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
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()
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.