Cause of No suitable driver found for

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

提交回复
热议问题