This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
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
posted
0
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
posted
0
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);
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
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