Skip site navigation (1) Skip section navigation (2)

I have a problem of abstraction...

From: Alfredo Rico <alfredorico(at)gmail(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: I have a problem of abstraction...
Date: 2005-10-06 13:27:28
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-jdbc
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

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 )
if(i == 1) //only for the first column; , X );

if( i == this.columnNumber )//if all columns (for one row) were updated;

}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.


pgsql-jdbc by date

Next:From: Dave CramerDate: 2005-10-06 14:04:58
Subject: Re: I have a problem of abstraction...
Previous:From: Peter CookDate: 2005-10-06 05:06:06
Subject: Getting connected

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group