i am creating a bank application with connection of MS ACCESS Database which is already construct a table with the following statement
Statement stmt = con.createStatement();
stmt.executeUpdate("CREATE TABLE ACCOUNT " +
"(AccName VARCHAR(32), AccNum INTEGER, Deposit FLOAT, " +
"Balance FLOAT, Withdraw FLOAT)");
So everything works fine ,the table was constructed successfully and i can create a record in the table ,but the problem is i cannot validate the record that exist in the table.The following code state the matter :
else if(source == signinButton)
{
String accname = JOptionPane.showInputDialog(null,"Please enter the Account Username");
String accnum = JOptionPane.showInputDialog(null,"Please enter the Account Number");
int number = Integer.parseInt(accnum);
try
{
st1.close(); //close connection with Database
st1=con.createStatement(); //open connection with database
rs1 =st1.executeQuery("Select * from ACCOUNT where AccNum like '"+number+"'"); //SQL statement
//rs1.next(); //moves the cursor forward one row
//txtA1.setText(rs1.getString("AccName"));
//txtA2.setText(rs1.getString("AccNum"));
// txtTextArea.append("Account Holder's Name :" + rs1.getString("AccName") + "\n");
// txtTextArea.append("Account Number :" + rs1.getString("AccNum") + "\n");
}
catch(Exception e1)
{
JOptionPane.showMessageDialog(null,"Invalid Account Number");
}
}
It keep prompt out the" Invalid Account Number" even i insert the data correctly.i might be some problem within the line
(rs1 =st1.executeQuery("Select * from ACCOUNT where AccNum like '"+number+"'");)