public static void main (String [] args) throws SQLException {
Enumeration result = DriverManager.getDrivers ();
while (result.hasMoreElements ()) {
System.out.println (result.nextElement (). getClass (). getName ());
}
}
just imported the mysql jdbc connection packet mysql-connector-java-5.1.21-bin.jar, does not load the driver
enter the result :
sun.jdbc.odbc.JdbcOdbcDriver
com.mysql.jdbc.Driver
and the connection also have access to the contents of the database without any problems.
When importing data packets jdbc connection oracle ojdbc14.jar , no access to the oracle driver
In other words , jdbc connect to the database , as long as the import for mysql driver package , you can load the driver need not be displayed properly connected
The oracle load the driver must show How should these issues
reasonable explanation for it ?
------ Solution ---------------------------------------- ----
I do not know right interpretation
you look at the top of this class DriverManager comment
The DriverManager methods getConnection and
getDrivershave been enhanced to support the Java Standard Edition
Service Providermechanism. JDBC 4.0 Drivers must
* include the file META-INF/services/java.sql.Driver. This file contains the name of the JDBC drivers
* implementation of java.sql.Driver. For example, to load the my.sql.Driver class,
* the META-INF/services/java.sql.Driver file would contain the entry:
*
*my.sql.Driver
*
mysql oracle driver package which did not have
------ Solution ------------------------------------ --------

ojdbc14 there without this ?
------ For reference only -------------------------------------- -
the code you posted , you said the problem with seemingly nothing to do
------ For reference only -------------------- -------------------
is the problem , are explained in the DriverManager

------ For reference only ---------------------------------- -----
is the problem , are explained in the DriverManager

Thank statement posted to the sub-
actually encountered this problem first, to see api documentation two is to look at the source code to see the source code I feel better haha
没有评论:
发表评论