-3
我使用的SQLite做一个登录,但是比较我用下面的代码的登录名和数据库的话:两个相同的字不同
public static boolean result(String nome, String pass) {
Connection c = null;
Statement stmt = null;
boolean bo = false;
try {
Class.forName("org.sqlite.JDBC");
c = DriverManager
.getConnection("jdbc:sqlite:C:/Users/M4UR0/Desktop/Pastas/Programação/Java/Albamoura/data.db");
c.setAutoCommit(false);
stmt = c.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM COMPANY where NAME = '" + nome + "';"); //
String password = rs.getString("PASSWORD");
if (rs.next() || !pass.equalsIgnoreCase(password)) {
bo = false;
System.out.println("deu1 " + password + " - " + pass);
} else {
System.out.println("Entrou!");
bo = true;
}
rs.close();
stmt.close();
c.close();
} catch (Exception e) {
System.err.println(e.getClass().getName() + ": " + e.getMessage());
System.exit(0);
bo = false;
}
System.out.println("Operation done successfully");
return bo;
}
和控制台说:
Conecçãoestabelecida!
deu1单词 - 单词
操作已成功完成
假
2相同的字显示为不同的,我没有注意到的东西吗?帮助请
什么是“stromg”? –
其言辞对不起。 –
我也注意到'stmt.executeQuery(...)'行很容易出现SQL注入,您可能想使用预处理语句。 – dat3450