这是jsp代码
这是jsp代码
final String DBDRIVER="com.mysql.jdbc.Driver";
final String DBURL="jdbc:mysql://localhost:3306/wangzhan";
final String DBUSER="root";
final String DBPASSWORD="999999";
Connection conn =null;
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql =null;
%>
try{
sql="insert into mytable VALUES(?,?)";
Class.forName(DBDRIVER);
conn=DriverManager.getConnection(DBURL,DBUSER,DBPASSWORD);
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,username);
pstmt.setString(2,password);
pstmt.executeUpdate();
out.println("insert successful");
//rs.close();
pstmt.close();
conn.close();
}
catch(Exception e)
{out.println(e);}
%>
这是数据库语句
create table mytable ( username varchar(20),password varchar(20),email varchar(20));
展开