Cause of No suitable driver found for

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

    "no suitable driver" usually means that the syntax for the connection URL is incorrect.

    0 讨论(0)
  • 2020-12-14 02:56

    It looks like you're not specifying a database name to connect to, should go something like

    jdbc:hsqldb:hsql://serverName:port/DBname
    
    0 讨论(0)
  • 2020-12-14 02:57

    As some answered before, this line of code solved the problem

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

    But my app is running in some tomcats but only in one installation I had to add this code.

    0 讨论(0)
  • 2020-12-14 02:58

    when try to run datasource connectivity using static main method, first we need to run database connection. This we can achieve in eclipse as bellow.

    1) open any IDE(Eclipse or RAD) after opening workspace by default IDE will be opened in JAVA prospective. Try to switch from java to database prospective in order to create datasource as well as virtual database connectivity.

    2)in database prospective enter all the details like userName, Password and URL of the particular schema.

    3)then try to run main method to access database.

    This will resolve the "serverName undefined".

    0 讨论(0)
  • 2020-12-14 02:59

    great I had the similar problem. The advice for all is to check jdbc url sintax

    0 讨论(0)
  • 2020-12-14 02:59

    I think your HSQL URL is wrong. It should also include the database name,

    so something like

    jdbc:hsqldb:hsql://localhost/mydatabase 
    

    if mydatabase is the name of your DB (file). Not including this can (I'm not sure if it is the case here) confuse the parsing of the URL, which may lead to the DriverManagerDS thinking that your driver is not suitable (it is found, but it thinks it is not a good one)

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