Back to Blog
Mysql jdbc driver class7/11/2023 Thereafter the newInstance () will be called on that class which returns an instance of the class, with no parameters, it is just calling new (). Therefore when you call Class.forName (.) it returns .class. This will also execute the static block and registers the driver but we will not be using the driver object anywhere after that which causes the problem of having extra memory allocation. The newInstance () method returns a new instance of the class. ![]() You even can register the driver just by creating object for the Driver class like below driver = new () The DriverInfo is a package-private support class which holds Driver object, driverClass and driverClassName class DriverInfo public static synchronized void registerDriver( driver)ĭi.driverClassName = di.driverClass.getName() ![]() We will then finally add the DriverInfo object into the drivers vector. With this method, you could use an external configuration file to supply the. With MySQL Connector/J, the name of this class is. ![]() The easiest way to do this is to use Class.forName() on the class that implements the interface. The registerDriver() method gets the driver object and registers all information about MySql driver via DriverInfo class. Specify to the DriverManager which JDBC drivers to try to make Connections with.
0 Comments
Read More
Leave a Reply. |