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

前端 未结 2 386
北海茫月
北海茫月 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条回答
  •  慢半拍i
    慢半拍i (楼主)
    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()

提交回复
热议问题