Maison >base de données >tutoriel mysql >mysql-JDBC连接MySQL插入数据问题
mysqljdbc连接插入数据
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/mysql", "root", "123456");
PreparedStatement sqlStmt =null;
String Email=request.getParameter("Email");
String Password=request.getParameter("Password");
String RePassword=request.getParameter("RePassword");
int power=1;
String sql = "INSERT INTO user_type(user_name,password,power) VALUES (?,?,?)";
sqlStmt=conn.prepareStatement(sql);
sqlStmt.setString(1,"Email") ;
sqlStmt.setString(2,"Password") ;
sqlStmt.setInt(3,'1') ;
sqlStmt.executeUpdate(sql);
out.print("alert('插入成功!');window.location.href='contact.html'");