欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  数据库

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

程序员文章站 2024-02-06 23:30:22
...
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'");