This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JDBC and the fly likes java.sql.SQLException: No data read Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "java.sql.SQLException: No data read" Watch "java.sql.SQLException: No data read" New topic

java.sql.SQLException: No data read

vas reddy

Joined: Jun 11, 2008
Posts: 23

I am getting "java.sql.SQLException: No data read" when I run the following code.
but when I used ResultSet rs = stmt.executeQuery(); (the commented line in the code)
I do n't get any error. Can any one please explain the reason for this?

(The query is not returning any rows from DB,
rs is not null in both the cases.
ResultSet rs = stmt.getResultSet();
ResultSet rs = stmt.executeQuery();


con = ConnectionMain.getDbConnection();
CallableStatement cstmt = con.prepareCall("{ call XXXX(?, ?, ?) }");
cstmt.setString(1, set1);
cstmt.setString(2, set2);
cstmt.registerOutParameter(3, Types.VARCHAR);
app = cstmt.getString(3);

if (app == null || app.length()==0) {
PreparedStatement stmt = con.prepareStatement(query);
stmt.setString(1, app_num);

ResultSet rs = stmt.getResultSet();
//ResultSet rs = stmt.executeQuery();

if ( {
app = rs.getString(1);


vas reddy

Joined: Jun 11, 2008
Posts: 23
I found the reason
execute the query before getting the resultset.

either you use

ResultSet rs=stmt.getResultSet();


ResultSet rs = stmt.executeQuery();
Jeanne Boyarsky
internet detective

Joined: May 26, 2003
Posts: 30130

Thanks for sharing the solution for others who have the same problem!

[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
I agree. Here's the link:
subject: java.sql.SQLException: No data read
Similar Threads
Couldn't retreive a String from the result set
Problem when Retreiving from DataBase
SQLException: No data found
calling stored proc. w/ resultset return?
java stored procedure problems