Thread: Troubles using PreparedStatements

Troubles using PreparedStatements

From
Alexander Troppmann
Date:
Hello,

I ran into troubles when using PreparedStatements with JDBC. My PostgreSQL
version is postgresql-jdbc-7.1.3-2 from Red Hat Linux 7.2, JDK is
IBMJava2-SDK-1.3-9.0. Here is a code snippet - I've built in debuggings...

log.debug("use a PreparedStatement and set all values");
pstmt = conn.prepareStatement(sqlValue);
log.debug("before setValues");
setValues(pstmt, values);
log.debug("after setValues");
rs = pstmt.executeQuery();
log.debug("after executeQuery");

I've already debugged the setValues() method successfully (the "values"
Vector provided wrong Objects...) So the problem is: the last line of the
code snippet will never be reached. So here's my debugging output:

[DEBUG] SQLCommandBean - requesting connection from DataSource
[DEBUG] SQLCommandBean - use a PreparedStatement and set all values
[DEBUG] SQLCommandBean - before setValues
[DEBUG] SQLCommandBean - set 1 values for prepared statement
[DEBUG] SQLCommandBean - element 1:
hexagon.storage.sql.value.IntValue@3267de1b
[DEBUG] SQLCommandBean - all values set
[DEBUG] SQLCommandBean - after setValues

unfortunatly that's all - no Exception, no error, no message at all - it
seems that the "rs = pstmt.executeQuery();" statement kills the running java
process...

Any idea?

The sql query looks like this: SELECT p.id, c.name AS customername, p.title,
p.description, p.creation, p.modified FROM project AS p, customer AS c WHERE
p.customer_id=c.id AND p.id=? ORDER BY customer, title

This code line adds the value for the prepared statement in setValues():

...
} else if (v instanceof IntValue) {
   pstmt.setInt(j, v.getInt());
...

I hope, someone can help... :-))

greetings from Munich,
cu talex


--
Don't Fear the Penguin...        <o)
                                 /\\
> http://www.cocktaildreams.de  _\_v


Re: Troubles using PreparedStatements

From
Dave Cramer
Date:
Is it possible this is a bug with the jvm? You should never be able to
kill the running java process.

Dave
On Fri, 2002-04-19 at 15:39, Alexander Troppmann wrote:
>
> Hello,
>
> I ran into troubles when using PreparedStatements with JDBC. My PostgreSQL
> version is postgresql-jdbc-7.1.3-2 from Red Hat Linux 7.2, JDK is
> IBMJava2-SDK-1.3-9.0. Here is a code snippet - I've built in debuggings...
>
> log.debug("use a PreparedStatement and set all values");
> pstmt = conn.prepareStatement(sqlValue);
> log.debug("before setValues");
> setValues(pstmt, values);
> log.debug("after setValues");
> rs = pstmt.executeQuery();
> log.debug("after executeQuery");
>
> I've already debugged the setValues() method successfully (the "values"
> Vector provided wrong Objects...) So the problem is: the last line of the
> code snippet will never be reached. So here's my debugging output:
>
> [DEBUG] SQLCommandBean - requesting connection from DataSource
> [DEBUG] SQLCommandBean - use a PreparedStatement and set all values
> [DEBUG] SQLCommandBean - before setValues
> [DEBUG] SQLCommandBean - set 1 values for prepared statement
> [DEBUG] SQLCommandBean - element 1:
> hexagon.storage.sql.value.IntValue@3267de1b
> [DEBUG] SQLCommandBean - all values set
> [DEBUG] SQLCommandBean - after setValues
>
> unfortunatly that's all - no Exception, no error, no message at all - it
> seems that the "rs = pstmt.executeQuery();" statement kills the running java
> process...
>
> Any idea?
>
> The sql query looks like this: SELECT p.id, c.name AS customername, p.title,
> p.description, p.creation, p.modified FROM project AS p, customer AS c WHERE
> p.customer_id=c.id AND p.id=? ORDER BY customer, title
>
> This code line adds the value for the prepared statement in setValues():
>
> ...
> } else if (v instanceof IntValue) {
>    pstmt.setInt(j, v.getInt());
> ...
>
> I hope, someone can help... :-))
>
> greetings from Munich,
> cu talex
>
>
> --
> Don't Fear the Penguin...        <o)
>                                  /\\
> > http://www.cocktaildreams.de  _\_v
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
>
>