what exactly does this do Class.forName(“com.mysql.jdbc.Driver”).newInstance();

后端 未结 5 1820
孤独总比滥情好
孤独总比滥情好 2020-12-30 02:57

While connecting to MySQL database I do following steps

Connection con = null;
Resultset rs = null;
Statement st = null;
Class.forName(\"com.mysql.jdbc.Drive         


        
5条回答
  •  醉酒成梦
    2020-12-30 03:39

    It initialize the class "com.mysql.jdbc.Driver" if found in the classpath, this imply that the driver is registered in the JDBC driver manager since the registration process is inside the static initializer of the driver class ...

    There is another approach you can use to register a driver : is to use the static DriverManager.registerDriver() method.

提交回复
热议问题