java.lang.ClassNotFoundException: sun.jdbc.odbc.JdbcOdbcDriver

出现这个异常的原因在于从JDK1.8开始,Oracle删除了jdbc-odbc桥,如果你要使用jdbc-odbc桥,那么请下载jdk1.7或者更低版本

近期笔者经常收到百度知道的消息,都是关于这个的一些评论,所以发一篇再博文说明下。

官网对jdbc-odbc驱动的说明:http://docs.oracle.com/javase/7/docs/technotes/guides/jdbc/bridge.html

JDBC-ODBC Bridge

The JDBC-ODBC Bridge allows applications written in the Java programming language to use the JDBC API with many existing ODBC drivers. The Bridge is itself a driver based on JDBC technology ("JDBC driver") that is defined in the class sun.jdbc.odbc.JdbcOdbcDriver. The Bridge defines the JDBC sub-protocol odbc.

Status of the JDBC-ODBC Bridge

The JDBC-ODBC Bridge should be considered a transitional solution; it will be removed in JDK 8. In addition, Oracle does not support the JDBC-ODBC Bridge. Oracle recommends that you use JDBC drivers provided by the vendor of your database instead of the JDBC-ODBC Bridge.

Why use ODBC at all?

The ideal is "Pure Java": no native code, no platform dependentfeatures. But you may need to begin your development effort rightaway, without waiting for your DBMS to offer a Java-only JDBCdriver. Partly native drivers, such as the JDBC-ODBC Bridge, letyou create programs that easily adapt to Pure Java drivers as theybecome available.

早期的时候java刚诞生没多久,jdbc还不是很成熟,为了保持对微软的驱动兼容使用了jdbc-odbc最为过渡,现在,jdbc已经可以独挡一面了,所以oracle/sun删除了这个驱动,这很正常。但是由于大多数教材的编者并没有与时俱进,操作数据库的第一个例子在jdk1.7的时候仍然是jdbc-odbc......,大部分编者认为配置微软的东西比配置mysql简单,实际上对初学者来说基本没有什么区别。

Oracle/sun还说了,以sun开头的包以后有废弃的风险,如果项目以后要更新的话,建议还是尽量避开这些包

  • 2
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值