String sess_user = session.getAttribute("userid").toString();
out.println(sess_user);
try{
String connectionURL = "jdbc:mysql://localhost:3306/books";// books is the database
Connection connection = null;
Class.forName("com.mysql.jdbc.Driver");
connection = DriverManager.getConnection(connectionURL, "root", "bonnysingh");
Statement st = connection.createStatement();
ResultSet rs=st.executeQuery("select email from signup where UserName = '" + sess_user +"'");
while(rs.next()){
userEmail = rs.getString(3);
}
}
catch(Exception ee){
out.println(ee);
}
out.println("Hello");
out.println(userEmail);
userEmail 的输出始终为空。我不知道这里有什么问题。但我认为 while(rs.next()) 循环没有正确执行。谁能告诉我错误是什么?