Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Integration test on JDBC (No Hibernate !) and Spring AbstractTransactionalJUnit4SpringContextTests

 
Stephane Eybert
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm trying to set up an integration test against a MySql database with a pure JDBC dao, that is, NOT using Hibernate or any ORM tool.

My base abstract test class uses the AbstractTransactionalJUnit4SpringContextTests class so as to have tests that roll back.



Spring requires a transactionManager bean which I provide.



But I get an exception.



Do I need to provide some connection pooling ?

Is there any way to do it with a Spring bean ?

Kind Regards,

Stephane

 
Rob Spoor
Sheriff
Posts: 20827
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're calling setAutoCommit on a Connection that's already closed.
 
Stephane Eybert
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How come is the connection closed ?


 
Rob Spoor
Sheriff
Posts: 20827
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because line 32 comes before line 38.
 
Stephane Eybert
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Fair enough :-) Thanks !
 
Rob Spoor
Sheriff
Posts: 20827
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!