pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
bug in jdbc
9+ messages / 6 participants
[nested] [flat]

* bug in jdbc
@ 2002-05-23 12:56  Marek  Koniew <asf@junisoftex.pl>
  0 siblings, 2 replies; 9+ messages in thread

From: Marek Koniew @ 2002-05-23 12:56 UTC (permalink / raw)
  To: pgsql-jdbc

i got the buggy driver from http://jdbc.postgresql.org/download/pgjdbc2.jar
jdbc7.0-1.2 driver working OK

there is exception :

 Something unusual has occured to cause the driver to fail. Please report this exception: Exception: java.sql.SQLException: ERROR:  No such function 'pg_encoding_to_char' with the specified attributes

Stack Trace:

java.sql.SQLException: ERROR:  No such function 'pg_encoding_to_char' with the specified attributes

        at org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:94)
        at org.postgresql.Connection.ExecSQL(Connection.java:398)
        at org.postgresql.Connection.ExecSQL(Connection.java:381)
        at org.postgresql.Connection.openConnection(Connection.java:314)
        at org.postgresql.Driver.connect(Driver.java:149)
        at java.sql.DriverManager.getConnection(DriverManager.java:517)
        at java.sql.DriverManager.getConnection(DriverManager.java:177)
        at board.userbase(board.java)
        at board.doPost(board.java)
        at board.doGet(board.java)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:271)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:311)
        at org.apache.jserv.JServConnection.processRequest(JServConnection.java:317)
        at org.apache.jserv.JServConnection.run(JServConnection.java:188)
        at java.lang.Thread.run(Thread.java:484)
End of Stack Trace

^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: bug in jdbc
@ 2002-05-28 12:08  Nick Fankhauser <nickf@ontko.com>
  parent: Marek  Koniew <asf@junisoftex.pl>
  1 sibling, 0 replies; 9+ messages in thread

From: Nick Fankhauser @ 2002-05-28 12:08 UTC (permalink / raw)
  To: Marek Koniew <asf@junisoftex.pl>; pgsql-jdbc

Marek-

This appears to be a normal message from the driver reporting an error in
the submitted SQL statement. The "Something unusual" part of the message is
a bit misleading, but the rest of the message points pretty clearly to a
problem with the function pg_encoding_to_char. What happens if you try to
execute the same statement via psql?

-Nick


-----Original Message-----
From: pgsql-jdbc-owner@postgresql.org
[mailto:pgsql-jdbc-owner@postgresql.org]On Behalf Of Marek Koniew
Sent: Thursday, May 23, 2002 7:56 AM
To: pgsql-jdbc@postgresql.org
Subject: [JDBC] bug in jdbc


i got the buggy driver from http://jdbc.postgresql.org/download/pgjdbc2.jar
jdbc7.0-1.2 driver working OK

there is exception :

 Something unusual has occured to cause the driver to fail. Please report
this exception: Exception: java.sql.SQLException: ERROR:  No such function
'pg_encoding_to_char' with the specified attributes

Stack Trace:

java.sql.SQLException: ERROR:  No such function 'pg_encoding_to_char' with
the specified attributes

        at org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:94)
        at org.postgresql.Connection.ExecSQL(Connection.java:398)
        at org.postgresql.Connection.ExecSQL(Connection.java:381)
        at org.postgresql.Connection.openConnection(Connection.java:314)
        at org.postgresql.Driver.connect(Driver.java:149)
        at java.sql.DriverManager.getConnection(DriverManager.java:517)
        at java.sql.DriverManager.getConnection(DriverManager.java:177)
        at board.userbase(board.java)
        at board.doPost(board.java)
        at board.doGet(board.java)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:271)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:311)
        at
org.apache.jserv.JServConnection.processRequest(JServConnection.java:317)
        at org.apache.jserv.JServConnection.run(JServConnection.java:188)
        at java.lang.Thread.run(Thread.java:484)
End of Stack Trace




^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: bug in jdbc
@ 2002-05-28 12:11  Dave Cramer <Dave@micro-automation.net>
  parent: Marek  Koniew <asf@junisoftex.pl>
  1 sibling, 1 reply; 9+ messages in thread

From: Dave Cramer @ 2002-05-28 12:11 UTC (permalink / raw)
  To: Marek Koniew <asf@junisoftex.pl>; +Cc: pgsql-jdbc

I think this is a case of using the jdbc 1.1 driver in a 1.2
environment? There are similiar messages in the archive

Dave
On Thu, 2002-05-23 at 08:56, Marek Koniew wrote:
> i got the buggy driver from http://jdbc.postgresql.org/download/pgjdbc2.jar
> jdbc7.0-1.2 driver working OK
> 
> there is exception :
> 
>  Something unusual has occured to cause the driver to fail. Please report this exception: Exception: java.sql.SQLException: ERROR:  No such function 'pg_encoding_to_char' with the specified attributes
> 
> Stack Trace:
> 
> java.sql.SQLException: ERROR:  No such function 'pg_encoding_to_char' with the specified attributes
> 
>         at org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:94)
>         at org.postgresql.Connection.ExecSQL(Connection.java:398)
>         at org.postgresql.Connection.ExecSQL(Connection.java:381)
>         at org.postgresql.Connection.openConnection(Connection.java:314)
>         at org.postgresql.Driver.connect(Driver.java:149)
>         at java.sql.DriverManager.getConnection(DriverManager.java:517)
>         at java.sql.DriverManager.getConnection(DriverManager.java:177)
>         at board.userbase(board.java)
>         at board.doPost(board.java)
>         at board.doGet(board.java)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:271)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:311)
>         at org.apache.jserv.JServConnection.processRequest(JServConnection.java:317)
>         at org.apache.jserv.JServConnection.run(JServConnection.java:188)
>         at java.lang.Thread.run(Thread.java:484)
> End of Stack Trace
> 
> 






^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: bug in jdbc
@ 2002-05-28 12:14  Nick Fankhauser <nickf@ontko.com>
  parent: Dave Cramer <Dave@micro-automation.net>
  0 siblings, 0 replies; 9+ messages in thread

From: Nick Fankhauser @ 2002-05-28 12:14 UTC (permalink / raw)
  To: Dave Cramer <Dave@micro-automation.net>; Marek Koniew <asf@junisoftex.pl>; +Cc: pgsql-jdbc


> I think this is a case of using the jdbc 1.1 driver in a 1.2
> environment? There are similiar messages in the archive

This sounds better than my idea- Try Dave's solution before mine.

-Nick



^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* bug in jdbc
@ 2011-09-03 17:16  luvar@plaintext.sk
  0 siblings, 2 replies; 9+ messages in thread

From: luvar@plaintext.sk @ 2011-09-03 17:16 UTC (permalink / raw)
  To: pgsql-jdbc

Hi, I have executed some update query and I have requested to return generated id...

statement.executeUpdate(query, Statement.RETURN_GENERATED_KEYS);
ResultSet ids  = statement.getGeneratedKeys();
ids.next();
ids.getInt(1);

It will fail with this exception:

19:03:50,300         WARN ObjectBrowser:254 - Bad value for type int : /home/luvar/output.svg
org.postgresql.util.PSQLException: Bad value for type int : /home/luvar/output.svg
	at org.postgresql.jdbc2.AbstractJdbc2ResultSet.toInt(AbstractJdbc2ResultSet.java:2759)
	at org.postgresql.jdbc2.AbstractJdbc2ResultSet.getInt(AbstractJdbc2ResultSet.java:2003)
.....


I am using maven. Used jdbc version:

	<dependency>
	    <groupId>postgresql</groupId>
	    <artifactId>postgresql</artifactId>
	    <version>9.0-801.jdbc4</version>
	</dependency>

I have table constructed in such way, that id (bigserial typed) column is NOT first column. It is second and first column of my table is "url" column to which I try insert "/home/luvar/output.svg" value.

Can you have a look and confirm this bug to me, or there is no bug and something I am doing bad?



^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: bug in jdbc
@ 2011-09-04 16:31  dmp <danap@ttc-cmc.net>
  parent: luvar@plaintext.sk
  1 sibling, 1 reply; 9+ messages in thread

From: dmp @ 2011-09-04 16:31 UTC (permalink / raw)
  To: luvar@plaintext.sk; pgsql-jdbc

luvar@plaintext.sk wrote:
> Hi, I have executed some update query and I have requested to return generated id...
>
> statement.executeUpdate(query, Statement.RETURN_GENERATED_KEYS);
> ResultSet ids  = statement.getGeneratedKeys();
> ids.next();
> ids.getInt(1);
>
> It will fail with this exception:
>
> 19:03:50,300         WARN ObjectBrowser:254 - Bad value for type int : /home/luvar/output.svg
> org.postgresql.util.PSQLException: Bad value for type int : /home/luvar/output.svg
> 	at org.postgresql.jdbc2.AbstractJdbc2ResultSet.toInt(AbstractJdbc2ResultSet.java:2759)
> 	at org.postgresql.jdbc2.AbstractJdbc2ResultSet.getInt(AbstractJdbc2ResultSet.java:2003)
> .....
>
>
> I am using maven. Used jdbc version:
>
> 	<dependency>
> 	<groupId>postgresql</groupId>
> 	<artifactId>postgresql</artifactId>
> 	<version>9.0-801.jdbc4</version>
> 	</dependency>
>
> I have table constructed in such way, that id (bigserial typed) column is NOT first column. It is second and first column of my table is "url" column to which I try insert "/home/luvar/output.svg" value.
>
> Can you have a look and confirm this bug to me, or there is no bug and something I am doing bad?
>

I have confirmed the behavior you have indicated in a test case that
is not using Maven, but rather the JDBC directly.

Though I have not reviewed the behavior of statement.executeUpdate(query,
Statement.RETURN_GENERATED_KEYS) thoroughly I suggest you try the
modifications that I made to your example code that helped me to understand
more fully what is happening. I can not address if this is a bug or not.

sqlStatement.executeUpdate(sqlStatementString, Statement.RETURN_GENERATED_KEYS);
resultSet = sqlStatement.getGeneratedKeys();
tableMetaData = resultSet.getMetaData();
while (resultSet.next())
{
    for (int i = 1; i < tableMetaData.getColumnCount() + 1; i++)
    {
       System.out.println(i + " " + tableMetaData.getColumnName(i));
       System.out.println(resultSet.getString(colNameString));
    }
}

Output:
Connection Created
INSERT INTO "public"."key_table21" ("text","id") VALUES ('aaa',33)
1 text
aaa
2 id
33
Connection Closed

danap.



^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: bug in jdbc
@ 2011-09-04 16:41  dmp <danap@ttc-cmc.net>
  parent: dmp <danap@ttc-cmc.net>
  0 siblings, 0 replies; 9+ messages in thread

From: dmp @ 2011-09-04 16:41 UTC (permalink / raw)
  To: luvar@plaintext.sk; pgsql-jdbc

dmp wrote:
> luvar@plaintext.sk wrote:
>> Hi, I have executed some update query and I have requested to return
>> generated id...
>>
>> statement.executeUpdate(query, Statement.RETURN_GENERATED_KEYS);
>> ResultSet ids = statement.getGeneratedKeys();
>> ids.next();
>> ids.getInt(1);
>>
>> It will fail with this exception:
>>
>> 19:03:50,300 WARN ObjectBrowser:254 - Bad value for type int :
>> /home/luvar/output.svg
>> org.postgresql.util.PSQLException: Bad value for type int :
>> /home/luvar/output.svg
>> at
>> org.postgresql.jdbc2.AbstractJdbc2ResultSet.toInt(AbstractJdbc2ResultSet.java:2759)
>>
>> at
>> org.postgresql.jdbc2.AbstractJdbc2ResultSet.getInt(AbstractJdbc2ResultSet.java:2003)
>>
>> .....
>>
>>
>> I am using maven. Used jdbc version:
>>
>> <dependency>
>> <groupId>postgresql</groupId>
>> <artifactId>postgresql</artifactId>
>> <version>9.0-801.jdbc4</version>
>> </dependency>
>>
>> I have table constructed in such way, that id (bigserial typed) column
>> is NOT first column. It is second and first column of my table is
>> "url" column to which I try insert "/home/luvar/output.svg" value.
>>
>> Can you have a look and confirm this bug to me, or there is no bug and
>> something I am doing bad?
>>
>
> I have confirmed the behavior you have indicated in a test case that
> is not using Maven, but rather the JDBC directly.
>
> Though I have not reviewed the behavior of statement.executeUpdate(query,
> Statement.RETURN_GENERATED_KEYS) thoroughly I suggest you try the
> modifications that I made to your example code that helped me to understand
> more fully what is happening. I can not address if this is a bug or not.
>
> sqlStatement.executeUpdate(sqlStatementString,
> Statement.RETURN_GENERATED_KEYS);
> resultSet = sqlStatement.getGeneratedKeys();
> tableMetaData = resultSet.getMetaData();
> while (resultSet.next())
> {
> for (int i = 1; i < tableMetaData.getColumnCount() + 1; i++)
> {
> System.out.println(i + " " + tableMetaData.getColumnName(i));
> System.out.println(resultSet.getString(colNameString));
> }
> }
>
> Output:
> Connection Created
> INSERT INTO "public"."key_table21" ("text","id") VALUES ('aaa',33)
> 1 text
> aaa
> 2 id
> 33
> Connection Closed
>
> danap.
>
Sorry I made a simplification of the example code in the email that
obscured it.

while (resultSet.next())
{
    for (int i = 1; i < tableMetaData.getColumnCount() + 1; i++)
    {
       String colNameString = tableMetaData.getColumnName(i);
       System.out.println(i + " " + colNameString);
       System.out.println(resultSet.getString(colNameString));
    }
}

danap.



^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: bug in jdbc
@ 2011-09-04 21:25  Oliver Jowett <oliver@opencloud.com>
  parent: luvar@plaintext.sk
  1 sibling, 0 replies; 9+ messages in thread

From: Oliver Jowett @ 2011-09-04 21:25 UTC (permalink / raw)
  To: luvar@plaintext.sk; +Cc: pgsql-jdbc

On 4 September 2011 05:16,  <luvar@plaintext.sk> wrote:
> Hi, I have executed some update query and I have requested to return generated id...
>
> statement.executeUpdate(query, Statement.RETURN_GENERATED_KEYS);
> ResultSet ids  = statement.getGeneratedKeys();
> ids.next();
> ids.getInt(1);
>
> It will fail with this exception:
>
> 19:03:50,300         WARN ObjectBrowser:254 - Bad value for type int : /home/luvar/output.svg
> org.postgresql.util.PSQLException: Bad value for type int : /home/luvar/output.svg
>        at org.postgresql.jdbc2.AbstractJdbc2ResultSet.toInt(AbstractJdbc2ResultSet.java:2759)
>        at org.postgresql.jdbc2.AbstractJdbc2ResultSet.getInt(AbstractJdbc2ResultSet.java:2003)

Javadoc for getGeneratedKeys says:

Note:If the columns which represent the auto-generated keys were not
specified, the JDBC driver implementation will determine the columns
which best represent the auto-generated keys.

So you shouldn't expect a particular set of returned columns unless
you explicitly specify which columns to return. (In this particular
case the driver is playing it safe and returning *all* columns as it
doesn't know which ones could be affected by triggers etc)
You could look up the column you want by name rather than by index, or
use the overloaded variant of executeUpdate() that takes a list of
column names.

Oliver



^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: bug in jdbc
@ 2011-09-05 00:07  luvar@plaintext.sk
  0 siblings, 0 replies; 9+ messages in thread

From: luvar@plaintext.sk @ 2011-09-05 00:07 UTC (permalink / raw)
  To: Oliver Jowett <oliver@opencloud.com>; +Cc: pgsql-jdbc

----- "Oliver Jowett" <oliver@opencloud.com> wrote:

> On 4 September 2011 05:16,  <luvar@plaintext.sk> wrote:
> > Hi, I have executed some update query and I have requested to return
> generated id...
> >
> > statement.executeUpdate(query, Statement.RETURN_GENERATED_KEYS);
> > ResultSet ids  = statement.getGeneratedKeys();
> > ids.next();
> > ids.getInt(1);
> >
> > It will fail with this exception:
> >
> > 19:03:50,300         WARN ObjectBrowser:254 - Bad value for type int
> : /home/luvar/output.svg
> > org.postgresql.util.PSQLException: Bad value for type int :
> /home/luvar/output.svg
> >        at
> org.postgresql.jdbc2.AbstractJdbc2ResultSet.toInt(AbstractJdbc2ResultSet.java:2759)
> >        at
> org.postgresql.jdbc2.AbstractJdbc2ResultSet.getInt(AbstractJdbc2ResultSet.java:2003)
> 
> Javadoc for getGeneratedKeys says:
> 
> Note:If the columns which represent the auto-generated keys were not
> specified, the JDBC driver implementation will determine the columns
> which best represent the auto-generated keys.
> 
> So you shouldn't expect a particular set of returned columns unless
> you explicitly specify which columns to return. (In this particular
> case the driver is playing it safe and returning *all* columns as it
> doesn't know which ones could be affected by triggers etc)
> You could look up the column you want by name rather than by index,
> or
> use the overloaded variant of executeUpdate() that takes a list of
> column names.

Many thanks for clarification. So this behavior is in line with specification.

To be accurate, I should call something like:
statement.executeUpdate(query, new String[] {"id"});
instead of:
statement.executeUpdate(query, Statement.RETURN_GENERATED_KEYS);
to get only autogenerated (in my case "id") column. Please correct me, If I am wrong.

> 
> Oliver



^ permalink  raw  reply  [nested|flat] 9+ messages in thread


end of thread, other threads:[~2011-09-05 00:07 UTC | newest]

Thread overview: 9+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-05-23 12:56 bug in jdbc Marek  Koniew <asf@junisoftex.pl>
2002-05-28 12:08 ` Nick Fankhauser <nickf@ontko.com>
2002-05-28 12:11 ` Dave Cramer <Dave@micro-automation.net>
2002-05-28 12:14   ` Nick Fankhauser <nickf@ontko.com>
2011-09-03 17:16 bug in jdbc luvar@plaintext.sk
2011-09-04 16:31 ` dmp <danap@ttc-cmc.net>
2011-09-04 16:41   ` dmp <danap@ttc-cmc.net>
2011-09-04 21:25 ` Oliver Jowett <oliver@opencloud.com>
2011-09-05 00:07 Re: bug in jdbc luvar@plaintext.sk

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox