• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SQLException: No ResultSet

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 220
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 220
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you. Now it's working.
/jenny
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic