繼承人我的代碼:用於連接數據庫會有什麼rs.getString(1)返回如果SQL查詢不返回任何
代碼:
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection con=DriverManager.getConnection("jdbc:sqlserver://localhost:1433;databaseName=city_mart;user=sa;password=aptech");
Statement st=con.createStatement();
String sql="Select Emp_login_ID from employee where Emp_login_ID = '"+r3.getText()+"' ";
ResultSet rs=st.executeQuery(sql);
String login = rs.getString(1);
if (r3.getText().equalsIgnoreCase(login))
{
JOptionPane.showMessageDialog(rootPane, "Login ID not available.");
}
else
{
JOptionPane.showMessageDialog(rootPane, "Login ID is available.");
}
thanks.any幫助深表感謝。
自2007年以來,Class.forName()行一直是不必要的。 – EJP