File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes SQLException: No ResultSet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "SQLException: No ResultSet " Watch "SQLException: No ResultSet " New topic
Author

SQLException: No ResultSet

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Hello!
I have some problem when I do an Update in my Access database I get this exception every time, SQLException: No ResultSet was produced.
The data changes, but I still receive an exception. What have I done wrong?
/Jenny
Rajendar Goud
Ranch Hand

Joined: Mar 06, 2002
Posts: 220
Hi,
can u show us the code related to this..
may be u r closing the resultset some where in the middle of the program..
Raj
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
This is the code, I�m using a servlet and a bean.
This is from the servlet:
myVideoDAO.setVideoRecording(id, request.getParameter("showDate"), request.getParameter("price"));
And this is from the bean:
public void setVideoRecording(int recordingId, String showDate, String price)
throws RecordingNotFoundException, SQLException {
VideoRecording tempRecording = null;
Connection tempConn = null;
try {
tempConn = myConnPool.getConnection();
Statement myStmt = tempConn.createStatement();
myStmt.executeQuery("UPDATE Video_Recordings SET showDate='"+ showDate +"', price="+ price +" WHERE recording_id=" + recordingId);

myStmt.close();
}
catch (ConnectionUnavailableException exc) {
log(exc);
throw new SQLException(exc.getMessage());
}
finally {
if (tempConn != null) {
myConnPool.releaseConnection(tempConn);
}
}
}
/jenny
Rajendar Goud
Ranch Hand

Joined: Mar 06, 2002
Posts: 220
Jenny,
looks like u r using the wrong method of Statement object for the query.
stmt.executeQuery() is used for DDL statements and it returns ResultSet object.that may be the reason u r getting 'No ResultSet exception'.
ResultSet rs =st.executeQuery();
if u want to run DML statements like 'update' query u had to use,
st.executeUpdate("update statement..").
check this out...
Raj
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

Originally posted by Rajendar G:
Jenny,
looks like u r using the wrong method of Statement object for the query.
stmt.executeQuery() is used for DDL statements and it returns ResultSet object.that may be the reason u r getting 'No ResultSet exception'.
ResultSet rs =st.executeQuery();
if u want to run DML statements like 'update' query u had to use,
st.executeUpdate("update statement..").
check this out...
Raj

not quite,
Statement.executeUpdate():
public int executeUpdate(String sql)
throws SQLException
Executes an SQL INSERT, UPDATE or DELETE statement. In addition, SQL statements that return nothing, such as SQL DDL statements, can be executed.
Statement.executeQuery()
public ResultSet executeQuery(String sql)
throws SQLException
Executes an SQL statement that returns a single ResultSet object...typically this is a static SQL SELECT statement. This can also call a stored procedure that returns a resultset. Not for DDL
Jamie
Jamie
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Thank you. Now it's working.
/jenny
 
 
subject: SQLException: No ResultSet