Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-09-2007, 07:47 PM
Member
 
Join Date: Jul 2007
Posts: 4
anderma8 is on a distinguished road
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!
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-09-2007, 08:59 PM
Senior Member
 
Join Date: Jun 2007
Posts: 114
Albert is on a distinguished road
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
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 07-09-2007, 09:24 PM
Member
 
Join Date: Jul 2007
Posts: 4
anderma8 is on a distinguished road
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;
}
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 07-09-2007, 11:52 PM
Member
 
Join Date: Jul 2007
Posts: 4
anderma8 is on a distinguished road
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...
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 07-09-2007, 11:57 PM
Member
 
Join Date: Jul 2007
Posts: 4
anderma8 is on a distinguished road
Figured it out...
it needed either the fully qualified table name OR a synonym... it works now! Thanks for your efforts!
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 07-10-2007, 12:33 AM
Senior Member
 
Join Date: Jun 2007
Posts: 114
Albert is on a distinguished road
I was testing your example but you've resolved it !! great
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting number of records (JDBC 2.0) Java Tip Java Tips 0 02-11-2008 09:51 AM
Deleting records from database table using PreparedStatement Java Tip Java Tips 0 02-09-2008 09:31 PM
Number of updated records Java Tip Java Tips 0 01-21-2008 05:32 PM
selecting a record in database ramachandran New To Java 0 10-25-2007 08:06 AM
How to extract each record from a large XML doc. which contain multiple nodes renjan XML 1 07-26-2007 08:28 PM


All times are GMT +3. The time now is 12:54 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org