Can anyone help me to check my error
hi, can anyone help me to check my code and find where is the error
after run my project, it show me error in SQL statement
thx ya:-<
private void initializeDB(){
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conCustomer = DriverManager.getConnection("jdbc:odbc:CustomerDB" );
stmtCustomer = conCustomer.createStatement();
}
catch(Exception ex){
JOptionPane.showMessageDialog(null, "Error in connection to Database");
}
}
private void findCustomer(ActionEvent e){
String custID = jtfCustomerID.getText();
String sqlSelect = "Select * From Customers Where cust_ID = '" + custID + "'";
try{
ResultSet rsCustomer = stmtCustomer.executeQuery(sqlSelect);
System.out.println("Error");
if(rsCustomer.next()){
jlblCustomerName.setText(rsCustomer.getString("Cus t_Name"));
jlblCustomerAddress.setText(rsCustomer.getString(" Cust_Address"));
}
else{
JOptionPane.showMessageDialog(null, "Customer not found");
}
}
catch(SQLException ex){
JOptionPane.showMessageDialog(null, "Error in SQL Statement");
}
}
Re: Can anyone help me to check my error
check out the entity "cus t_Name" cause in query there does'nt support any blank in name of an entity.
Re: Can anyone help me to check my error
although i correct it, it still come out with error in SQL statement
Re: Can anyone help me to check my error
Quote:
Originally Posted by
Kelvin017
... error in SQL statement
What error?
Code :
catch(SQLException ex){
JOptionPane.showMessageDialog(null, "Error in SQL Statement");
}
A part of your code from above... Not a good way to troubleshoot. That "ex" up there is the key to much more powerful insight to the problem you have.
Re: Can anyone help me to check my error
..yes, jbs is right. Try to ex.printStackTrace()