ps.setString(1, pwd);
ps.setString(2, nickname);
pwd 是英文,nickname是中文,每次查找的时候都提示You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' nickname = '???????‘?'' at line 1
这个问题,向数据库插入的时候就没有问题,不是为什么查找就不行,知道的大神帮下忙啊!
7 个解决方案
#1
晕,你的SQL语句写错了,应该是select * from user where pwd=? and nickname=?
#2
不是那个原因,逗号和and 都行
#3
朋友,你试试下面的方法
Connection con=DriverManager.getConnection(conURL);
Statement s=con.createStatement();
ResultSet rs=s.executeQuery("select *from user");
i=0;
while(rs.next())
{
s1=rs.getString("pwd");
s2=rs.getString("nickname");
i++;
}
即可得到你需要的字符串
Connection con=DriverManager.getConnection(conURL);
Statement s=con.createStatement();
ResultSet rs=s.executeQuery("select *from user");
i=0;
while(rs.next())
{
s1=rs.getString("pwd");
s2=rs.getString("nickname");
i++;
}
即可得到你需要的字符串
#4
Connection con=DriverManager.getConnection(conURL);
Statement s=con.createStatement();
ResultSet rs=s.executeQuery("select *from vip");
int i=0;
while(rs.next())
{
s1=rs.getString("nickname");
s2=rs.getString("pwd");
i++;
}
Statement s=con.createStatement();
ResultSet rs=s.executeQuery("select *from vip");
int i=0;
while(rs.next())
{
s1=rs.getString("nickname");
s2=rs.getString("pwd");
i++;
}
#5
本以为是lz讲的那样,好奇之下验证之,结果证明:1楼讲的是对的...
#6
不能用逗号,用and
#7
问题已经解决了,谢谢大家了!
#1
晕,你的SQL语句写错了,应该是select * from user where pwd=? and nickname=?
#2
不是那个原因,逗号和and 都行
#3
朋友,你试试下面的方法
Connection con=DriverManager.getConnection(conURL);
Statement s=con.createStatement();
ResultSet rs=s.executeQuery("select *from user");
i=0;
while(rs.next())
{
s1=rs.getString("pwd");
s2=rs.getString("nickname");
i++;
}
即可得到你需要的字符串
Connection con=DriverManager.getConnection(conURL);
Statement s=con.createStatement();
ResultSet rs=s.executeQuery("select *from user");
i=0;
while(rs.next())
{
s1=rs.getString("pwd");
s2=rs.getString("nickname");
i++;
}
即可得到你需要的字符串
#4
Connection con=DriverManager.getConnection(conURL);
Statement s=con.createStatement();
ResultSet rs=s.executeQuery("select *from vip");
int i=0;
while(rs.next())
{
s1=rs.getString("nickname");
s2=rs.getString("pwd");
i++;
}
Statement s=con.createStatement();
ResultSet rs=s.executeQuery("select *from vip");
int i=0;
while(rs.next())
{
s1=rs.getString("nickname");
s2=rs.getString("pwd");
i++;
}
#5
本以为是lz讲的那样,好奇之下验证之,结果证明:1楼讲的是对的...
#6
不能用逗号,用and
#7
问题已经解决了,谢谢大家了!