From: Javier Caballero <jcaballero@empretal.com>
To: pgsql-jdbc@postgresql.org
Subject: Driver modified for JDeveloper+ADF communication
Date: Tue, 19 Jun 2007 13:05:31 +0200
Message-ID: <4677B87B.2000108@empretal.com> (raw)
Hi.
I'm doing a program with JDeveloper+ADF and Postgre and was having
problems with the update sentence (created automatically by JDeveloper).
After some research, found the problem in the SQL sentence. Postgre
don't accept alias in a UPDATE query and JDeveloper sends it.
I have modified the driver to eliminate the alias, here's a new method
to include in AbstractJdbc2Statement.java:
private String eliminaAlias(String sql)
{
String nuevaSQL= sql;
StringTokenizer cadenaTokens=new StringTokenizer(sql);
String vTokens[]= new String[cadenaTokens.countTokens()];
int j= 0;
String temp;
while(cadenaTokens.hasMoreTokens())
{
temp= cadenaTokens.nextToken();
vTokens[j]= temp;
j++;
}
// La sentencia tiene un alias, hay que eliminarlo
if((vTokens[1].toLowerCase()).equals(vTokens[2].toLowerCase())
|| (vTokens[1].toLowerCase()).equals("public."+vTokens[2].toLowerCase()))
{
nuevaSQL= "";
for(int i=0;i<vTokens.length;i++)
{
if(i==2)continue;
nuevaSQL+= vTokens[i];
if(i!=(vTokens.length - 1))
{
nuevaSQL+= " ";
}
else
{
nuevaSQL+= ";";
}
}
}
return nuevaSQL;
}
And the call to this method is in the constructor of the class:
public AbstractJdbc2Statement(AbstractJdbc2Connection connection, String
sql, boolean isCallable, int rsType, int rsConcurrency) throws SQLException
{
// -- Added
// Si es una sentencia UPDATE eliminamos el alias
if(sql.trim().toUpperCase().indexOf("UPDATE") == 0)
{
sql = eliminaAlias(sql);
}
// -- End added
.
.
.
I'm sending it to the list because it was ussefull to me and maybe for
others.
Bye, Paxet.
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: jcaballero@empretal.com
Subject: Re: Driver modified for JDeveloper+ADF communication
In-Reply-To: <4677B87B.2000108@empretal.com>
References: <4677B87B.2000108@empretal.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