Error Java .sql.sqlexception No Resultset Was Produced
I EXECUTE THE BELOW CODE I GETS AN EXCEPTION java.sql.SQLException: No ResultSet was produced.........BUT EVEN THOUGH INSERTION OPERATION WORKS FINE........CAN ANYONE TELL ME WHY THIS EXCEPTION COMES Connection co; try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); co = DriverManager.getConnection("jdbc:odbc:hh"); Statement st1; ResultSet result; st1 = co.createStatement(); result=st1.executeQuery("select count(*) from rooms"); result.next(); int cn = result.getInt(1); System.out.println("count"+cn); String depart = (String) dept1.getSelectedItem(); if("Others".equals(depart)) { cn++; st1.executeQuery("insert into rooms (room_number, serial, depart) values('"+room_no1.getText()+"','"+cn+"','"+others1.getText()+"')"); } st1.close(); } catch (Exception ex) {System.out.print(ex);} Jessurider -10 207 posts since Feb 2011 Community Member 3Contributors 4Replies 9Views 5 YearsDiscussion Span 5 Years Ago Last Post by Jessurider 0 peter_budo 2,516 5 Years Ago Because you used executeQuery instead of executeUpdate PS: Writing with Caps Lock is like shouting, that is considere rude. 0 murali_quest -5 5 Years Ago Hi nidhish According to 9th line you have used result.next() without any if statement. If your table is empty while executing first time result.next() will throw an error. Got it? 0 Featured Reply murali_quest -5 5 Years Ago Another problem is for ddl statements you should use executeUpdate. for dml you shoul use executeQuery. According to 16th line you should use executeUpdate.. 0 Discussion Starter Jessurider -10 5 Years Ago thanks................ java This question has already been answered. Start a new discussion instead. Message Insert Code Snippet Alt+I Code Inline Code Link H1 H2 Preview Submit your Reply Alt+S Ask a Different Software Development Question Related Articles problem in having two ResultSet in single statement. 26 replies I am using two ResultSet in a single statement..this code is a part of servlet.. [C
This Site Careers Other all forums Forum: JDBC and Relational Databases SQLException: No ResultSet Anonymous Ranch Hand Posts: 18944 posted 14 years ago 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 https://www.daniweb.com/programming/software-development/threads/373165/why-java-sql-sqlexception-no-resultset-was-produced Posts: 220 posted 14 years ago 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 posted 14 years ago This is the code, I�m using a servlet and https://coderanch.com/t/297119/JDBC/databases/SQLException-ResultSet 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 posted 14 years ago 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 t
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the http://stackoverflow.com/questions/4524132/jdbc-resultset-no-results workings and policies of this site About Us Learn more about http://forums.pentaho.com/showthread.php?200752-No-ResultSet-was-produced Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. error java Join them; it only takes a minute: Sign up JDBC ResultSet no results? up vote -1 down vote favorite Why aren't there any results for this query? Only "Movies!" is printed when i run this servlet. import java.io.*; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.sql.*; public class Service extends HttpServlet { private static final long serialVersionUID error java .sql.sqlexception = 1L; protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); out.println("Movies!"); Connection connection = null; Statement statement = null; try { connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/test"); statement = connection.createStatement(); String query = "SELECT * FROM movies"; ResultSet rs = statement.executeQuery(query); while(rs.next()) { out.println("result set"); out.print(rs.getInt(1)); out.print(rs.getString(2)); out.print(rs.getInt(3)); out.print(rs.getInt(4)); } } catch(SQLException e) { e.printStackTrace(); } } } java servlets jdbc share|improve this question edited Dec 24 '10 at 4:22 BalusC 683k20824732692 asked Dec 24 '10 at 4:05 aLk 93 2 Has no relevance to your question, but always finally close Connection, Statement, ResultSet (or use DbUtils). –Thilo Dec 24 '10 at 4:18 +10 for Thilo's comment. –Stephen C Dec 24 '10 at 4:39 add a comment| 5 Answers 5 active oldest votes up vote 2 down vote Best guess: There are no rows in the table. What's the result when you execute the query manually ? mysql test # connect to mysql SELECT * FROM movies; share|improve this answer answered Dec 24 '10 at 4:12 b7kich 2,5912
View Site Leaders Advanced Search Forum Pentaho Users Pentaho Data Integration [Kettle] No ResultSet was produced If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. Results 1 to 2 of 2 Thread: No ResultSet was produced Thread Tools Show Printable Version Subscribe to this Thread… Search Thread Advanced Search Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode 02-05-2016,01:46 AM #1 mbmartinez View Profile View Forum Posts Private Message Junior Member Join Date Feb 2016 Posts 8 No ResultSet was produced Hi all, I'm getting this error during the Table Input step. My datasource is an ODBC datasource connected to a Marklogic database. I have chosen Generic Database as my connection type and entered the required odbc connection details. Test connection is successful. I am even able to explore the database in Database Explorer!However, when I run the simple "select * from operators" query, I get this: 2016/02/05 14:35:36 - Table input.0 - select * from operators 2016/02/05 14:35:36 - Table input.0 - No ResultSet was produced 2016/02/05 14:35:36 - Table input.0 - 2016/02/05 14:35:36 - Table input.0 - at org.pentaho.di.core.database.Database.openQuery(Database.java:1729) 2016/02/05 14:35:36 - Table input.0 - at org.pentaho.di.trans.steps.tableinput.TableInput.doQuery(TableInput.java:224) 2016/02/05 14:35:36 - Table input.0 - at org.pentaho.di.trans.steps.tableinput.TableInput.processRow(TableInput.java:138) 2016/02/05 14:35:36 - Table input.0 - at org.pentaho.di.trans.step.RunThread.run(RunThread.java:62) 2016/02/05 14:35:36 - Table input.0 - at java.lang.Thread.run(Thread.java:745) 2016/02/05 14:35:36 - Table input.0 - Caused by: java.sql.SQLException: No ResultSet was produced 2016/02/05 14:35:36 - Table input.0 - at sun.jdbc.odbc.JdbcOdbcStatement.executeQuery(JdbcOdbcStatement.java:258) 2016/02/05 14:35:36 - Table input.0 - at org.pentaho.di.core.database.Database.openQuery(Database.java:1718) 2016/02/05 14:35:36 - Table input.0 - ... 4 more Please help Thanks, Mark Rep