当前位置:Gxlcms > mysql > mysql-JDBC连接MySQL插入数据问题

mysql-JDBC连接MySQL插入数据问题

时间:2021-07-01 10:21:17 帮助过:54人阅读

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'");

人气教程排行