pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Dave Cramer <pg@fastcrypt.com>
To: ALBERDI Ion <alberdi@enseirb.fr>
Cc: pgsql-jdbc@postgresql.org <pgsql-jdbc@postgresql.org>
Subject: Re: ConnectionPooling executeUpdate
Date: Wed, 23 Jun 2004 10:39:13 -0400
Message-ID: <1088001552.2324.76.camel@localhost.localdomain> (raw)
In-Reply-To: <20040623161221.A8925@enseirb.fr>
References: <20040623161221.A8925@enseirb.fr>

Hi,


couple of things.

I strongly suggest you use dbcp http://jakarta.apache.org/commons/dbcp/
as your connection pool as it is very good.

In general you should look at the server logs to figure out what the
driver did or didn't do.

I'm curious why you go to such great lengths to make up the query?
why not 
psmt = con.prepareStatement("update service table set servicedeskdocid =
?, servicehelpdocid = ? .... );

Dave
On Wed, 2004-06-23 at 10:12, ALBERDI Ion wrote:
> 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 :)  			
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
>       subscribe-nomail command to majordomo@postgresql.org so that your
>       message can get through to the mailing list cleanly
> 
> 
> 
> !DSPAM:40d993a8230582142038005!
> 
> 
-- 
Dave Cramer
519 939 0336
ICQ # 14675561




view thread (2+ messages)

Message-ID: <1088001552.2324.76.camel@localhost.localdomain>
Permalink:  ../1088001552.2324.76.camel@localhost.localdomain/
Also on:    postgresql.org/message-id/1088001552.2324.76.camel@localhost.localdomain

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: pg@fastcrypt.com, alberdi@enseirb.fr
  Subject: Re: ConnectionPooling executeUpdate
  In-Reply-To: <1088001552.2324.76.camel@localhost.localdomain>
  References: <20040623161221.A8925@enseirb.fr> <1088001552.2324.76.camel@localhost.localdomain>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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