Results 1 to 3 of 3
  1. #1
    marvelk is offline Member
    Join Date
    Jan 2011
    Rep Power

    Default retrivieving from oraclexe database table to data program

    i try to retrieve data from a database to my java program but the code doesn't seem to work no error but it just doesnt work

    here is the code
    try {
    String nam = jComboBox9.getSelectedItem().toString();

    st2 = con.createStatement();

    rs1 = st2.executeQuery("select * from member2 where name = "+ nam +" " );;


    } catch (SQLException ex) {
    Logger.getLogger(CPM.class.getName()).log(Level.SE VERE, null, ex);

  2. #2
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Voorschoten, the Netherlands
    Blog Entries
    Rep Power


    Quote Originally Posted by marvelk View Post
    rs1 = st2.executeQuery("select * from member2 where name = "+ nam +" " );
    For starters, shouldn't a value be put in single quotes? having said that, it reminds me of this.

    kind regards,

    Build a wall around Donald Trump; I'll pay for it.

  3. #3
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Rep Power


    Debug it.
    Print out the values.

    As Jos says, I doubt that SQL will run so you ought to be getting an exception. Where it's going (are you logging to a file?) I have no idea.

    ETA: Oh yes, and this is one of the reasons for keeping display logic separate from db logic.
    Make a DAO (Data Access Object) that gets the data you want from the db and creates a List of a suitable class which it returns.
    The display can then show the data based on this list and not care where it comes from.
    In addition you'll be able to test the db logic in isolation since it won't care what's done with that data.

    Oh...and PreparedStatement.
    Last edited by Tolls; 02-03-2011 at 09:25 AM.

Similar Threads

  1. error in reading data from table in pidgree database
    By chethan_kc in forum Java Servlet
    Replies: 17
    Last Post: 02-18-2011, 03:11 PM
  2. Connecting to a database table
    By kiz106 in forum JDBC
    Replies: 1
    Last Post: 05-19-2010, 10:33 AM
  3. How to display database in table
    By tamnc in forum SWT / JFace
    Replies: 0
    Last Post: 03-15-2010, 06:57 AM
  4. Replies: 0
    Last Post: 02-09-2008, 09:22 PM
  5. Replies: 1
    Last Post: 02-01-2008, 02:21 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts