Connection conn = null;
//?
Connection conn = null;
try{
//
String url = "jdbc:mysql://localhost:3306/zhaohan";
//?
String user = "root";
String password = "123";
//
Class.forName("com.mysql.jdbc.Driver");
//
conn = DriverManager.getConnection(url, user, password);
}catch(Exception e){
System.out.println("?");
}
//
PreparedStatement st = conn.prepareStatement("insert into student(sname,pwd) values(?,?)");
//?
st.setString(1,name);
st.setString(2,pwd);
//
int i = st.executeUpdate();
//?
if(i > 0){ //?
request.getRequestDispatcher("select.jsp").forward(request,response);
}
//?
st.close();
conn.close();