Cause of No suitable driver found for

后端 未结 15 1663
佛祖请我去吃肉
佛祖请我去吃肉 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:15

    If you look at your original connection string:

    <property name="url" value="jdbc:hsqldb:hsql://localhost"/>
    

    The Hypersonic docs suggest that you're missing an alias after localhost:

    http://hsqldb.org/doc/guide/ch04.html

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

    In order to have HSQLDB register itself, you need to access its jdbcDriver class. You can do this the same way as in this example.

    Class.forName("org.hsqldb.jdbcDriver");
    

    It triggers static initialization of jdbcDriver class, which is:

    static {
        try {
            DriverManager.registerDriver(new jdbcDriver());
        } catch (Exception e) {}
    }
    
    0 讨论(0)
  • 2020-12-14 03:18

    It might be that

    hsql://localhost

    can't be resolved to a file. Look at the sample program here:

    Sample HSQLDB program

    See if you can get that working first, and then see if you can take that configuration information and use it in the Spring bean configuration.

    Good luck!

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