jsp 无法获取数据库的值,
<%StringName="";Stringpword="";intid=0;Connectionconn=null;Statementstmt=null;ResultS...
<%
String Name = "";
String pword = "";
int id = 0;
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
String url = "jdbc:mysql://localhost:3306/kchshj";
String user = "root";
String pass = "123";
try {
Class.forName("com.mysql.jdbc.Driver");
conn = DriverManager.getConnection(url, user, pass);
} catch (Exception e) {
System.out.println("数据库连接错误!!!");
e.printStackTrace();
}
stmt = conn.createStatement();
String sql = "select S_name,S_password from admin where S_username='"
+ name + "'";
rs = stmt.executeQuery(sql);
while (rs.next()) {
Name = rs.getString("S_name");
pword = rs.getString("S_password");
System.out.println(pword);
为什么pword获取不了值,而数据库其他字段的值都可以获取
好了,已经解决了,谢谢啊 展开
String Name = "";
String pword = "";
int id = 0;
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
String url = "jdbc:mysql://localhost:3306/kchshj";
String user = "root";
String pass = "123";
try {
Class.forName("com.mysql.jdbc.Driver");
conn = DriverManager.getConnection(url, user, pass);
} catch (Exception e) {
System.out.println("数据库连接错误!!!");
e.printStackTrace();
}
stmt = conn.createStatement();
String sql = "select S_name,S_password from admin where S_username='"
+ name + "'";
rs = stmt.executeQuery(sql);
while (rs.next()) {
Name = rs.getString("S_name");
pword = rs.getString("S_password");
System.out.println(pword);
为什么pword获取不了值,而数据库其他字段的值都可以获取
好了,已经解决了,谢谢啊 展开
2010-12-23
展开全部
其他的都能获取,就是获取不到pword,那么一定是pword = rs.getString("S_password");这句话有问题,看看S_password是不是写错了
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询