-1
當我輸入正確的用戶名/密碼時,查詢正常工作,客戶端與服務器之間的連接正常工作。但是,如果我做了不正確的用戶名/密碼組合,那麼程序會凍結正確的一個。我使用JDBC連接使用Java。在多個查詢條目後,JDBC會凍結
String usr = clientName.getText();
String pass = clientPass.getText();
String u = null, p = null;
ResultSet results=null;
String stmtLogin = "Select * from userInfo where username = '" + usr + "'";
try
{
results = statement.executeQuery(stmtLogin);
results.next();
u = results.getString(1);
p = results.getString(2);
}
catch (SQLException e)
{
e.printStackTrace();
}
if ((pass.equals(p)) && usr.equals(u))
{
message = clientName.getText();
output.println(message);
btnSendM.setEnabled(true);
btnConn.setEnabled(false);
clientName.setEditable(false);
clientPass.setEditable(false);
messageBox.append(message + " has entered the chatroom \n");
btnSendM.setFont(new Font("Verdana", Font.BOLD, 10));
updateConnList();
}
else
JOptionPane.showMessageDialog(null, "Username Password Incorrect, Please try Again");
你嘗試過使用調試器嗎? – akhilless
你有沒有關閉這些東西? 「ResultSet?''Statement?''Connection?' – EJP
不,我不會在這裏關閉它們,生病嘗試關閉它們,看看是否有幫助。謝謝 – user3125462