I am trying to load or u can say register my sql jdbc driver with the use of ServletConfig interface

前端 未结 2 354
北海茫月
北海茫月 2021-01-26 00:37

I am able to load my mysql jdbc driver from the other ways but when I am trying to register it with the use of servletconfig interface it gives an exception

相关标签:
2条回答
  • 2021-01-26 00:53

    The error it's because there is no class "driver" the correct sentence is :

    Class.forName("com.mysql.jdbc.Driver"); 
    

    or

    Class.forName( config.getInitParameter("driver") ); 
    

    But actually this isn't a correct way to access a database in a servlet see : Class.forName("com.mysql.jdbc.Driver").newInstance()

    0 讨论(0)
  • 2021-01-26 00:54

    The problem is in the Class.forName() line, but you haven't needed this line at all since 2007, and you therefore don't need the init parameter either. Just remove both.

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