pg.ddx.io pgsql-jdbc@postgresql.org mailing list archive
help / color / mirror / Atom feedException-handling
4+ messages / 3 participants
[nested] [flat]
* Exception-handling
@ 2006-12-21 10:01 Håkan Jacobsson <hakan.jacobsson99@bredband.net>
0 siblings, 1 reply; 4+ messages in thread
From: Håkan Jacobsson @ 2006-12-21 10:01 UTC (permalink / raw)
To: pgsql-jdbc
Hi,
I'm working against a postgresql database (version 8.0 ).
I was wondering how to handle exceptions properly when doing
database-related stuff, like queries, inserts etc.
Often when I get an exception (I just catch an SQL exception in the catch
clause) I get a message saying call getNextException(). Should I always add
this code in the catch clause? Or should I always add a catch for catching
postgresql-exceptions? Is there a general rule for this?
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Exception-handling
@ 2006-12-21 14:54 Dave Cramer <pg@fastcrypt.com>
parent: Håkan Jacobsson <hakan.jacobsson99@bredband.net>
0 siblings, 1 reply; 4+ messages in thread
From: Dave Cramer @ 2006-12-21 14:54 UTC (permalink / raw)
To: Håkan Jacobsson <hakan.jacobsson99@bredband.net>; +Cc: pgsql-jdbc
The only general rule I adhere to is to make sure you clean up your
connections in a finally clause
Dave
On 21-Dec-06, at 5:01 AM, Håkan Jacobsson wrote:
> Hi,
>
> I'm working against a postgresql database (version 8.0 ).
> I was wondering how to handle exceptions properly when doing
> database-related stuff, like queries, inserts etc.
>
> Often when I get an exception (I just catch an SQL exception in the
> catch
> clause) I get a message saying call getNextException(). Should I
> always add
> this code in the catch clause? Or should I always add a catch for
> catching
> postgresql-exceptions? Is there a general rule for this?
>
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 7: You can help support the PostgreSQL project by donating at
>
> http://www.postgresql.org/about/donate
>
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Exception-handling
@ 2006-12-21 17:04 Roland Walter <roland.walter.rwa@gmx.net>
parent: Dave Cramer <pg@fastcrypt.com>
0 siblings, 1 reply; 4+ messages in thread
From: Roland Walter @ 2006-12-21 17:04 UTC (permalink / raw)
To: Dave Cramer <pg@fastcrypt.com>; +Cc: Håkan Jacobsson <hakan.jacobsson99@bredband.net>; pgsql-jdbc
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Dave Cramer wrote:
> The only general rule I adhere to is to make sure you clean up your
> connections in a finally clause
>
> Dave
Depends of your application. I usually free up all resources in the
finally clause, that I do not need any more. The resources are
ResultSets and Statements and may be connections. Not closing the
Statments and using the same connection further prooved to be fatal.
Regards,
Roland.
- --
Dipl.-Phys. Roland Walter
mailto: roland (dot) walter (dot) rwa (at) gmx (dot) net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org
iD8DBQFFir6oxoOEAkary1ERAh1gAJ0XCLT7ildof8QbH/x6y+xrPy4xvACeLBwk
vv9oqUJtZGFW/pYCtfLKDUk=
=NoBO
-----END PGP SIGNATURE-----
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Exception-handling
@ 2006-12-21 17:06 Dave Cramer <pg@fastcrypt.com>
parent: Roland Walter <roland.walter.rwa@gmx.net>
0 siblings, 0 replies; 4+ messages in thread
From: Dave Cramer @ 2006-12-21 17:06 UTC (permalink / raw)
To: Roland Walter <roland.walter.rwa@gmx.net>; +Cc: Håkan Jacobsson <hakan.jacobsson99@bredband.net>; pgsql-jdbc
On 21-Dec-06, at 12:04 PM, Roland Walter wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Dave Cramer wrote:
>> The only general rule I adhere to is to make sure you clean up your
>> connections in a finally clause
>>
>> Dave
>
> Depends of your application. I usually free up all resources in the
> finally clause, that I do not need any more. The resources are
> ResultSets and Statements and may be connections. Not closing the
> Statments and using the same connection further prooved to be fatal.
My point was to make sure you do your cleanup, whatever it may be in
a finally clause. This is the most frequent cause of leaking resources.
Dave
>
> Regards,
> Roland.
>
> - --
> Dipl.-Phys. Roland Walter
> mailto: roland (dot) walter (dot) rwa (at) gmx (dot) net
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.2 (GNU/Linux)
> Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org
>
> iD8DBQFFir6oxoOEAkary1ERAh1gAJ0XCLT7ildof8QbH/x6y+xrPy4xvACeLBwk
> vv9oqUJtZGFW/pYCtfLKDUk=
> =NoBO
> -----END PGP SIGNATURE-----
>
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2006-12-21 17:06 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-12-21 10:01 Exception-handling Håkan Jacobsson <hakan.jacobsson99@bredband.net>
2006-12-21 14:54 ` Dave Cramer <pg@fastcrypt.com>
2006-12-21 17:04 ` Roland Walter <roland.walter.rwa@gmx.net>
2006-12-21 17:06 ` Dave Cramer <pg@fastcrypt.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