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 - sqljdbc JDBC Driver Example
How to verify if sqljdbc 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 sqljdbc JDBC Driver is loaded corrected from the classpath or not:
// Copyright (c) 2016 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 sqljdbc JDBC driver class listed in the output:
C:\fyicenter>\local\jdk-1.8.0\bin\javac ShowJdbcDrivers.java C:\fyicenter>\local\jdk-1.8.0\bin\java -cp .;C:\local\sqljdbc_6.0\enu\sqljdbc42.jar ShowJdbcDrivers Loaded JDBC driver classes: com.microsoft.sqlserver.jdbc.SQLServerDriver
If you run the example again with a typo in the classpath, you will not see the sqljdbc JDBC driver class in the output:
C:\fyicenter>\local\jdk-1.8.0\bin\java -cp .;C:\local\sqljdbc_6.0\enu\sqljdbc-4.2.jar ShowJdbcDrivers Loaded JDBC driver classes:
If you run the example in JDK 1.8 with sqljdbc.jar in the classpath, you will not see the sqljdbc JDBC driver class in the output. This shows that sqljdbc.jar is not compatible with JDK 1.8.
C:\fyicenter>\local\jdk-1.8.0\bin\java -cp .;C:\local\sqljdbc_6.0\enu\sqljdbc.jar ShowJdbcDrivers Loaded JDBC driver classes:
⇒ sqljdbc JDBC Driver Connection URL String
⇐ sqljdbc Driver in Java Database Connection Architecture
2017-01-05, 2167🔥, 0💬
Popular Posts:
How to download and install Apache XMLBeans-2.6.0.zip? If you want to try the XMLBeans Java library,...
JDK 11 java.sql.jmod is the JMOD file for JDK 11 SQL (Structured Query Language) module. JDK 11 SQL ...
JLayer is a library that decodes/plays/converts MPEG 1/2/2.5 Layer 1/2/3 (i.e. MP3) in real time for...
ANTLR is a powerful parser generator for multiple programming languages including Java. ANTLR contai...
What Is XMLBeans xbean.jar 2.6.0? XMLBeans xbean.jar 2.6.0 is the JAR file for Apache XMLBeans 2.6.0...