Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (101)
JavaBeans (21)
JDBC (121)
JDK (426)
JSP (20)
Logging (108)
Mail (58)
Messaging (8)
Network (84)
PDF (97)
Report (7)
Scripting (84)
Security (32)
Server (121)
Servlet (26)
SOAP (24)
Testing (54)
Web (15)
XML (309)
Collections:
Other Resources:
ShowJdbcDrivers.java - Connector/J JDBC Driver Example
How to verify if Connector/J JDBC Driver is loaded corrected from the classpath? I want to see a Java program example.
✍: FYIcenter.com
Here is an example program, ShowJdbcDrivers.java, that can be used to verify if Connector/J JDBC Driver is loaded corrected from the classpath or not:
// Copyright (c) FYIcenter.com import java.sql.DriverManager; import java.sql.Driver; import java.util.Enumeration; // Example show all JDBC drivers loaded in the classpath public class ShowJdbcDrivers { public static void main(String [] args) throws Exception { System.out.println("Loaded JDBC driver classes:"); for (Enumeration<Driver> drivers=DriverManager.getDrivers(); drivers.hasMoreElements(); ) { System.out.println(drivers.nextElement().getClass().getName()); } } }
You can compile and run the above example in a command window. You should see Connector/J JDBC driver class listed in the output:
fyicenter> javac ShowJdbcDrivers.java fyicenter> java -cp .;mysql-connector-java-5.1.40-bin.jar ShowJdbcDrivers Loaded JDBC driver classes: com.mysql.jdbc.Driver com.mysql.fabric.jdbc.FabricMySQLDriver
If you run the example again without the mysql-connector-java-5.1.40-bin.jar file in the classpath, you will not see the Connector/J JDBC driver class in the output:
fyicenter> java -cp . ShowJdbcDrivers Loaded JDBC driver classes:
⇒ Connector/J JDBC Driver Connection URL String
⇐ Connector/J in Java Database Connection Architecture
2016-12-04, 1753🔥, 0💬
Popular Posts:
Apache Axis2 is the core engine for Web services. It is a complete re-design and re-write of the wid...
Java Architecture for XML Binding (JAXB) is a Java API that allows Java developers to map Java class...
How to download and install JDK (Java Development Kit) 1.3? If you want to write Java applications, ...
JDK 11 java.compiler.jmod is the JMOD file for JDK 11 Compiler module. JDK 11 Compiler module compil...
JDK 11 jdk.scripting.nashorn.jm odis the JMOD file for JDK 11 Scripting Nashorn module. JDK 11 Scrip...