Driver modified for JDeveloper+ADF communication

From: Javier Caballero <jcaballero(at)empretal(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Driver modified for JDeveloper+ADF communication
Date: 2007-06-19 11:05:31
Message-ID: 4677B87B.2000108@empretal.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

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.

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Kris Jurka 2007-06-19 16:38:19 Re: Driver modified for JDeveloper+ADF communication
Previous Message Christopher Hunt 2007-06-18 13:58:53 Re: Literal vs parameterized 'timestamp with time zone' value