Results 1 to 6 of 6
  1. #1
    anderma8 is offline Member
    Join Date
    Jul 2007
    Posts
    4
    Rep Power
    0

    Default Query with 1 record vs. multiple records

    I have a method that queryies the DB for a single record and returns the expected information, but when I create a 2nd method returining multiple records, I'm getting 0 records. I verified that the SQL statement is correct and I think it may have to do with the connection and statement. Can someone steer me in the right direction? I have the following:


    stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSI TIVE, ResultSet.CONCUR_READ_ONLY);
    rs.stmt.executeQuery("Select firstname, lastname from myTable");

    Thank!

  2. #2
    Albert is offline Senior Member
    Join Date
    Jun 2007
    Posts
    114
    Rep Power
    0

    Default

    Can you paste more code?
    I need to know how do you realized that you have 0 records.
    Maybe the problem is when you iterate in the resultset

  3. #3
    anderma8 is offline Member
    Join Date
    Jul 2007
    Posts
    4
    Rep Power
    0

    Default

    I hope this formats well:

    Here is the query: static String GETMFDEMPINFO = "select serialno, keyop, keyopempno, keyopbld, keyoproom, keyopphone, altop, altopempno, altopbld, altoproom, altopphone, dolu from tbl_mfd";


    Thanks for your input!


    public MFDObjList getMFDList() {
    Connection conn = getConnection();
    Statement stmt = null;
    ResultSet rs = null;

    MFDObjList myList = new MFDObjList();

    try {

    stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSI TIVE, ResultSet.CONCUR_READ_ONLY);
    rs = stmt.executeQuery(GETMFDEMPINFO);

    while (rs.next()) {
    MFDObj myMFD = new MFDObj();

    myMFD.setSerialNo(rs.getString("serialno"));
    myMFD.setKeyOp(rs.getString("keyop"));
    myMFD.setKeyOpEmpNo(rs.getString("keyopempno"));
    myMFD.setKeyOpBld(rs.getString("keyopbld"));
    myMFD.setKeyOpRoom(rs.getString("keyoproom"));
    myMFD.setKeyOpPhone(rs.getString("keyopphone"));
    myMFD.setAltOp(rs.getString("altop"));
    myMFD.setAltOpEmpNo(rs.getString("altopempno"));
    myMFD.setAltOpBld(rs.getString("altopbld"));
    myMFD.setAltOpRoom(rs.getString("altoproom"));
    myMFD.setAltOpPhone(rs.getString("altopphone"));

    myList.addMFDItem(myMFD);
    }

    } catch (Exception ex) {
    System.out.println("SQL Exception (" + ex.getMessage() + ")");
    } finally {
    returnResources(rs, stmt, conn);
    }
    return myList;
    }

  4. #4
    anderma8 is offline Member
    Join Date
    Jul 2007
    Posts
    4
    Rep Power
    0

    Default I think my problem is...

    that the table in which I am performing a query on is a new table and it may be a rights issue. When I try and grand myself rights to the table, I get:

    ORA-01749: you may not grant/revoke privileges to/from yourself

    I'm trying to figure out how else I can grant privileges to the user that created the table. I'm thinking this is what is causing my problem of 0 replies...

  5. #5
    anderma8 is offline Member
    Join Date
    Jul 2007
    Posts
    4
    Rep Power
    0

    Default Figured it out...

    it needed either the fully qualified table name OR a synonym... it works now! Thanks for your efforts!

  6. #6
    Albert is offline Senior Member
    Join Date
    Jun 2007
    Posts
    114
    Rep Power
    0

    Default

    I was testing your example but you've resolved it !! great
    ;)

Similar Threads

  1. Getting number of records (JDBC 2.0)
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 02-11-2008, 09:51 AM
  2. Replies: 0
    Last Post: 02-09-2008, 09:31 PM
  3. Number of updated records
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-21-2008, 05:32 PM
  4. selecting a record in database
    By ramachandran in forum New To Java
    Replies: 0
    Last Post: 10-25-2007, 08:06 AM
  5. Replies: 1
    Last Post: 07-26-2007, 08:28 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
  •