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

Re: query manipulation

From: Mark Lewis <mark(dot)lewis(at)mir3(dot)com>
To: Dave Cramer <pg(at)fastcrypt(dot)com>
Cc: Randall Smith <randall(at)tnr(dot)cc>, pgsql-jdbc(at)postgresql(dot)org
Subject: Re: query manipulation
Date: 2007-03-19 21:27:52
Message-ID: 1174339672.7880.107.camel@archimedes (view raw or flat)
Thread:
Lists: pgsql-jdbc
Randall,

I happen to have an example right here that might be useful for you.
The attached class will wrap a driver (in this case hard-coded to
"org.postgresql.Driver") and transparently implement prepared statement
caching.  Shouldn't be too hard to adapt it to your case.

Disclaimer: this is for demonstration only, not a production-quality
implementation.  Don't use this in your product without reading through
it, understanding the limitations and adding some sanity checking.
Also, this is based on a real class we use for testing here, but the
process of simplifying it for the list may have broken stuff.

-- Mark

On Mon, 2007-03-19 at 16:37 -0400, Dave Cramer wrote:
> Randall,
> 
> Yeah, you would have to wrap the jdbc driver with a proxy driver.  
> It's not that hard to write one.
> 
> Dave
> On 19-Mar-07, at 4:19 PM, Randall Smith wrote:
> 
> > I'm trying to find a way to manipulate some poorly written queries  
> > in which I don't have access to the application source.  I can't do  
> > it at the Postgresql server, so I'm thinking of attacking it at the  
> > jdbc driver.
> >
> > I was thinking of a wrapper that would look at and alter the SQL  
> > before it went to the server.  Anyone know of something like this?  
> > Specifically, I'm trying to drop "FOR UPDATE column name" off of  
> > some queries.  They were written for Oracle, but Postgresql uses  
> > "FOR UPDATE table name".  I'm not a Java programmer, but I won't  
> > let that stop me if it is required.
> >
> > Randall
> >
> >
> > ---------------------------(end of  
> > broadcast)---------------------------
> > TIP 7: You can help support the PostgreSQL project by donating at
> >
> >                http://www.postgresql.org/about/donate
> >
> 
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 6: explain analyze is your friend

Attachment: PoolingDriver.java
Description: text/x-java (2.8 KB)

In response to

Responses

pgsql-jdbc by date

Next:From: Randall SmithDate: 2007-03-20 19:21:36
Subject: Re: query manipulation
Previous:From: Dave CramerDate: 2007-03-19 20:37:31
Subject: Re: query manipulation

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