Thread: Problem with creating language by JDBC
Hi there, I was trying to create language by execute() or executeUpdate(). But the call always fails with message as problem running SQL query: CREATE TRUSTED PROCEDURAL LANGUAGE 'plpgsql' HANDLER plpgsql_call_handler .An I/O error occured while sending to the backend. Following is a snippet of the Java code I have, which works with creating database, executing other queries: PreparedStatement stmt = null; ResultSet rs = null; try { stmt = con.prepareStatement(str); System.out.println("Running SQL query: " + str + ".."); try { //stmt.executeUpdate(); stmt.execute(); } catch (SQLException sqle) { StringBuffer errMsg = new StringBuffer( " problem running SQL query: " + str + "."); errMsg.append(sqle.getMessage()); System.err.println(errMsg.toString()); ret = false; } con.commit(); System.out.println("Query is done."); } finally { I'm using postgresql-8.2dev-501.jdbc3.jar and querying against an 8.3.4 server. If I run the query manually on psql command with same authentication, it will return successfully. I tried with a later JDBC driver, it has the same problem. Regards, M. --------------------------------------------------------------------- This transmission (including any attachments) may contain confidential information, privileged material (including materialprotected by the solicitor-client or other applicable privileges), or constitute non-public information. Any useof this information by anyone other than the intended recipient is prohibited. If you have received this transmissionin error, please immediately reply to the sender and delete this information from your system. Use, dissemination,distribution, or reproduction of this transmission by unintended recipients is not authorized and may be unlawful.
Ming Deng wrote on 24.06.2010 19:44: > Hi there, > > I was trying to create language by execute() or executeUpdate(). But the > call always fails with message as > > problem running SQL query: CREATE TRUSTED PROCEDURAL LANGUAGE 'plpgsql' > HANDLER plpgsql_call_handler > .An I/O error occured while sending to the backend. > > Following is a snippet of the Java code I have, which works with > creating database, executing other queries: > Did you try to use a regular statement, instead of a PreparedStatement? Statement stmt = con.createStatement() stmt.executeUpdate("CREATE TRUSTED PROCEDURAL LANGUAGE 'plpgsql' HANDLER plpgsql_call_handler"); Thomas
On Jun 24, 5:38 pm, spam_eater@gmx.net (Thomas Kellerer) wrote: > Ming Deng wrote on 24.06.2010 19:44: > > > Hi there, > > > I was trying to create language by execute() or executeUpdate(). But the > > call always fails with message as > > > problem running SQL query: CREATE TRUSTED PROCEDURAL LANGUAGE 'plpgsql' > > HANDLER plpgsql_call_handler > > .An I/O error occured while sending to the backend. > > > Following is a snippet of the Java code I have, which works with > > creating database, executing other queries: > > Did you try to use a regular statement, instead of a PreparedStatement? > > Statement stmt = con.createStatement() > stmt.executeUpdate("CREATE TRUSTED PROCEDURAL LANGUAGE 'plpgsql' HANDLER plpgsql_call_handler"); > > Thomas > > -- > Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) > To make changes to your subscription:http://www.postgresql.org/mailpref/pgsql-jdbc I just tried with the regular statement, got the same failure.
MD, 25.06.2010 05:10: >>> I was trying to create language by execute() or executeUpdate(). But the >>> call always fails with message as >> >>> problem running SQL query: CREATE TRUSTED PROCEDURAL LANGUAGE 'plpgsql' >>> HANDLER plpgsql_call_handler >>> .An I/O error occured while sending to the backend. >> >>> Following is a snippet of the Java code I have, which works with >>> creating database, executing other queries: >> >> Did you try to use a regular statement, instead of a PreparedStatement? >> > > I just tried with the regular statement, got the same failure. That's strange, the following works fine for me: Class.forName("org.postgresql.Driver"); con = DriverManager.getConnection("jdbc:postgresql://localhost/postgres", "postgres", "postgres"); stmt = con.createStatement(); stmt.executeUpdate("CREATE TRUSTED PROCEDURAL LANGUAGE 'plpgsql' HANDLER plpgsql_call_handler"); I think it is not related to the way you run this from Java, but something else, and the "I/O error" seems to indicate that. Regards Thomas
On Jun 25, 2:40 am, spam_ea...@gmx.net (Thomas Kellerer) wrote: > MD, 25.06.2010 05:10: > > >>> I was trying to create language by execute() or executeUpdate(). But the > >>> call always fails with message as > > >>> problem running SQL query: CREATE TRUSTED PROCEDURAL LANGUAGE 'plpgsql' > >>> HANDLER plpgsql_call_handler > >>> .An I/O error occured while sending to the backend. > > >>> Following is a snippet of the Java code I have, which works with > >>> creating database, executing other queries: > > >> Did you try to use a regular statement, instead of a PreparedStatement? > > > I just tried with the regular statement, got the same failure. > > That's strange, the following works fine for me: > > Class.forName("org.postgresql.Driver"); > con = DriverManager.getConnection("jdbc:postgresql://localhost/postgres", "postgres", "postgres"); > stmt = con.createStatement(); > stmt.executeUpdate("CREATE TRUSTED PROCEDURAL LANGUAGE 'plpgsql' HANDLER plpgsql_call_handler"); > > I think it is not related to the way you run this from Java, but something else, and the "I/O error" seems to indicatethat. > > Regards > Thomas Hi Thomas, Thanks for your investigation. What are the version of Postgres and JDBC you are using?
>> Class.forName("org.postgresql.Driver"); >> con = DriverManager.getConnection("jdbc:postgresql://localhost/postgres", "postgres", "postgres"); >> stmt = con.createStatement(); >> stmt.executeUpdate("CREATE TRUSTED PROCEDURAL LANGUAGE 'plpgsql' HANDLER plpgsql_call_handler"); >> >> I think it is not related to the way you run this from Java, but something else, and the "I/O error" seems to indicatethat. >> >> Regards >> Thomas > > Hi Thomas, > > Thanks for your investigation. What are the version of Postgres and > JDBC you are using? > Postgres: 8.4.2 JDBC Driver: 8.4 JDBC4 (build 701) Regards Thomas
On Jun 25, 11:14 am, spam_ea...@gmx.net (Thomas Kellerer) wrote: > >> Class.forName("org.postgresql.Driver"); > >> con = DriverManager.getConnection("jdbc:postgresql://localhost/postgres", "postgres", "postgres"); > >> stmt = con.createStatement(); > >> stmt.executeUpdate("CREATE TRUSTED PROCEDURAL LANGUAGE 'plpgsql' HANDLER plpgsql_call_handler"); > > >> I think it is not related to the way you run this from Java, but something else, and the "I/O error" seems to indicatethat. > > >> Regards > >> Thomas > > > Hi Thomas, > > > Thanks for your investigation. What are the version of Postgres and > > JDBC you are using? > > Postgres: 8.4.2 > JDBC Driver: 8.4 JDBC4 (build 701) > > Regards > Thomas > Thanks very much for your info. With the help of that, I narrowed down the problem. It was caused by a bug in a related piece of code.
Thomas Kellerer wrote: > Did you try to use a regular statement, instead of a PreparedStatement? That would not change anything. -- Lew