加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

java – 加载没有Class.forName的JDBC驱动程序

发布时间:2020-12-15 08:48:48 所属栏目:Java 来源:网络整理
导读:Oracle JDBC tutorial说 In previous versions of JDBC,to obtain a connection,you first had to initialize your JDBC driver by calling the method Class.forName. This methods required an object of type java.sql.Driver. Each JDBC driver contains
Oracle JDBC tutorial说

In previous versions of JDBC,to obtain a connection,you first had to
initialize your JDBC driver by calling the method Class.forName. This
methods required an object of type java.sql.Driver. Each JDBC driver
contains one or more classes that implements the interface
java.sql.Driver. The drivers for Java DB are
org.apache.derby.jdbc.EmbeddedDriver and
org.apache.derby.jdbc.ClientDriver,and the one for MySQL Connector/J
is com.mysql.jdbc.Driver. See the documentation of your DBMS driver
to obtain the name of the class that implements the interface
java.sql.Driver.

Any JDBC 4.0 drivers that are found in your class path are automatically loaded. (However,you must manually load any drivers
prior to JDBC 4.0 with the method Class.forName.)

但是当我删除Class.forName时,它会给出错误No Driver found.我正在使用ojdbc14驱动程序.如何在没有Class.forName的情况下实现连接?

解决方法

仔细查看JDBC版本.文章说它是在JDBC 4.0(Java 1.6)中引入的.

但是,ojdbc14是JDBC 3.0(Java 1.5)驱动程序.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读