pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Dave Cramer <pg@fastcrypt.com>
To: Alfredo Rico <alfredorico@gmail.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: I have a problem of abstraction...
Date: Thu, 6 Oct 2005 10:04:58 -0400
Message-ID: <D7165560-214A-4034-985C-D047AA0544EB@fastcrypt.com> (raw)
In-Reply-To: <89cc056d0510060627o2b710dd4jc435c20dd1dd574f@mail.gmail.com>
References: <89cc056d0510060627o2b710dd4jc435c20dd1dd574f@mail.gmail.com>

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.




view thread (7+ messages)  latest in thread

Message-ID: <D7165560-214A-4034-985C-D047AA0544EB@fastcrypt.com>
Permalink:  ../D7165560-214A-4034-985C-D047AA0544EB@fastcrypt.com/
Also on:    postgresql.org/message-id/D7165560-214A-4034-985C-D047AA0544EB@fastcrypt.com

 · 

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, alfredorico@gmail.com
  Subject: Re: I have a problem of abstraction...
  In-Reply-To: <D7165560-214A-4034-985C-D047AA0544EB@fastcrypt.com>
  References: <89cc056d0510060627o2b710dd4jc435c20dd1dd574f@mail.gmail.com> <D7165560-214A-4034-985C-D047AA0544EB@fastcrypt.com>

* 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