pg.ddx.io pgsql-jdbc@postgresql.org mailing list archive
help / color / mirror / Atom feedJava Studio Creator Fix/Hack
4+ messages / 3 participants
[nested] [flat]
* Java Studio Creator Fix/Hack
@ 2004-12-10 22:09 Pucky Loucks <ploucks@h2st.com>
2004-12-11 00:45 ` Re: Java Studio Creator Fix/Hack Oliver Jowett <oliver@opencloud.com>
2004-12-11 01:53 ` Re: Java Studio Creator Fix/Hack Kris Jurka <books@ejurka.com>
0 siblings, 2 replies; 4+ messages in thread
From: Pucky Loucks @ 2004-12-10 22:09 UTC (permalink / raw)
To: pgsql-jdbc
Hi everyone, I noticed at TODO for getMetaData() on the 8.0 and figured
I'd give this task a try. I now am able to use Java Studio Creator
with Postgresql 7.4.6.
couldn't access the postgresql sites for the past couple of days so I
posted my hack on the Sun Software Forums.
http://swforum.sun.com/jive/thread.jspa?threadID=50150&tstart=15
here is was I posted:
Ok so I've noticed that there have been a few of us Postgres people
trying to use JSC with our favourite Database. I am posting the fix
here because i can't get access to the Postgresql websites(very odd).
if you check out the postgres jdbc code from their cvs change
org.postgresql.jdbc2.AbstractJdbc2Statement.getMetaData() to the
following.
===========START OF CODE HACK===============
public ResultSetMetaData getMetaData() throws SQLException
{ ResultSet rs = null;
checkClosed();
rs = getResultSet();
if(rs == null)
{
// the following code hack has not been fully tested, therefor use at
your own risk.
/// by Pucky Loucks of How2share Technologies (creators of PiXPO)
StatementResultHandler handler = new StatementResultHandler();
connection.getQueryExecutor().execute(preparedQuery,
preparedParameters,
handler,
0,
0,
QueryExecutor.QUERY_ONESHOT);
rs = handler.getResults().getResultSet();
}
return rs.getMetaData();
}
===================END OF CODE HACK=====
then run ant for pgjdbc and use the postgresql.jar that is in the jar
directory, and volia.
Enjoy.
Pucky Loucks
Senior Systems Architect
How2Share Technologies Inc.
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Java Studio Creator Fix/Hack
2004-12-10 22:09 Java Studio Creator Fix/Hack Pucky Loucks <ploucks@h2st.com>
@ 2004-12-11 00:45 ` Oliver Jowett <oliver@opencloud.com>
1 sibling, 0 replies; 4+ messages in thread
From: Oliver Jowett @ 2004-12-11 00:45 UTC (permalink / raw)
To: Pucky Loucks <ploucks@h2st.com>; +Cc: pgsql-jdbc
Pucky Loucks wrote:
> org.postgresql.jdbc2.AbstractJdbc2Statement.getMetaData() to the following. [...]
> connection.getQueryExecutor().execute(preparedQuery,
> preparedParameters,
> handler,
> 0,
> 0,
> QueryExecutor.QUERY_ONESHOT);
> rs = handler.getResults().getResultSet();
> }
Danger, danger. This actually *executes* the query.
Statement.getMetaData() isn't meant to do that!
-O
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Java Studio Creator Fix/Hack
2004-12-10 22:09 Java Studio Creator Fix/Hack Pucky Loucks <ploucks@h2st.com>
@ 2004-12-11 01:53 ` Kris Jurka <books@ejurka.com>
2004-12-11 17:35 ` Re: Java Studio Creator Fix/Hack Pucky Loucks <ploucks@h2st.com>
1 sibling, 1 reply; 4+ messages in thread
From: Kris Jurka @ 2004-12-11 01:53 UTC (permalink / raw)
To: Pucky Loucks <ploucks@h2st.com>; +Cc: pgsql-jdbc
On Fri, 10 Dec 2004, Pucky Loucks wrote:
> Hi everyone, I noticed at TODO for getMetaData() on the 8.0 and figured
> I'd give this task a try. I now am able to use Java Studio Creator
> with Postgresql 7.4.6.
>
> public ResultSetMetaData getMetaData() throws SQLException
> { ResultSet rs = null;
> checkClosed();
> rs = getResultSet();
>
> if(rs == null)
> {
> // the following code hack has not been fully tested, therefor use at
> your own risk.
> /// by Pucky Loucks of How2share Technologies (creators of PiXPO)
>
> StatementResultHandler handler = new StatementResultHandler();
>
> connection.getQueryExecutor().execute(preparedQuery,
> preparedParameters,
> handler,
> 0,
> 0,
> QueryExecutor.QUERY_ONESHOT);
> rs = handler.getResults().getResultSet();
> }
>
> return rs.getMetaData();
> }
> ===================END OF CODE HACK=====
This patch doesn't really work. It assumes that the PreparedStatement
doesn't have side effects and that all parameters have been set.
Consider:
PreparedStatement pst = con.prepareStatement("UPDATE tab SET x=x+1");
pst.getMetaData();
pst.execute();
Now all of a sudden x = x+2. Actually your patch will throw a
NullPointerException, but that's a simple code issue.
Consider:
PreparedStatement pst = con.prepareStatement("SELECT * FROM t WHERE x=?");
pst.getMetaData();
Fails with: org.postgresql.util.PSQLException: No value specified for
parameter 1.
The planned way to implement this feature is with the V3 protocol issuing
Parse/Bind/Describe/ClosePortal without ever executing it.
Kris Jurka
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Java Studio Creator Fix/Hack
2004-12-10 22:09 Java Studio Creator Fix/Hack Pucky Loucks <ploucks@h2st.com>
2004-12-11 01:53 ` Re: Java Studio Creator Fix/Hack Kris Jurka <books@ejurka.com>
@ 2004-12-11 17:35 ` Pucky Loucks <ploucks@h2st.com>
0 siblings, 0 replies; 4+ messages in thread
From: Pucky Loucks @ 2004-12-11 17:35 UTC (permalink / raw)
To: Kris Jurka <books@ejurka.com>; +Cc: pgsql-jdbc
I should have only said HACK not fix... :) Totally understand that
there is a better way to do it, I just need to get something working,
(this is not for production use) therefore hitting the database is fine
for me right now, and all statements are "select * from tablename"
again this is specific hack for Java Studio Creator.
Can't wait till a real JDBC Developer attacks the problem.
Thanks for the awesome work you guys do!
Pucky Loucks
How2Share Technologies Inc.
On 10-Dec-04, at 5:53 PM, Kris Jurka wrote:I s
>
>
> On Fri, 10 Dec 2004, Pucky Loucks wrote:
>
>> Hi everyone, I noticed at TODO for getMetaData() on the 8.0 and
>> figured
>> I'd give this task a try. I now am able to use Java Studio Creator
>> with Postgresql 7.4.6.
>>
>> public ResultSetMetaData getMetaData() throws SQLException
>> { ResultSet rs = null;
>> checkClosed();
>> rs = getResultSet();
>>
>> if(rs == null)
>> {
>> // the following code hack has not been fully tested, therefor use at
>> your own risk.
>> /// by Pucky Loucks of How2share Technologies (creators of PiXPO)
>>
>> StatementResultHandler handler = new StatementResultHandler();
>>
>> connection.getQueryExecutor().execute(preparedQuery,
>> preparedParameters,
>> handler,
>> 0,
>> 0,
>> QueryExecutor.QUERY_ONESHOT);
>> rs = handler.getResults().getResultSet();
>> }
>>
>> return rs.getMetaData();
>> }
>> ===================END OF CODE HACK=====
>
>
> This patch doesn't really work. It assumes that the PreparedStatement
> doesn't have side effects and that all parameters have been set.
>
> Consider:
>
> PreparedStatement pst = con.prepareStatement("UPDATE tab SET x=x+1");
> pst.getMetaData();
> pst.execute();
>
> Now all of a sudden x = x+2. Actually your patch will throw a
> NullPointerException, but that's a simple code issue.
>
> Consider:
>
> PreparedStatement pst = con.prepareStatement("SELECT * FROM t WHERE
> x=?");
> pst.getMetaData();
>
> Fails with: org.postgresql.util.PSQLException: No value specified for
> parameter 1.
>
> The planned way to implement this feature is with the V3 protocol
> issuing
> Parse/Bind/Describe/ClosePortal without ever executing it.
>
> Kris Jurka
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faqs/FAQ.html
>
>
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2004-12-11 17:35 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-12-10 22:09 Java Studio Creator Fix/Hack Pucky Loucks <ploucks@h2st.com>
2004-12-11 00:45 ` Oliver Jowett <oliver@opencloud.com>
2004-12-11 01:53 ` Kris Jurka <books@ejurka.com>
2004-12-11 17:35 ` Pucky Loucks <ploucks@h2st.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