You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by chunlinyao <ch...@gmail.com> on 2010/10/14 09:27:41 UTC

Re: Schema generation uses auto-commit mode; breaks on XA data sources

Hi

You said schemaTool use autocommit, I found it set autocommit to true and
also call commit method.

According to javadoc in here.
http://download.oracle.com/javase/6/docs/api/java/sql/Connection.html#commit()

Throws:
SQLException - if a database access error occurs, this method is called
while participating in a distributed transaction, if this method is called
on a closed conection or this Connection object is in auto-commit mode

It will get SQLException when this Connection object is in auto-commit mode.

My project broke when I upgrade to a new version of jdbc recently.

Regards,
Yao
-- 
View this message in context: http://openjpa.208410.n2.nabble.com/Schema-generation-uses-auto-commit-mode-breaks-on-XA-data-sources-tp4583095p5634010.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Re: Schema generation uses auto-commit mode; breaks on XA data sources

Posted by Yaocl <ch...@gmail.com>.
Hi

On Thu, Oct 14, 2010 at 4:16 PM, crispyoz [via OpenJPA] <
ml-node+5634141-491366881-296944@n2.nabble.com<ml...@n2.nabble.com>
> wrote:

> Yao please send your persistence.xml, DB and driver details.
>

I figured out the problem.
My Environment:
Openjpa-1.1.0
Glassfish-2.1.1
JDK_1.6.0_21
postgresql-9.0-801.jdbc4.jar

Use a server managed connection pool.
Openjpa schematool work with javax.sql.DataSource,but javax.sql.XADataSource
report a error.

Caused by: org.postgresql.util.PSQLException: Cannot commit when
autoCommit is enabled.
	at org.postgresql.jdbc2.AbstractJdbc2Connection.commit(AbstractJdbc2Connection.java:705)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.postgresql.ds.jdbc23.AbstractJdbc23PooledConnection$ConnectionHandler.invoke(AbstractJdbc23PooledConnection.java:352)
	at $Proxy354.commit(Unknown Source)

Because when I use a Connection.commit it throw a SQLException, and
openjpa catch it.But the XAConnection of postgres use reflect
internally,it wrapped SQLException in a InvocationTargetException.

Finally I got a  java.lang.reflect.UndeclaredThrowableException.

I think this is postgres's bug.

Thanks.

RE: Schema generation uses auto-commit mode; breaks on XA data sources

Posted by C N Davies <cn...@cndavies.com>.
Yao please send your persistence.xml, DB and driver details.


-----Original Message-----
From: chunlinyao [mailto:chunlinyao@gmail.com] 
Sent: Thursday, 14 October 2010 6:28 PM
To: users@openjpa.apache.org
Subject: Re: Schema generation uses auto-commit mode; breaks on XA data
sources


Hi

You said schemaTool use autocommit, I found it set autocommit to true and
also call commit method.

According to javadoc in here.
http://download.oracle.com/javase/6/docs/api/java/sql/Connection.html#commit
()

Throws:
SQLException - if a database access error occurs, this method is called
while participating in a distributed transaction, if this method is called
on a closed conection or this Connection object is in auto-commit mode

It will get SQLException when this Connection object is in auto-commit mode.

My project broke when I upgrade to a new version of jdbc recently.

Regards,
Yao
--
View this message in context:
http://openjpa.208410.n2.nabble.com/Schema-generation-uses-auto-commit-mode-
breaks-on-XA-data-sources-tp4583095p5634010.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.