Cause of No suitable driver found for

后端 未结 15 1662
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-14 02:17

I\'m trying to unit test (JUnit) a DAO i\'ve created. I\'m using Spring as my framework, my DAO (JdbcPackageDAO) extends SimpleJdbcDaoSupport. The testing class (JdbcPacka

相关标签:
15条回答
  • 2020-12-14 03:05

    Okay so here's the solution. Most everyone made really good points but none solved the problem (THANKS for the help). Here is the solution I found to work.

    1. Move jars from .../web-inf/lib to PROJECT_ROOT/lib
    2. Alter build path in eclipse to reflect this change.
    3. cleaned and rebuilt my project.
    4. ran the junit test and BOOM it worked!

    My guess is that it had something to do with how Ganymede reads jars in the /web-inf/lib folder. But who knows... It works now.

    0 讨论(0)
  • 2020-12-14 03:06

    In some cases check permissions (ownership).

    0 讨论(0)
  • 2020-12-14 03:10

    I was facing similar problem and to my surprise the problem was in the version of Java. java.sql.DriverManager comes from rt.jar was unable to load my driver "COM.ibm.db2.jdbc.app.DB2Driver".

    I upgraded from jdk 5 and jdk 6 and it worked.

    0 讨论(0)
  • 2020-12-14 03:11

    Can you import the driver (org.hsqldb.jdbcDriver) into one of your source files? (To test that the class is actually on your class path).

    If you can't import it then you could try including hsqldb.jar in your build path.

    0 讨论(0)
  • 2020-12-14 03:11

    I had the same problem with spring, commons-dbcp and oracle 10g. Using this URL I got the 'no suitable driver' error: jdbc:oracle:thin@192.168.170.117:1521:kinangop

    The above URL is missing a full colon just before the @. After correcting that, the error disappeared.

    0 讨论(0)
  • 2020-12-14 03:13

    Not sure if it's worth anything, but I had a similar problem where I was getting a "java.sql.SQLException: No suitable driver found" error. I found this thread while researching a solution.

    The way I ended up solving my problem was to forgo using java.sql.DriverManager to get a connection and instead built up an instance of org.hsqldb.jdbc.jdbcDataSource and used that.

    The root cause of my problem (I believe) had to do with the classloader hierarchy and the fact that the JRE was running Java 5. Even though I could successfully load the jdbcDriver class, the classloader behind java.sql.DriverManager was higher up, to the point that it couldn't see the hsqldb.jar I needed.

    Anyway, just putting this note here in case someone else stumbles by with a similar problem.

    0 讨论(0)
提交回复
热议问题