pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Driver modified for JDeveloper+ADF communication
2+ messages / 2 participants
[nested] [flat]

* Driver modified for JDeveloper+ADF communication
@ 2007-06-19 11:05 Javier Caballero <jcaballero@empretal.com>
  2007-06-19 16:38 ` Re: Driver modified for JDeveloper+ADF communication Kris Jurka <books@ejurka.com>
  0 siblings, 1 reply; 2+ messages in thread

From: Javier Caballero @ 2007-06-19 11:05 UTC (permalink / raw)
  To: 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.



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Driver modified for JDeveloper+ADF communication
  2007-06-19 11:05 Driver modified for JDeveloper+ADF communication Javier Caballero <jcaballero@empretal.com>
@ 2007-06-19 16:38 ` Kris Jurka <books@ejurka.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Kris Jurka @ 2007-06-19 16:38 UTC (permalink / raw)
  To: Javier Caballero <jcaballero@empretal.com>; +Cc: pgsql-jdbc



On Tue, 19 Jun 2007, Javier Caballero wrote:

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

PG accepts update aliases in version 8.2+.  So a better solution is 
probably just to upgrade.

Kris Jurka



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2007-06-19 16:38 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2007-06-19 11:05 Driver modified for JDeveloper+ADF communication Javier Caballero <jcaballero@empretal.com>
2007-06-19 16:38 ` Kris Jurka <books@ejurka.com>

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