Thread: "No results" exception on insert
Hello, I have some code which is essentially doing the following: Statement stmt; ResultSet rs = stmt.executeQuery("insert into users values ( 'joe', 'blow' )"); The values are inserted into the table correctly. I verified this using psql: "select * from users". The problem is that the executeQuery throws an Exception. The message is "No results were returned by the query": No results were returned by the query. at org.postgresql.jdbc2.Statement.executeQuery(Statement.java, Compiled Code) My driver is "org.postgresql.Driver" from the jar file jdbc7.0-1.2.jar. I think the port version is 7.1 The platform is FreeBSD 4.2-RELEASE. I am using linux jdk 1.2.2. Can anyone give me any ideas? Thanks, Brian
>Statement stmt; >ResultSet rs = stmt.executeQuery("insert into users values ( 'joe', 'blow' >)"); > >The problem is that the executeQuery throws an Exception. The message >is "No results were returned by the query": Try executeUpdate() for insert, create and delete. Mike
Brian_Williams@i2.com wrote: > Hello, > > I have some code which is essentially doing the following: > > Statement stmt; > ResultSet rs = stmt.executeQuery("insert into users values ( 'joe', 'blow' > )"); > > The values are inserted into the table correctly. I verified this using > psql: > "select * from users". > > The problem is that the executeQuery throws an Exception. The message > is "No results were returned by the query": > > No results were returned by the query. > at org.postgresql.jdbc2.Statement.executeQuery(Statement.java, > Compiled > Code) Hi, When you're using INSERT, UPDATE, or DELETE, you should use the executeUpdate() method of JDBC. executeQuery expects results because it assumes a query is being sent. :) HTH, Jeremy
Hello. I just update my driver to the latest version (7.1-1.3). I am seeing MANY of the following exception: No results were returned by the query. at org.postgresql.jdbc2.Statement.executeQuery(Statement.java:63) at com.commnav.sbh.framework.persist.JDBCEngine.executeQuery(JDBCEngine.java:22 1) at com.commnav.sbh.framework.persist.PersistenceObject.query(PersistenceObject. java:1046) ... I checked the history of this listserv and found some related but not quite relevant stuff (part of the thread is below - it talks about using executeUpdate for update/insert/delete)... I am sometimes getting this exception even when there should be results returned... I appreciate any help. chris -----Original Message----- From: pgsql-jdbc-owner@postgresql.org [mailto:pgsql-jdbc-owner@postgresql.org]On Behalf Of Brian_Williams@i2.com Sent: Tuesday, May 08, 2001 2:50 PM To: pgsql-jdbc@postgresql.org Subject: [JDBC] "No results" exception on insert Hello, I have some code which is essentially doing the following: Statement stmt; ResultSet rs = stmt.executeQuery("insert into users values ( 'joe', 'blow' )"); The values are inserted into the table correctly. I verified this using psql: "select * from users". The problem is that the executeQuery throws an Exception. The message is "No results were returned by the query": No results were returned by the query. at org.postgresql.jdbc2.Statement.executeQuery(Statement.java, Compiled Code) My driver is "org.postgresql.Driver" from the jar file jdbc7.0-1.2.jar. I think the port version is 7.1 The platform is FreeBSD 4.2-RELEASE. I am using linux jdk 1.2.2. Can anyone give me any ideas? Thanks, Brian ---------------------------(end of broadcast)--------------------------- TIP 4: Don't 'kill -9' the postmaster
Chris, executeQuery will not return a resultset from an insert query. If you use execute instead it will work ok Dave -----Original Message----- From: pgsql-jdbc-owner@postgresql.org [mailto:pgsql-jdbc-owner@postgresql.org] On Behalf Of chris markiewicz Sent: August 16, 2001 12:47 PM To: pgsql-jdbc@postgresql.org Subject: [JDBC] "No results" exception on executeQuery() Hello. I just update my driver to the latest version (7.1-1.3). I am seeing MANY of the following exception: No results were returned by the query. at org.postgresql.jdbc2.Statement.executeQuery(Statement.java:63) at com.commnav.sbh.framework.persist.JDBCEngine.executeQuery(JDBCEngine.jav a:22 1) at com.commnav.sbh.framework.persist.PersistenceObject.query(PersistenceObj ect. java:1046) ... I checked the history of this listserv and found some related but not quite relevant stuff (part of the thread is below - it talks about using executeUpdate for update/insert/delete)... I am sometimes getting this exception even when there should be results returned... I appreciate any help. chris -----Original Message----- From: pgsql-jdbc-owner@postgresql.org [mailto:pgsql-jdbc-owner@postgresql.org]On Behalf Of Brian_Williams@i2.com Sent: Tuesday, May 08, 2001 2:50 PM To: pgsql-jdbc@postgresql.org Subject: [JDBC] "No results" exception on insert Hello, I have some code which is essentially doing the following: Statement stmt; ResultSet rs = stmt.executeQuery("insert into users values ( 'joe', 'blow' )"); The values are inserted into the table correctly. I verified this using psql: "select * from users". The problem is that the executeQuery throws an Exception. The message is "No results were returned by the query": No results were returned by the query. at org.postgresql.jdbc2.Statement.executeQuery(Statement.java, Compiled Code) My driver is "org.postgresql.Driver" from the jar file jdbc7.0-1.2.jar. I think the port version is 7.1 The platform is FreeBSD 4.2-RELEASE. I am using linux jdk 1.2.2. Can anyone give me any ideas? Thanks, Brian ---------------------------(end of broadcast)--------------------------- TIP 4: Don't 'kill -9' the postmaster ---------------------------(end of broadcast)--------------------------- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/users-lounge/docs/faq.html
ERROR: SET TRANSACTION ISOLATION LEVEL must be called before any query
From
"chris markiewicz"
Date:
In addition to the error that I mentioned in my earlier post ("No results" exception on executeQuery() - see below), I get the following when I try to commit a connection: java.sql.SQLException: ERROR: SET TRANSACTION ISOLATION LEVEL must be called before any query at org.postgresql.Connection.ExecSQL(Connection.java:548) at org.postgresql.Connection.ExecSQL(Connection.java:415) at org.postgresql.jdbc2.Connection.doIsolationLevel(Connection.java:412) at org.postgresql.jdbc2.Connection.commit(Connection.java:226) at com.commnav.sbh.framework.persist.JDBCConnection.commit(JDBCConnection.java: 312) at com.commnav.sbh.framework.persist.ConnectionManager.commitConnections(Connec tionManager.java:366) at com.commnav.sbh.framework.persist.ConnectionManager.removeConnectionManager( ConnectionManager.java:204) at com.commnav.sbh.objects.User.finalize(User.java:162) at java.lang.ref.Finalizer.invokeFinalizeMethod(Native Method) at java.lang.ref.Finalizer.runFinalizer(Finalizer.java:86) at java.lang.ref.Finalizer.access$100(Finalizer.java:17) at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:163) -----Original Message----- From: pgsql-jdbc-owner@postgresql.org [mailto:pgsql-jdbc-owner@postgresql.org]On Behalf Of chris markiewicz Sent: Thursday, August 16, 2001 12:47 PM To: pgsql-jdbc@postgresql.org Subject: [JDBC] "No results" exception on executeQuery() Hello. I just update my driver to the latest version (7.1-1.3). I am seeing MANY of the following exception: No results were returned by the query. at org.postgresql.jdbc2.Statement.executeQuery(Statement.java:63) at com.commnav.sbh.framework.persist.JDBCEngine.executeQuery(JDBCEngine.java:22 1) at com.commnav.sbh.framework.persist.PersistenceObject.query(PersistenceObject. java:1046) ... I checked the history of this listserv and found some related but not quite relevant stuff (part of the thread is below - it talks about using executeUpdate for update/insert/delete)... I am sometimes getting this exception even when there should be results returned... I appreciate any help. chris -----Original Message----- From: pgsql-jdbc-owner@postgresql.org [mailto:pgsql-jdbc-owner@postgresql.org]On Behalf Of Brian_Williams@i2.com Sent: Tuesday, May 08, 2001 2:50 PM To: pgsql-jdbc@postgresql.org Subject: [JDBC] "No results" exception on insert Hello, I have some code which is essentially doing the following: Statement stmt; ResultSet rs = stmt.executeQuery("insert into users values ( 'joe', 'blow' )"); The values are inserted into the table correctly. I verified this using psql: "select * from users". The problem is that the executeQuery throws an Exception. The message is "No results were returned by the query": No results were returned by the query. at org.postgresql.jdbc2.Statement.executeQuery(Statement.java, Compiled Code) My driver is "org.postgresql.Driver" from the jar file jdbc7.0-1.2.jar. I think the port version is 7.1 The platform is FreeBSD 4.2-RELEASE. I am using linux jdk 1.2.2. Can anyone give me any ideas? Thanks, Brian ---------------------------(end of broadcast)--------------------------- TIP 4: Don't 'kill -9' the postmaster ---------------------------(end of broadcast)--------------------------- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/users-lounge/docs/faq.html
On Thu, 16 Aug 2001 12:47:10 -0400, you wrote: >I am seeing MANY of the following exception: You'd better tell us something about the code and the query that's throwing these exceptions. Regards, René Pijlman