X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 82B8ADA3F0 for ; Thu, 6 Oct 2005 13:48:20 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 18470-05 for ; Thu, 6 Oct 2005 16:48:14 +0000 (GMT) Received: from net2.micro-automation.com (net2.micro-automation.com [64.7.141.29]) by svr1.postgresql.org (Postfix) with SMTP id 927A1DA269 for ; Thu, 6 Oct 2005 13:48:13 -0300 (ADT) Received: (qmail 5802 invoked from network); 6 Oct 2005 16:48:13 -0000 Received: from dcdsl.ebox.com (HELO ?192.168.1.2?) (davec@64.7.143.116) by net2.micro-automation.com with SMTP; 6 Oct 2005 16:48:13 -0000 In-Reply-To: <89cc056d0510060749g305e1bdcvab7d940b50033be2@mail.gmail.com> References: <89cc056d0510060627o2b710dd4jc435c20dd1dd574f@mail.gmail.com> <89cc056d0510060749g305e1bdcvab7d940b50033be2@mail.gmail.com> Mime-Version: 1.0 (Apple Message framework v734) Content-Type: multipart/alternative; boundary=Apple-Mail-31--13767170 Message-Id: <4AFEC163-3990-4199-898B-F2DBAABE8519@fastcrypt.com> Cc: pgsql-jdbc@postgresql.org From: Dave Cramer Subject: Re: I have a problem of abstraction... Date: Thu, 6 Oct 2005 12:48:08 -0400 To: Alfredo Rico X-Mailer: Apple Mail (2.734) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.048 required=5 tests=[AWL=-0.009, HTML_30_40=0.056, HTML_MESSAGE=0.001] X-Spam-Level: X-Archive-Number: 200510/28 X-Sequence-Number: 13959 --Apple-Mail-31--13767170 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Alfredo, No, once you open the connection in v2 it stays in v2. Dave On 6-Oct-05, at 10:49 AM, Alfredo Rico wrote: > Thanks Dave, but could I switch to v2 just when I need it and then > back to v3 afterwards whitout open a new connection ? > I can't use more than one connection per user becaues I'm using a > pool conection. > Besides I'm using a ResultSet to update my database and so the > conection already were established. > > > Kind Regards.- > Alfredo Rico. > > > On 10/6/05, Dave Cramer wrote: > Alfredo, > > The simplest and quickest way is to force v2 protocol > > http://jdbc.postgresql.org/documentation/80/connect.html#connection- > parameters > > Dave > On 6-Oct-05, at 9:27 AM, Alfredo Rico wrote: > > > Hi friends, greetings. > > Please apologize by my bad english ;-( > > > > I need to resolve a problem of data type abstraction using JDBC. > > > > In first place, please check out the following java code fragment: > > /********************************/ > > //for each row that I want to insert > > for(int i=1 ; i<= this.columnNumbers ; i ++) > > { > > this.insertColumn( columnNames[i] , columnValues[i] , i ); > > > > } > > /******************************/ > > In the code above, for each row that I want to insert: > > columnNames is a String vector containing columns names for a given > > table. > > columnValues is a String vector containing the values for each > > column for the same table. > > Ok, this string vector could contain int, float, double, Date, > > character string, I mean basic types, > > represented as string. The reason is due to this vector is > > fulfilled by users parameters > > that has been sent via HttpServletRequest and method > > request.getParameter("parameter") > > return its values as string. > > > > > > Now, please look at the following java method: > > > > //For each row that I want to insert: > > public void insertColumn(String columnName, Object X , int i ) > > { > > try{ > > if(i == 1) //only for the first column > > this.rs.moveToInsertRow(); > > > > this.rs.updateObject(columnName , X ); > > > > if( i == this.columnNumber )//if all columns (for one row) > > were updated > > this.rs.insertRow(); > > > > }catch(SQLException e ) > > { > > System.out.println("Error: "+e); > > } > > } > > > > > > Ok, if I'm using JDBC driver version 7.4 Build 216 there isn't > > problem with the data types. > > The method ResultSet.updateObject works perfectly inserting Int, > > float, double, Date. > > Evrything works very well. > > > > But I need use JDBC driver verion 8.0 Build 312 for another > > reasons, and the java code above not works > > because this version of JDBC driver is very strict about data types. > > > > I really need insert my data in an abstract way, I mean without > > knowing the data types. > > (Application requirements). I would not like to use a bulk of if > > setences for various data types > > according to obtained by using ResultSetMetaData. > > > > How could I overcome this situation ? > > > > Beforehand thank you very much by your help and support. > > > > Kind Regards. > > Alfredo Rico. > > --Apple-Mail-31--13767170 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=ISO-8859-1 Alfredo,

No, once you open the = connection in v2 it stays in v2.

Dave
On = 6-Oct-05, at 10:49 AM, Alfredo Rico wrote:

Thanks = Dave, but could I switch to v2 just when I need it and then back to v3 = afterwards whitout open a new connection ?
I can't use more than one = connection per user becaues I'm using a pool conection.
Besides I'm = using a ResultSet to update my database and so the conection already = were established.


Kind Regards.-
Alfredo Rico.
=

On 10/6/05, Dave Cramer <pg@fastcrypt.com> = wrote:
Alfredo,

The simplest and quickest way is to force v2 = protocol

http://jdbc.postgresql.org/documentation/80/connect.html#connection- =
parameters

Dave
On 6-Oct-05, at 9:27 AM, Alfredo Rico = wrote:

> Hi friends, greetings.
> Please apologize by my = bad english ;-(
>
> I need to resolve a problem of data type = abstraction using JDBC.
>
> In first place, please check = out the following java code fragment:
> = /********************************/
> //for each row that I want to = insert
> for(int i=3D1 ; i<=3D this.columnNumbers ; i ++) =
> {
>=A0=A0=A0=A0this.insertColumn( columnNames[i] , = columnValues[i] , i=A0=A0);
>
> }
> = /******************************/
> In the code above, for each row = that I want to insert:
> columnNames is a String vector containing = columns names for a given
> table.
> columnValues is a = String vector containing the values for each
> column for the same = table.
> Ok, this string vector could contain int, float, double, = Date,
> character string, I mean basic types,
> represented = as string. The reason is due to this vector is
> fulfilled by = users parameters
> that has been sent via HttpServletRequest and = method
> request.getParameter("parameter")
> return its = values as string.
>
>
> Now, please look at the = following java method:
>
> //For each row that I want to = insert:
> public void insertColumn(String columnName, Object X , = int i )
> {
>=A0=A0=A0=A0try{
>=A0=A0=A0=A0=A0=A0=A0=A0= if(i =3D=3D 1) //only for the first = column
>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0this.rs.moveToInsertRow(= );
>
>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0this.rs.updateObject(colum= nName , X );
>
>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0if( i =3D=3D = this.columnNumber )//if all columns (for one row)
> were = updated
>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 = this.rs.insertRow();
>
>=A0=A0=A0=A0=A0=A0=A0=A0 = }catch(SQLException e = )
>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0{
>=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0System.out.println("Error: "+e); =
>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0}
> = }
>
>
> Ok, if I'm using JDBC driver version 7.4 Build = 216 there isn't
> problem with the data types.
> The method = ResultSet.updateObject works perfectly inserting Int,
> float, = double, Date.
> Evrything works very well.
>
> But I = need use JDBC driver verion 8.0 Build 312 for another
> reasons, = and the java code above not works
> because this version of JDBC = driver is very strict about data types.
>
> I really need = insert my data in an abstract way, I mean without
> knowing the = data types.
> (Application requirements). I would not like to use = a bulk of if
> setences for various data types
> according = to obtained by using ResultSetMetaData.
>
> How could I = overcome this situation ?
>
> Beforehand thank you very much = by your help and support.
>
> Kind Regards.
> Alfredo = Rico. =



= --Apple-Mail-31--13767170--