与数据库建立连接
Class.forName(“com.mysql.jdbc.Driver”);
String url = “jdbc:mysql:\127.0.0.1:3306:\et2107”;
String username = “root”;
String password = “123456”;
Connection conn = DriverManager.getConnection(url,username,password);
Statement stmt = conn.createStatement();
String sql = “insert into user values(null,’+username+’,’+password+’)”;
int count= stmt.executeUpdate(sql);
String sql1 = “select password from user where username = ? and password = md5(?)”;
PreparedStatement pstmt = conn.prepareStatement();
pstmt.setString(1,username);
pstmt.setString(2,password);
ResultSet rs= pstmt.executeQuery();