Results 1 to 6 of 6
- 07-09-2007, 06:47 PM #1
Member
- Join Date
- Jul 2007
- Posts
- 4
- Rep Power
- 0
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!
- 07-09-2007, 07:59 PM #2
Senior Member
- Join Date
- Jun 2007
- Posts
- 114
- Rep Power
- 0
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
- 07-09-2007, 08:24 PM #3
Member
- Join Date
- Jul 2007
- Posts
- 4
- Rep Power
- 0
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;
}
- 07-09-2007, 10:52 PM #4
Member
- Join Date
- Jul 2007
- Posts
- 4
- Rep Power
- 0
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...
- 07-09-2007, 10:57 PM #5
Member
- Join Date
- Jul 2007
- Posts
- 4
- Rep Power
- 0
Figured it out...
it needed either the fully qualified table name OR a synonym... it works now! Thanks for your efforts!
- 07-09-2007, 11:33 PM #6
Senior Member
- Join Date
- Jun 2007
- Posts
- 114
- Rep Power
- 0
Similar Threads
-
Getting number of records (JDBC 2.0)
By Java Tip in forum Java TipReplies: 0Last Post: 02-11-2008, 08:51 AM -
Deleting records from database table using PreparedStatement
By Java Tip in forum Java TipReplies: 0Last Post: 02-09-2008, 08:31 PM -
Number of updated records
By Java Tip in forum Java TipReplies: 0Last Post: 01-21-2008, 04:32 PM -
selecting a record in database
By ramachandran in forum New To JavaReplies: 0Last Post: 10-25-2007, 07:06 AM -
How to extract each record from a large XML doc. which contain multiple nodes
By renjan in forum XMLReplies: 1Last Post: 07-26-2007, 07:28 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks