What is the solution?

try {

Class.forName(“net.ucanaccess.jdbc.UcanaccessDriver”);
con = DriverManager.getConnection(“jdbc:ucanaccess://C:\Users\admin\Documents\NetBeansProjects\VotingSystems\votingdb.accdb”);

String sql = "select * from tblvoting where Username= " + txtusername.getText() + “‘and’” + txtpassword.getText() + “’”;

ps = con.prepareStatement(sql);
rs = ps.executeQuery();

if (rs.next()) {

JOptionPane.showMessageDialog(this, “Successful Login”);

} else {
JOptionPane.showMessageDialog(this, “Invalid Username or Password!”);
}

} catch (Exception e) {

System.out.println(e);

}

this is the problem

net.ucanaccess.jdbc.UcanaccessSQLException: UCAExc:::4.0.3 data type of expression is not boolean

I suggest you set a breakpoint in the debugger, or write to the console, the resulting value of the sql variable:

String sql = "select * from tblvoting where Username= " + txtusername.getText() + “‘and’” + txtpassword.getText() + “’”;

The above does not look correct to me.

Please follow-up to let us know how you made out. For good karma, mark a reply as the answer if it helped!

1 Like