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 9443CD8833 for ; Thu, 6 Oct 2005 11:49:50 -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 82052-01 for ; Thu, 6 Oct 2005 14:49:46 +0000 (GMT) Received: from xproxy.gmail.com (xproxy.gmail.com [66.249.82.192]) by svr1.postgresql.org (Postfix) with ESMTP id 4E2D8DA415 for ; Thu, 6 Oct 2005 11:49:46 -0300 (ADT) Received: by xproxy.gmail.com with SMTP id i26so258044wxd for ; Thu, 06 Oct 2005 07:49:51 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:references; b=M2wQfuKI4EtSOrHNAGvV9wtPYaxYK1kHPGdOT82WEzj961Nm/MQZTkxAsXKPH8LBgu+GicfRx3HzY758J/J4styvzTp8iT57ZhxjwNr3+ELkJIUOYj5uqGKnBnJjvPxhkDRO2q+eNuxM4ZKwAHrqjbN9g1/ecJHIpmgotbiru10= Received: by 10.70.12.19 with SMTP id 19mr1369211wxl; Thu, 06 Oct 2005 07:49:51 -0700 (PDT) Received: by 10.70.41.14 with HTTP; Thu, 6 Oct 2005 07:49:51 -0700 (PDT) Message-ID: <89cc056d0510060749g305e1bdcvab7d940b50033be2@mail.gmail.com> Date: Thu, 6 Oct 2005 10:49:51 -0400 From: Alfredo Rico Reply-To: Alfredo Rico To: Dave Cramer Subject: Re: I have a problem of abstraction... Cc: pgsql-jdbc@postgresql.org In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_32787_18022843.1128610191635" References: <89cc056d0510060627o2b710dd4jc435c20dd1dd574f@mail.gmail.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.48 required=5 tests=[AWL=0.399, HTML_30_40=0.056, HTML_MESSAGE=0.001, RCVD_BY_IP=0.024] X-Spam-Level: X-Archive-Number: 200510/27 X-Sequence-Number: 13958 ------=_Part_32787_18022843.1128610191635 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline 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=3D1 ; i<=3D 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 =3D=3D 1) //only for the first column > > this.rs.moveToInsertRow(); > > > > this.rs.updateObject(columnName , X ); > > > > if( i =3D=3D 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. > > ------=_Part_32787_18022843.1128610191635 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline 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 cone= ction.
Besides I'm using a ResultSet to update my database and so the conection al= ready were established.


Kind Regards.-
Alfredo Rico.


On 10/6/05, Dave Cramer <pg@fastcrypt.co= m> 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 wro= te:

> Hi friends, greetings.
> Please apologize by my bad e= nglish ;-(
>
> I need to resolve a problem of data type abstrac= tion using JDBC.
>
> In first place, please check out the following java code f= ragment:
> /********************************/
> //for each row = that I want to insert
> for(int i=3D1 ; i<=3D 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 fo= r a given
> table.
> columnValues is a String vector containing the valu= es for each
> column for the same table.
> Ok, this string vect= or 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 HttpServletRe= quest 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{
>   &nb= sp;     if(i =3D=3D 1) //only for the first column
&= gt;            = this.rs.moveToInsertRow();
>
>     &nb= sp;    this.rs.updateObject(columnName , X );
>>          if( i =3D= =3D=20 this.columnNumber )//if all columns (for one row)
> were updated
&= gt;            = this.rs.insertRow();
>
>      &n= bsp;  }catch(SQLException e )
>     &nb= sp;    {
>      &nb= sp;       System.out.println("Error= : "+e);
>          }
&g= t; }
>
>
> Ok, if I'm using JDBC driver version 7.4 Build= 216 there isn't
> problem with the data types.
> The method Re= sultSet.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
> r= easons, and the java code above not works
> because this version of J= DBC driver is very strict about data types.
>
> I really need insert my data in an abstract way, I mean wi= thout
> 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.
> A= lfredo Rico.


------=_Part_32787_18022843.1128610191635--