Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: Can anyone help me to check my error

  1. #1
    Junior Member
    Join Date
    Jul 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default 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("jdbcdbc: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");
    }
    }


  2. #2
    Junior Member
    Join Date
    Jul 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default 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.

  3. #3
    Junior Member
    Join Date
    Jul 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Can anyone help me to check my error

    although i correct it, it still come out with error in SQL statement

  4. #4
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: Can anyone help me to check my error

    Quote Originally Posted by Kelvin017 View Post
    ... error in SQL statement
    What error?

    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.

  5. #5
    Member
    Join Date
    Jul 2012
    Posts
    119
    Thanks
    0
    Thanked 19 Times in 19 Posts

    Default Re: Can anyone help me to check my error

    ..yes, jbs is right. Try to ex.printStackTrace()

Similar Threads

  1. Replies: 0
    Last Post: June 23rd, 2012, 01:57 AM
  2. Error Check Not Working
    By Damian3395 in forum What's Wrong With My Code?
    Replies: 4
    Last Post: January 17th, 2012, 02:25 PM
  3. how to check the value
    By javaking in forum Java Servlet
    Replies: 2
    Last Post: July 22nd, 2010, 07:56 AM
  4. Collision Check Error
    By Josh Yaxley in forum What's Wrong With My Code?
    Replies: 19
    Last Post: July 12th, 2010, 03:12 PM
  5. Problem in AWT and IFrame implementaion
    By AZBOY2000 in forum What's Wrong With My Code?
    Replies: 9
    Last Post: April 24th, 2009, 04:41 AM