pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
PoolingDataSource executeUpdate
4+ messages / 3 participants
[nested] [flat]

* PoolingDataSource executeUpdate
@ 2004-06-23 14:09  ALBERDI Ion <alberdi@enseirb.fr>
  0 siblings, 1 reply; 4+ messages in thread

From: ALBERDI Ion @ 2004-06-23 14:09 UTC (permalink / raw)
  To: pgsl-jdbc@postgresql.org



Hi everybody!
First excuse me for my poor english, I'm not a native english speaker :-).

I have problems with the ConnectionPooling Implementation of the 4.3 postgresql 
jdbc driver: (pg74.214.jdbc3.jar).
I'm using the 4.3-1 postgresql server under windows 2000 with cygwin.
There is my problem:
I am trying to comunicate with this datasource from a web application(the web-
server is websphere 5.1 and we use jsp,servlets...).

First I cannot manage to configure the datasource so that the application takes 
it in account (with WSAD5.1 I configure a new datasource implemented by 
org.postgresql.jdbc3.Jdbc3PoolingDataSource and with the serverName 
dataBaseName,user,maxConnections and password properties set), I launch the 
server and during the execution I get an exception which says something like  
Driver cast exception this driver cannot be used as one phase.

So I tried another thing, instead of configuring the datasource with the 
websephere interface I configure it with javacode (I know that I may not do 
that because the code results to be less portable). So there is my code:

Jdbc3PoolingDataSource pgSource = new Jdbc3PoolingDataSource();
		pgSource.setServerName("localhost");
		pgSource.setDatabaseName(dbName);
		pgSource.setUser(userName);
		pgSource.setPassword(password);
		pgSource.setMaxConnections(numberOfMaxConnections);
		ds = (javax.sql.DataSource)pgSource;
		
and to obtain a connection I do:

Connection con = ds.getConnection.

I launch the server and test it. All the select queries work well, but when I 
try to do the first update of the database:

query = new StringBuffer();
query.append("UPDATE ");
query.append(ServiceTable);
query.append(" SET ");
query.append(ServiceDescDocId);
query.append(" = ?, ");
query.append(ServiceHelpDocId);
query.append(" = ? WHERE ");
query.append(ServiceId);
query.append(" = ?");		
// Execute the query:
psmt = con.prepareStatement(query.toString());
psmt.setString(1, ddId);
psmt.setString(2, hdId);	
psmt.setString(3, svcId);
numUpdates = psmt.executeUpdate();

What happens there is that with Connection Pooling the executeUpdate method 
always returns 0, and that the database is not upgraded.
I'm currently forced to use the Jdbc3SimpleDataSource class (with this class 
the application runs perfectly) but I would like to use Connection Pools to 
improve the application's performances.

Thanks for having read my mail until the end :)  			





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

* Re: PoolingDataSource executeUpdate
@ 2004-06-24 02:38  Oliver Jowett <oliver@opencloud.com>
  parent: ALBERDI Ion <alberdi@enseirb.fr>
  0 siblings, 1 reply; 4+ messages in thread

From: Oliver Jowett @ 2004-06-24 02:38 UTC (permalink / raw)
  To: ALBERDI Ion <alberdi@enseirb.fr>; +Cc: pgsql-jdbc

ALBERDI Ion wrote:

> What happens there is that with Connection Pooling the executeUpdate method 
> always returns 0, and that the database is not upgraded.
> I'm currently forced to use the Jdbc3SimpleDataSource class (with this class 
> the application runs perfectly) but I would like to use Connection Pools to 
> improve the application's performances.

I notice that the default autocommit setting in 
org.postgresql.jdbc2.optional.ConnectionPool is false. This is the 
opposite of the required Connection default and seems like a bug to me.

If your application is expecting connections obtained from the 
datasource to have autocommit on by default, this could be the problem.

-O



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

* Re: PoolingDataSource executeUpdate
@ 2004-06-24 06:35  Kris Jurka <books@ejurka.com>
  parent: Oliver Jowett <oliver@opencloud.com>
  0 siblings, 1 reply; 4+ messages in thread

From: Kris Jurka @ 2004-06-24 06:35 UTC (permalink / raw)
  To: Oliver Jowett <oliver@opencloud.com>; +Cc: ALBERDI Ion <alberdi@enseirb.fr>; pgsql-jdbc



On Thu, 24 Jun 2004, Oliver Jowett wrote:

> ALBERDI Ion wrote:
> 
> > What happens there is that with Connection Pooling the executeUpdate method 
> > always returns 0, and that the database is not upgraded.
> > I'm currently forced to use the Jdbc3SimpleDataSource class (with this class 
> > the application runs perfectly) but I would like to use Connection Pools to 
> > improve the application's performances.
> 
> I notice that the default autocommit setting in 
> org.postgresql.jdbc2.optional.ConnectionPool is false. This is the 
> opposite of the required Connection default and seems like a bug to me.

True, but that doesn't explain why executeUpdate returns an affected row 
count of zero.

Kris Jurka



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

* Re: PoolingDataSource executeUpdate
@ 2004-06-24 10:21  Oliver Jowett <oliver@opencloud.com>
  parent: Kris Jurka <books@ejurka.com>
  0 siblings, 0 replies; 4+ messages in thread

From: Oliver Jowett @ 2004-06-24 10:21 UTC (permalink / raw)
  To: Kris Jurka <books@ejurka.com>; +Cc: ALBERDI Ion <alberdi@enseirb.fr>; pgsql-jdbc

Kris Jurka wrote:
> 
> On Thu, 24 Jun 2004, Oliver Jowett wrote:
> 
> 
>>ALBERDI Ion wrote:
>>
>>
>>>What happens there is that with Connection Pooling the executeUpdate method 
>>>always returns 0, and that the database is not upgraded.
>>>I'm currently forced to use the Jdbc3SimpleDataSource class (with this class 
>>>the application runs perfectly) but I would like to use Connection Pools to 
>>>improve the application's performances.
>>
>>I notice that the default autocommit setting in 
>>org.postgresql.jdbc2.optional.ConnectionPool is false. This is the 
>>opposite of the required Connection default and seems like a bug to me.
> 
> 
> True, but that doesn't explain why executeUpdate returns an affected row 
> count of zero.

I was thinking along the lines of an insert on a separate connection not 
being committed, or the insert not being visible to the update's 
transaction (which will be a very long transaction if the app is 
expecting autocommit..). i.e. executeUpdate() is fine, it's just that 
the update sees a different set of data to what is expected by the app.

-O



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


end of thread, other threads:[~2004-06-24 10:21 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-06-23 14:09 PoolingDataSource executeUpdate ALBERDI Ion <alberdi@enseirb.fr>
2004-06-24 02:38 ` Oliver Jowett <oliver@opencloud.com>
2004-06-24 06:35   ` Kris Jurka <books@ejurka.com>
2004-06-24 10:21     ` Oliver Jowett <oliver@opencloud.com>

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