Обсуждение: why do some failure spoils the jdbc connection ?

Поиск
Список
Период
Сортировка

why do some failure spoils the jdbc connection ?

От
Maxime Lévesque
Дата:

 Hi everyone,

 When I execute some statements, for example droping a constraint and the constraint
doesn't exist, an exception gets thrown as expected. If I issue another statelemt
via the same connection, I get another exception saying the transaction is canceled,
in other words, the connection is no longer useable.

 Is the re a way that I can concinue using the connection ?

 Thanks

Re: why do some failure spoils the jdbc connection ?

От
Kris Jurka
Дата:

On Sat, 1 May 2010, Maxime L?vesque wrote:

>  When I execute some statements, for example droping a constraint and
> the constraint doesn't exist, an exception gets thrown as expected. If I
> issue another statelemt via the same connection, I get another exception
> saying the transaction is canceled, in other words, the connection is no
> longer useable.
>
>  Is the re a way that I can concinue using the connection ?
>

Yes, by creating a Savepoint around statements that may fail and rolling
back to that Savepoint if an exception occurs.

http://java.sun.com/javase/6/docs/api/java/sql/Connection.html#rollback%28java.sql.Savepoint%29

Kris Jurka