469,609 Members | 1,437 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,609 developers. It's quick & easy.

JDBC caching plpgsql function errors?

Hey all - my inaugural post,

I have a Java web application on Tomcat 5 using pg73jdbc3.jar to connect to
PostgreSQL 7.3.4 running on the same server (Red Hat Linux [8.0, I think]).

I have a Perl script that drops the database and rebuilds it with all of our
table/function/etc. scripts. This ran without any errors - all the
functions, tables, etc. were created successfully.

While testing the web application, one of the functions returned a syntax
error. I went in using the psql command-line utility to fix the function
manually, and this worked - I could then call the function successfully via
the command-line ("SELECT foo(bar);").

However - and here's my problem - when testing the web application again, I
still got the SQLExceptioned syntax error, even though the function was
fixed.

Some more curiosities:

If I shut down Postgres and Tomcat, and then restart them, the
problem is still there.

If I shut down Postgres, and test the web application, I get the
expected "Connection could not be established". Then, when restarting
Postgres, I still get the syntax error message.

If I copy the function "foo", rename it as "foo2", and then have
the web application use "foo2" instead of "foo", then it works perfectly.

It would seem some sort of caching is going on, and it persists beyond
shutting Tomcat and Postgres down. Further, it would seem that it has
something to do with JDBC (I'm using PreparedStatement, by the way), or
Tomcat's connection-pooling mechanism, since if I run the very same SQL
statements directly via the psql console, the functions to not return an
error.

Anyone have any ideas? I /think/ I worked around this same problem a few
months ago by restarting the server, but clearly I shouldn't have to do that
every time I modify a function.

Thank you!

Jim Steinberger

Dynamic Edge, Inc.
Nov 23 '05 #1
6 1716

On 30/04/2004 17:34 Jim Steinberger wrote:
[snip]
Anyone have any ideas? I /think/ I worked around this same problem a few
months ago by restarting the server, but clearly I shouldn't have to do
that
every time I modify a function.


Are you storing anything in session scope which might cause the function
to be cached?
--
Paul Thomas
+------------------------------+---------------------------------------------+
| Thomas Micro Systems Limited | Software Solutions for
Business |
| Computer Consultants |
http://www.thomas-micro-systems-ltd.co.uk |
+------------------------------+---------------------------------------------+

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 23 '05 #2

On 30/04/2004 17:34 Jim Steinberger wrote:
[snip]
Anyone have any ideas? I /think/ I worked around this same problem a few
months ago by restarting the server, but clearly I shouldn't have to do
that
every time I modify a function.


Are you storing anything in session scope which might cause the function
to be cached?
--
Paul Thomas
+------------------------------+---------------------------------------------+
| Thomas Micro Systems Limited | Software Solutions for
Business |
| Computer Consultants |
http://www.thomas-micro-systems-ltd.co.uk |
+------------------------------+---------------------------------------------+

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 23 '05 #3
[snip]
Are you storing anything in session scope which might cause the function
to be cached?

No -- when the SUBMIT button is pressed, a bean is instantiated, the bean's
properties are set based on the HTML form, and then the bean's "insert"
method is called. The "insert" method gets a connection from Tomcat's
connection pool, uses it to create a PreparedStatement, and then uses the
bean's properties to set the PreparedStatement's parameters. It executes
the statement, and finally closes the PreparedStatement and then the
Connection (in a finally { } block) before leaving the method.

So, nothing's being stored in the session -- the bean, PreparedStatement,
and Connection objects are all created and destroyed/closed in the scope of
the request.
However, it is possible that each request is using the same database
connection, since each request closes the connection it used, returning the
connection to Tomcat's connection pool. Even if the connection is the same,
however, the specific PreparedStatement should have gone away when it was
closed, shouldn't it have? And even if it cached the PreparedStatement,
why/how would it be able to cache Postgres's response to it?
So confused,
Jim
-----Original Message-----
From: pg*****************@postgresql.org
[mailto:pg*****************@postgresql.org] On Behalf Of Paul Thomas
Sent: Friday, April 30, 2004 2:01 PM
To: Jim Steinberger
Cc: pgsql-general @ postgresql . org
Subject: Re: [GENERAL] JDBC caching plpgsql function errors?
On 30/04/2004 17:34 Jim Steinberger wrote:
[snip]
Anyone have any ideas? I /think/ I worked around this same problem a few
months ago by restarting the server, but clearly I shouldn't have to do
that
every time I modify a function.


Are you storing anything in session scope which might cause the function
to be cached?
--
Paul Thomas
+------------------------------+--------------------------------------------
-+
| Thomas Micro Systems Limited | Software Solutions for
Business |
| Computer Consultants |
http://www.thomas-micro-systems-ltd.co.uk |
+------------------------------+--------------------------------------------
-+

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Nov 23 '05 #4
[snip]
Are you storing anything in session scope which might cause the function
to be cached?

No -- when the SUBMIT button is pressed, a bean is instantiated, the bean's
properties are set based on the HTML form, and then the bean's "insert"
method is called. The "insert" method gets a connection from Tomcat's
connection pool, uses it to create a PreparedStatement, and then uses the
bean's properties to set the PreparedStatement's parameters. It executes
the statement, and finally closes the PreparedStatement and then the
Connection (in a finally { } block) before leaving the method.

So, nothing's being stored in the session -- the bean, PreparedStatement,
and Connection objects are all created and destroyed/closed in the scope of
the request.
However, it is possible that each request is using the same database
connection, since each request closes the connection it used, returning the
connection to Tomcat's connection pool. Even if the connection is the same,
however, the specific PreparedStatement should have gone away when it was
closed, shouldn't it have? And even if it cached the PreparedStatement,
why/how would it be able to cache Postgres's response to it?
So confused,
Jim
-----Original Message-----
From: pg*****************@postgresql.org
[mailto:pg*****************@postgresql.org] On Behalf Of Paul Thomas
Sent: Friday, April 30, 2004 2:01 PM
To: Jim Steinberger
Cc: pgsql-general @ postgresql . org
Subject: Re: [GENERAL] JDBC caching plpgsql function errors?
On 30/04/2004 17:34 Jim Steinberger wrote:
[snip]
Anyone have any ideas? I /think/ I worked around this same problem a few
months ago by restarting the server, but clearly I shouldn't have to do
that
every time I modify a function.


Are you storing anything in session scope which might cause the function
to be cached?
--
Paul Thomas
+------------------------------+--------------------------------------------
-+
| Thomas Micro Systems Limited | Software Solutions for
Business |
| Computer Consultants |
http://www.thomas-micro-systems-ltd.co.uk |
+------------------------------+--------------------------------------------
-+

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Nov 23 '05 #5
Hello,

How can i do to change, with security, my all database and records fromMySQL to PostgreSQL. Can Anybody help me??

Grettings
Kilmer Cruz
Nov 23 '05 #6
Hello,

How can i do to change, with security, my all database and records fromMySQL to PostgreSQL. Can Anybody help me??

Grettings
Kilmer Cruz
Nov 23 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Martin Marques | last post: by
6 posts views Thread by bill.postgresql-users | last post: by
10 posts views Thread by lnd | last post: by
reply views Thread by Jim Steinberger | last post: by
reply views Thread by Solution2021 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.