Exception on org.dbunit.ext.mssql.InsertIdentityOperation.CLEAN_INSERT

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Exception on org.dbunit.ext.mssql.InsertIdentityOperation.CLEAN_INSERT

Loïc Lacombe-2
Hi,
Here is the infamous exception.

com.microsoft.sqlserver.jdbc.SQLServerException: The COMMIT TRANSACTION request has no 

corresponding BEGIN TRANSACTION.
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(Unknown 

Source)
at com.microsoft.sqlserver.jdbc.IOBuffer.processPackets(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectionCommand(Unknown 

Source)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.sendCommit(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.setAutoCommit(Unknown 

Source)
at org.dbunit.ext.mssql.InsertIdentityOperation.execute

(InsertIdentityOperation.java:240)
at org.dbunit.operation.CompositeOperation.execute(CompositeOperation.java:79)
at org.dbunit.AbstractDatabaseTester.executeOperation

(AbstractDatabaseTester.java:190)
at org.dbunit.AbstractDatabaseTester.onSetup(AbstractDatabaseTester.java:103)
at org.dbunit.DatabaseTestCase.setUp(DatabaseTestCase.java:156)
at com.transatel.vigor.commons.dbunit.AbstractVigorDbUnitTest.setUp

(AbstractVigorDbUnitTest.java:66)
at junit.framework.TestCase.runBare(TestCase.java:132)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at junit.framework.TestSuite.runTest(TestSuite.java:232)
at junit.framework.TestSuite.run(TestSuite.java:227)
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:79)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run

(JUnit4TestReference.java:45)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run

(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests

(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests

(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run

(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main

(RemoteTestRunner.java:196)

The setting back of the autocommit breaks everything down as it seems to want to do a commit when no transaction was started, under some rare conditions. Which cases, I have not figured out yet.
I worked around this stuff by copying the original class source and try/catching the final commit and the setAutocommit. After that ugly modification, it just works flawlessly and I cannot find any missing data as far as I can see.

So, what could cause this strange behavior ?

TIA

Loïc



------------------------------------------------------------------------------
Stay on top of everything new and different, both inside and
around Java (TM) technology - register by April 22, and save
$200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
300 plus technical and hands-on sessions. Register today.
Use priority code J9JMT32. http://p.sf.net/sfu/p
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user
Reply | Threaded
Open this post in threaded view
|

Re: Exception on org.dbunit.ext.mssql.InsertIdentityOperation.CLEAN_INSERT

Matthias Gommeringer
Hi Loic,

I read through http://www.tech-archive.net/Archive/SQL-Server/microsoft.public.sqlserver.jdbcdriver/2006-04/msg00051.html and to me it is not clear why the ".setAutocommit(true)" tries to commit a transaction while no work has been done since the last "jdbcConnection.commit()". It looks as if the MS-SQL JDBC driver implementation changed (see the link above) - I do not have any idea how to fix this, sorry...I think catching the exception is not the proper way to handle this, but maybe it is the only one. Please let me know if you find a better solution (or perhaps a JDBC driver update). Otherwise let me know whether I should commit your bugfix.

thanks and regards,
matthias


> -----Ursprüngliche Nachricht-----
> Von: "Loïc Lacombe" <[hidden email]>
> Gesendet: 20.04.09 20:35:14
> An: [hidden email]
> Betreff: [dbunit-user] Exception on org.dbunit.ext.mssql.InsertIdentityOperation.CLEAN_INSERT

Hi,

> Here is the infamous exception.
>
> com.microsoft.sqlserver.jdbc.SQLServerException: The COMMIT
> TRANSACTION request has no
>
> corresponding BEGIN TRANSACTION.
> at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseErro
> r(Unknown
>
> Source)
> at com.microsoft.sqlserver.jdbc.IOBuffer.processPackets(Unknown
> Source)
> at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectionCommand(
> Unknown
>
> Source)
> at com.microsoft.sqlserver.jdbc.SQLServerConnection.sendCommit(
> Unknown Source)
> at com.microsoft.sqlserver.jdbc.SQLServerConnection.setAutoCommit(
> Unknown
>
> Source)
> at org.dbunit.ext.mssql.InsertIdentityOperation.execute
>
> (InsertIdentityOperation.java:240)
> at org.dbunit.operation.CompositeOperation.execute(CompositeOperation.
> java:79)
> at org.dbunit.AbstractDatabaseTester.executeOperation
>
> (AbstractDatabaseTester.java:190)
> at org.dbunit.AbstractDatabaseTester.onSetup(AbstractDatabaseTester.
> java:103)
> at org.dbunit.DatabaseTestCase.setUp(DatabaseTestCase.java:156)
> at com.transatel.vigor.commons.dbunit.AbstractVigorDbUnitTest.setUp
>
> (AbstractVigorDbUnitTest.java:66)
> at junit.framework.TestCase.runBare(TestCase.java:132)
> at junit.framework.TestResult$1.protect(TestResult.java:110)
> at junit.framework.TestResult.runProtected(TestResult.java:128)
> at junit.framework.TestResult.run(TestResult.java:113)
> at junit.framework.TestCase.run(TestCase.java:124)
> at junit.framework.TestSuite.runTest(TestSuite.java:232)
> at junit.framework.TestSuite.run(TestSuite.java:227)
> at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner
> .java:79)
> at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run
>
> (JUnit4TestReference.java:45)
> at org.eclipse.jdt.internal.junit.runner.TestExecution.run
>
> (TestExecution.java:38)
> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests
>
> (RemoteTestRunner.java:460)
> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests
>
> (RemoteTestRunner.java:673)
> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run
>
> (RemoteTestRunner.java:386)
> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main
>
> (RemoteTestRunner.java:196)
>
> The setting back of the autocommit breaks everything down as it seems
> to want to do a commit when no transaction was started, under some
> rare conditions. Which cases, I have not figured out yet.
> I worked around this stuff by copying the original class source and
> try/catching the final commit and the setAutocommit. After that ugly
> modification, it just works flawlessly and I cannot find any missing
> data as far as I can see.
>
> So, what could cause this strange behavior ?
>
> TIA
>
> Loïc
>
> ----------------------------------------------------------------------
> -------- Stay on top of everything new and different, both inside and
> around Java (TM) technology - register by April 22, and save $200 on
> the JavaOne (SM) conference, June 2-5, 2009, San Francisco. 300 plus
> technical and hands-on sessions. Register today. Use priority code
> J9JMT32. http://p.sf.net/sfu/p________________________________________
> _______ dbunit-user mailing list [hidden email]
>
> https://lists.sourceforge.net/lists/listinfo/dbunit-user


______________________________________________________
GRATIS für alle WEB.DE-Nutzer: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://movieflat.web.de


------------------------------------------------------------------------------
Stay on top of everything new and different, both inside and
around Java (TM) technology - register by April 22, and save
$200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
300 plus technical and hands-on sessions. Register today.
Use priority code J9JMT32. http://p.sf.net/sfu/p
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user
Reply | Threaded
Open this post in threaded view
|

Re: Exception on org.dbunit.ext.mssql.InsertIdentityOperation.CLEAN_INSERT

Loïc Lacombe-2
Hi,
Some further investigations were done and I could not exactly pinpoint the root problem.
It seems like when the flat xml dataset file has some foreign keys related inconsistencies, the commit error may appear but when I use my workaround, the foreign key problem is masked. So the workaround is not exactly a solution.

Loïc Lacombe




On Mon, Apr 20, 2009 at 9:06 PM, Matthias Gommeringer <[hidden email]> wrote:
Hi Loic,

I read through http://www.tech-archive.net/Archive/SQL-Server/microsoft.public.sqlserver.jdbcdriver/2006-04/msg00051.html and to me it is not clear why the ".setAutocommit(true)" tries to commit a transaction while no work has been done since the last "jdbcConnection.commit()". It looks as if the MS-SQL JDBC driver implementation changed (see the link above) - I do not have any idea how to fix this, sorry...I think catching the exception is not the proper way to handle this, but maybe it is the only one. Please let me know if you find a better solution (or perhaps a JDBC driver update). Otherwise let me know whether I should commit your bugfix.

thanks and regards,
matthias

------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, &
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com 
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user