Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

No suitable driver Error in Test Class

 
Franz van Betteraey
Greenhorn
Posts: 20
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I have a problem writing a Spring-Unit-Test extending AbstractDependencyInjectionSpringContextTests.
The TestClass (Bean) includes a property of a bean that I want to test. Injection of that bean happens well.
The bean to test extends "SimpleJdbcDaoSupport". Every configuration (jdbcTemplate/datasource) is done well (in my opinion).

I want to test a database operation and the method invokation happens well. But than the following error occures:



This happens normally, when the jar with the db drivers are not in the classpath. But they are.

So, does anybody knows about a reason for this problem. Maybe using a Test Class which extends AbstractDependencyInjectionSpringContextTests does not inject all propertys needed in reference bean which I want to test (especially the jdbcTemplate property).

Any help is appreciated.

Best regards
Klaus
 
Herman Schelti
Ranch Hand
Posts: 387
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Klaus,

Every configuration (jdbcTemplate/datasource) is done well (in my opinion).


Should we guess your configuration or are you are going to post it?

Herman
 
Franz van Betteraey
Greenhorn
Posts: 20
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Herman,

I will post it :-)



After some more debugging (and logging) I am very sure, that all injection is done correctly and also the class to test (de.mycompany.myproject.dao.myDaoImpl) has a correct refence to the DataSource. So it must be some kind of classpath problem I cant figure out. The necessary DB2 Jar's are in the classpath, but apperently can not be found while establishing the connection.

I assume that ist is hard to comprehend the problem but any hint what to check is still welcome.

Thanks
Klaus
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<property name="url" value="dbcb2://localhost:55150/myDB"/>


The url value appears incorrect. Shouldn't it be:



The 'j' in jdbc seems to be missing in the url that you posted.
 
Franz van Betteraey
Greenhorn
Posts: 20
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh my god!

I will

* never ever assert that I did every configuration well
* search for the deep black hole to sink
* thank you 1000 times for finding this mistake

Klaus
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic