Please help with selecting a String from a database

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Tripmaker
    New Member
    • Jun 2007
    • 60

    Please help with selecting a String from a database

    What is wrong with my codeing. When I select the search button via my GUI, the GUI dissappears, it doesn't even go to the catch dialog. But when I copy and paste my search query to MySQL it works normally. Please explain.

    Here is my code:

    [CODE=java]If (source == searchB)
    {
    try
    {
    query = "SELECT Telephone,Book, Date from loan WHERE Name = ' " +
    nameT.getText() + " ' ";

    rs = stmt.executeQue ry(query);
    rs.next();
    TelT.setText(rs .getString("Tel ephone"));
    bookT.setText(r s.getString("Da te"));
    dateT.setText(r s.getString("Da te"));
    }
    catch(SQL Exception sql)
    {
    JOptionPane.sho wMessageDialog( this,"Details not found");
    }
    }
    [/code]
    Thank you in advance.

    Petra
  • pbmods
    Recognized Expert Expert
    • Apr 2007
    • 5821

    #2
    Heya, Petra.

    Can you echo your query? What does it look like?

    Comment

    • Tripmaker
      New Member
      • Jun 2007
      • 60

      #3
      Originally posted by pbmods
      Heya, Petra.

      Can you echo your query? What does it look like?
      When I type in a persons name in my GUI I want it to link to my database and give me the persons telephone number, the book they loaned and the date that they took the book.

      Petra

      Comment

      • ak1dnar
        Recognized Expert Top Contributor
        • Jan 2007
        • 1584

        #4
        Originally posted by Tripmaker
        When I type in a persons name in my GUI I want it to link to my database and give me the persons telephone number, the book they loaned and the date that they took the book.

        Petra
        As I can see from the Original post your GUI is Java Based.
        So first try to get the User Inputs from the input box and try to print It back when pressing the *Search Button*.

        If its working then we will try to check it out whats going on there on the try and catch blocks.

        Comment

        • Tripmaker
          New Member
          • Jun 2007
          • 60

          #5
          Originally posted by ajaxrand
          As I can see from the Original post your GUI is Java Based.
          So first try to get the User Inputs from the input box and try to print It back when pressing the *Search Button*.

          If its working then we will try to check it out whats going on there on the try and catch blocks.
          You're correct in assuming that my GUI is Java Based. Please forgive me, but please can you explain in laymans terms what you want me to do. I'm very new at programming.

          Thank you.

          Comment

          Working...