我正试图验证客户端提供的用户名和密码。当我试图执行我的代码时,我收到了一条错误消息:
java.sql.SQLSyntaxErrorException: 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 '= 'enki' and password = 'enki$'' at line 1
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:120)我的代码clientLogin()方法:
public static void clientLogin(String username, String password)
{
try
{
Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/ikub", "root", "root");
PreparedStatement ps = connection.prepareStatement("select username, password from clieent"
+ "where username = ? and password = ?");
ps.setString(1, username);
ps.setString(2, password);
ResultSet rs = ps.executeQuery();
if (rs.next())
System.out.println("done");
else
System.out.println("error");
connection.close();
} catch (Exception e)
{
System.out.println("ERROR CANT LOGIN!");
System.out.println("_____________");
e.printStackTrace();
}
}我认为我的sql查询有问题。
发布于 2019-04-30 05:59:27
我是说..。
“选择用户名,密码”+“其中用户名=.”
或
“选择用户名,密码”+“其中用户名=.”
https://stackoverflow.com/questions/55914626
复制相似问题