MySQL Connector/J 8.0 Developer Guide /. The name of the class that implements java.sql.Driver in MySQL Connector/J has changed from com.mysql.jdbc.Driver to com.mysql.cj.jdbc.Driver. The old class name has been deprecated. The names of these commonly-used classes and interfaces have also been changed. This page shows details for the Java class Driver contained in the package org.gjt.mm.mysql. All JAR files containing this class file are listed. Last queries: SimpleTypeConverter ARRAYUTILS org.hibernate.Session.
![]()
Ranch Hand
posted 8 years ago
is there any difference between
and however in the second statement a instance of the Class is created but both are giving the same output, so i want to know is there any difference between both of them??
Sheriff
posted 8 years ago
The first only loads the class, the second also creates an instance. For some (mostly old) drivers this was necessary because the class wouldn't register itself properly without it. You're using an old driver though. The latest one is com.mysql.jdbc.Driver, and doesn't need the newInstance() call.
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask QuestionsHow To Answer Questions
Marshal
posted 8 years ago
You do not need an instance of the class. If your class has a private constructor, it may throw a (checked) Exception. You should miss out the newInstance call because you do not need the instance.
Ranch Hand
posted 8 years ago
means if i m using
Class.forName('com.mysql.jdbc.Driver'); i should not worry about newInstance().
Sheriff
posted 8 years ago
Campbell Ritchie wrote:You do not need an instance of the class. If your class has a private constructor, it may throw a (checked) Exception. You should miss out the newInstance call because you do not need the instance.
If I recall correctly, a few quite old JDBC drivers actually did need an instance. They were poorly written to register the driver in the constructor, not a static block. These days that should definitely not be the case anymore.
Punit Jain wrote:means if i m using Class.forName('com.mysql.jdbc.Driver'); i should not worry about newInstance(). Nope. Just drop it.
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask QuestionsHow To Answer Questions
Ranch Hand
posted 8 years ago
Sheriff
posted 8 years ago
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask QuestionsHow To Answer Questions
Marshal
posted 8 years ago
Jeff FischerResearch EngineerNovell AppNotes01 Mar 2003With the addition of MySQL for NetWare, NetWare now has a fast, reliable, and proven database server. MySQL has gained a large market share running on Linux servers because it is open source. While it does not provide some advanced features that other database servers provide, it does provide fast access and strong performance.NetWare and MySQL make a good combination with NetWare's scalability and web services initiatives, and MySQL's speed. Every Java developer needs the JDBC driver for MySQL, which can be downloaded from. Here are the specifics necessary in order to use the MySQL JDBC driver.The driver name is mm.mysql-2.0.14-bin.jar.
Once the.jar file is included in your classpath, just like any JDBC driver, you need to include three statements in your code to connect to MySQL running on NetWare. They are the class to import, the driver name to register in the class.forName statement, and the URL for the database you want to connect to.Here is a code snippet that shows the three necessary statements to connect to a MySQL database running on a NetWare server. Import org.gjt.mm.mysql.;Class.forName('org.gjt.mm.mysql.Driver');Connection con =DriverManager.getConnection('jdbc:mysql://serverhostname:3306/dbname','dbuser', 'dbpassword');Note: Don't forget to grant access to the database with a Grant statement to the database user you use for the JDBC connection.
![]() Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
February 2023
Categories |