我试图在Eclipse中用Java创建一个注册程序。 但是我收到了一个错误:
java.sql.SQLException: Query does not return results
您可以看到以下代码:
Login.addnewuser(lblname.getText(), lblusername.getText(), lblpseudo.getText(), passwordField.getText(), rankchoice.getSelectedItem());
:
public static void addnewuser(String Name, String Username, String Pseudo, String Password, String Rank) {
String query = ("INSERT INTO UsersInfos (Name, Username, Pseudo, Password, Rank) " + "VALUES ('" + Name + "' , '" + Username + "' , '" + Pseudo + "' , '" + Password + "' , '" + Rank + "')");
connection = SqliteConnection.dbConnector();
try {
PreparedStatement name2 = connection.prepareStatement(query);
name2.executeQuery();
} catch (SQLException e) {
e.printStackTrace();
}
}
有人可以帮助我吗?谢谢:)!
答案 0 :(得分:10)
对于INSERT
,UPDATE
或DELETE
使用executeUpdate()
方法,SELECT
使用executeQuery()
方法返回{{1} }}