java ClassNotFoundException for org.h2.Driver

前端 未结 13 2370
被撕碎了的回忆
被撕碎了的回忆 2021-01-01 10:40

I am trying to use H2 to connect to a database in Java (using Eclipse as the IDE). The sample does (below) throws a ClassNotFoundException. The thing is, I

13条回答
  •  囚心锁ツ
    2021-01-01 11:20

    I have faced same issue when using : 2 times in h2 database, because Driver manager can not identify proper connection type

    • when you use "jdbc:h2:localhost:123/db", then it divide into "jdbc","h2:localhost","123/db",
    • so here expected value is h2 but getting h2:localhost because of issue in core regex for identify driver class from list of loaded drivers

    Use full path like:

    • Don't: "jdbc:h2:testdb",         Do:"jdbc:h2:/c:/.../testdb"
    • Don't: "jdbc:h2:localhost:123/db",    Do: "jdbc:h2://localhost:123/db"

提交回复
热议问题