【发布时间】:2012-04-03 14:21:32
【问题描述】:
大家好,我正在尝试使用用户在 html 中输入的用户名来验证数据库中的用户名,假设
un//be the variable where username entered now from html form is stored
现在如何从用户表中检索 uname 的所有列
uname //column name in mysql for usernames
user //table name in mysql
并检查天气用户名,即现在输入的用户名是否存在于数据库中 我正在使用
Connection con = DriverManager.getConnection("jdbc:mysql://localhost/mebps","root","admin");
Statement stmt = (Statement) con.createStatement();
ResultSet rs = stmt.executeQuery("select un from userinfo");
while(rs.next())
{
if(rs.getString("uname") == un)
{
out.println("user is present");
}
}
【问题讨论】: