所以我在intellij中创建了一个数据库表,我创建了一个javafx项目,它连接到我的服务器(localhost) 现在我在这里遇到错误
String query = "SELECT * FROM IntellijDB.dbo.Employee WHERE username = ? and passcode = ?";
它说我无法访问该表
这是方法
public boolean isLogin(String user,String pass) throws SQLException
{
PreparedStatement preparedStatement = null ;
ResultSet resultSet = null;
String query = "SELECT * FROM IntellijDB.dbo.Employee WHERE username = ? and passcode = ?";
try
{
preparedStatement = connection.prepareStatement(query);
preparedStatement.setString(1,user);
preparedStatement.setString(2,pass);
resultSet = preparedStatement.executeQuery();
if (resultSet.next())
{
return true;
}
else
{
return false;
}
}
catch (Exception e)
{
return false;
//TODO: handle exception
}
finally {
preparedStatement.close();
resultSet.close();
}
}
和其他错误
if (loginModel.isLogin(userAction.getText(), passAction.getText()))
这条线也是
resultSet.close();
我想他们是相关的,我不知道如何解决这个问题 这是其他代码
@FXML
public void Login(ActionEvent event) {
try {
if (loginModel.isLogin(userAction.getText(), passAction.getText())) {
isConnected.setText("Username & password is correct");
}
else
{
isConnected.setText("Check your username or password");
}
} catch (SQLException e)
{
isConnected.setText("Check your username or password");
//TODO Auto-generated catch block
e.printStackTrace();
}
}