Home > Database > Mysql Tutorial > mysql-JDBC连接MySQL插入数据问题

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

WBOY
Release: 2016-06-06 09:43:44
Original
1053 people have browsed it

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

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template