I am trying to get the result of SELECT 1
query using PreparedStatement. I am unable to get the result. Since the select 1 query result has no column name, so how can I retrieve the resultant column value.
Connection conn = DB.getconnnection();
PreparedStatement ps = conn.prepareStatement("select 1 from tbl_user where username = ? and password = ?");
ps.setString(1,txtUsername.getText());
ps.setString(2,String.valueOf(txtPassword.getPassword()));
ResultSet rs=ps.executeQuery();
String status=rs.getString("");
System.out.println(status);
conn.close();
I referred the code from java tutorial, I can not understand why is there ?
in the query statement (select 1 from tbl_user where username = ? and password = ?
). Please clarify.