java代码不连数据库 java实现数据库连接代码

java web不连接数据库会怎样数据库java代码不连数据库你从名字就知道就是存放数据java代码不连数据库的地方 。
你做web项目的时候一般都是靠数据库来活着的java代码不连数据库,比如你说登录这种java代码不连数据库,你就得有地方存用户信息 。
但是没说没数据库web项目就活不java代码不连数据库了 。我写个web项目,就写个页面,页面给你提供一个xx的算法什么的也都是可以的,比如我给你个页面,随机输出个数字,这样只要写个接口然后前端调接口也没数据库什么事 。不过话说回来这么做和咸鱼有什么区别 。
如何使用java写一个增删改查的通用类,不需要连接数据库import java.util.LinkedList;
import javax.swing.text.html.HTMLDocument.Iterator;
public class TestKnow {
public static void main(String[] args) {
Student s1 = new Student(1,"s1",15);
Student s2 = new Student(2,"s2",15);
Student s3 = new Student(3,"s3",15);
Grade g = new Grade(1);
g.add(s1);g.add(s2);g.add(s3);//增
g.delete(s1);//删
Student s4 = new Student(4,"s4",12);
g.change(s2, s4);//改
Student ss = g.check(3);//查
System.out.println(ss.name);
}
}
class Student{
int num;//学号
String name;
int age;
public Student(int num,String name,int age){
this.num = num;
this.name = name;
this.age = age;
}
}
class Grade{
int gnum;
LinkedListStudent grade;
public Grade(int gnum){
this.gnum = gnum;
grade = new LinkedListStudent();
}
public void add(Student s){
grade.add(s);
}
public Student check(int n){
java.util.IteratorStudent it = grade.iterator();
while(it.hasNext()){
Student temp = it.next();
if(temp.num==n)
return temp;
}
return null;
}
public void delete(Student s){
if(grade != null)
if(check(s.num)!=null)
grade.remove(s);
else
System.out.println("没有此人");
else
System.out.println("班里没人");
}
public void change(Student s1,Student s2){
if(grade != null)
if(check(s1.num)!=null)
{
grade.remove(s1);
grade.add(s2);
}
else
System.out.println("没有要替换java代码不连数据库的人");
else
System.out.println("班里没人");
}
}
Java开发一定要连接数据库吗不是一定的,可以用文件保存数据 , 但是大点的应用程序都使用数据库 。
java 登录注册界面代码怎么写?不链接数据库 。不用mysql !给你提供个思路吧
1、注册界面把注册的人的用户名和密码存储到本地的一个txt文件中
2、登录时比较登录输入的用户名和密码和txt文件中的是否一致,如果一致就允许登录,不一致提示异常
用Java设计一个登录页面,不用连接数据库 , 只要把用户和密码信息存放在文本里面 , 怎样设计代码???/* Main.java
*
* Created on __DATE__, __TIME__
*/
import javax.swing.JOptionPane;
/**
*
* @author__USER__
*/
public class Main extends javax.swing.JFrame {
/** Creates new form Main */
public Main() {
initComponents();
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
//GEN-BEGIN:initComponents
// editor-fold defaultstate="collapsed" desc="Generated Code"
private void initComponents() {
jPanel1 = new javax.swing.JPanel();//标签
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();

推荐阅读