开发环境一直使用jdbc14.jar "Oracle JDBC Driver version - 9.0.2.0.0"版本连接Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 服务器,突然今天不能连接了,报错误如下:
java.sql.SQLException: 不能在 UTF8 和 UCS2 之间转换: failUTF8Conv
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java: 134 )
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java: 179 )
at oracle.jdbc.dbaccess.DBError.check_error(DBError.java: 1130 )
at oracle.jdbc.dbaccess.DBConversion.failUTF8Conv(DBConversion.java: 2261
)
at oracle.jdbc.dbaccess.DBConversion.utf8BytesToJavaChars(DBConversion.j
ava: 2061 )
at oracle.jdbc.dbaccess.DBConversion.utf8BytesToString(DBConversion.java
: 1976 )
at oracle.jdbc.dbaccess.DBConversion.CharBytesToString(DBConversion.java
: 543 )
at oracle.jdbc.ttc7.TTIoer.processWarning(TTIoer.java: 334 )
at oracle.jdbc.ttc7.O3log.receive2nd(O3log.java: 523 )
at oracle.jdbc.ttc7.TTC7Protocol.logon(TTC7Protocol.java: 278 )
at oracle.jdbc.driver.OracleConnection. < init > (OracleConnection.java: 346 )
at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.ja
va: 468 )
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java: 314 )
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at JDBC.main(JDBC.java: 9 )
然后更换为Oracle 11g的驱动,可以正常连接了,但是会显示下面异常
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java: 134 )
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java: 179 )
at oracle.jdbc.dbaccess.DBError.check_error(DBError.java: 1130 )
at oracle.jdbc.dbaccess.DBConversion.failUTF8Conv(DBConversion.java: 2261
)
at oracle.jdbc.dbaccess.DBConversion.utf8BytesToJavaChars(DBConversion.j
ava: 2061 )
at oracle.jdbc.dbaccess.DBConversion.utf8BytesToString(DBConversion.java
: 1976 )
at oracle.jdbc.dbaccess.DBConversion.CharBytesToString(DBConversion.java
: 543 )
at oracle.jdbc.ttc7.TTIoer.processWarning(TTIoer.java: 334 )
at oracle.jdbc.ttc7.O3log.receive2nd(O3log.java: 523 )
at oracle.jdbc.ttc7.TTC7Protocol.logon(TTC7Protocol.java: 278 )
at oracle.jdbc.driver.OracleConnection. < init > (OracleConnection.java: 346 )
at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.ja
va: 468 )
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java: 314 )
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at JDBC.main(JDBC.java: 9 )
javax.management.MalformedObjectNameException: Invalid character
'
' in value part of property
at javax.management.ObjectName.construct(ObjectName.java: 529 )
at javax.management.ObjectName. < init > (ObjectName.java: 1304 )
at oracle.jdbc.driver.OracleDriver.registerMBeans(OracleDriver.java: 303 )
at oracle.jdbc.driver.OracleDriver$ 1 .run(OracleDriver.java: 213 )
at java.security.AccessController.doPrivileged(Native Method)
at oracle.jdbc.driver.OracleDriver. < clinit > (OracleDriver.java: 209 )
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java: 164 )
采用9i驱动还碰到下面错误
' in value part of property
at javax.management.ObjectName.construct(ObjectName.java: 529 )
at javax.management.ObjectName. < init > (ObjectName.java: 1304 )
at oracle.jdbc.driver.OracleDriver.registerMBeans(OracleDriver.java: 303 )
at oracle.jdbc.driver.OracleDriver$ 1 .run(OracleDriver.java: 213 )
at java.security.AccessController.doPrivileged(Native Method)
at oracle.jdbc.driver.OracleDriver. < clinit > (OracleDriver.java: 209 )
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java: 164 )
java.sql.SQLException: 违反协议
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java: 134 )
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java: 179 )
at oracle.jdbc.dbaccess.DBError.check_error(DBError.java: 1160 )
at oracle.jdbc.ttc7.O3log.receive2nd(O3log.java: 548 )
at oracle.jdbc.ttc7.TTC7Protocol.logon(TTC7Protocol.java: 279 )
at oracle.jdbc.driver.OracleConnection. < init > (OracleConnection.java: 371 )
at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.ja
va: 551 )
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java: 351 )
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java: 134 )
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java: 179 )
at oracle.jdbc.dbaccess.DBError.check_error(DBError.java: 1160 )
at oracle.jdbc.ttc7.O3log.receive2nd(O3log.java: 548 )
at oracle.jdbc.ttc7.TTC7Protocol.logon(TTC7Protocol.java: 279 )
at oracle.jdbc.driver.OracleConnection. < init > (OracleConnection.java: 371 )
at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.ja
va: 551 )
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java: 351 )
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
- 最终查询资料,发现还是jdbc驱动问题,原因因该是与bug有关,因此从新从otn.oracle.com下载驱动升级解决问题。
ojdbc6.jar的驱动版本可以运行java -jar ojdbc6.jar查看,如果是Oracle 11.1.0.6.0-Production+ JDBC 4.0 compiled with JDK6,带+号就是补丁版本,否则是没有打补丁的,仍然可能出错。 - 我遇到的请况,采用10.2.0.4的jdbc驱动就没有问题了
- oracle jdbc驱动下载地址如下:
Oracle JDBC Portal
|
|||
Oracle Database 11g Release 1 (11.1.0.6) drivers | |||
Oracle Database 10g Release 2 (10.2.0.4), (10.2.0.3), (10.2.0.2), (10.2.0.1.0) drivers | |||
Oracle Database 10g (10.1.0.5), (10.1.0.4), (10.1.0.2.0) drivers | |||
Oracle9i Release 2 (9.2.0.8), (9.2.0.5), (9.2.0.4), (9.2.0.3), & (9.2.0.1) drivers | |||
Oracle9i Release 1 (9.0.1.4) & (9.0.1) drivers | |||
Oracle8i Release 2 (8.1.7) |