`

org.apache.commons.dbcp.DbcpException: java.sql.SQLException: 不能在 UTF8 和 UCS2 之间

 
阅读更多

今天生产环境tomcat启动后,用户登录时系统报错:java.sql.SQLException: 不能在 UTF8 和 UCS2 之间转换: failUTF8Conv

经确认数据库、程序、TOMCAT均未进行示改动。

在网上查询有说是oracle jdbc驱动的问题,但我本地使用ojdbc14.jar的驱动仍不行,

参考:http://blog.csdn.net/dacong910/article/details/5432245

本地程序连生产环境数据库调试:

 

DBCP borrowObject failed: java.sql.SQLException: 不能在 UTF8 和 UCS2 之间转换: failUTF8Conv
DBCP borrowObject failed: java.sql.SQLException: 不能在 UTF8 和 UCS2 之间转换: failUTF8Conv
DBCP borrowObject failed: java.sql.SQLException: 不能在 UTF8 和 UCS2 之间转换: failUTF8Conv
org.apache.commons.dbcp.DbcpException: java.sql.SQLException: 不能在 UTF8 和 UCS2 之间转换: failUTF8Conv
	at org.apache.commons.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:85)
	at org.apache.commons.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:184)
	at org.apache.commons.pool.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:722)
	at org.apache.commons.dbcp.AbandonedObjectPool.borrowObject(AbandonedObjectPool.java:117)
	at org.apache.commons.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:108)
	at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:312)
	at com.eclink.util.DBUtil.getNewConnection(DBUtil.java:160)
	at com.eclink.util.DBUtil.<init>(DBUtil.java:133)
	at com.eclink.util.DBUtil.<init>(DBUtil.java:99)
	at com.eclink.dectr.model.sys.OfficePostDAO.getUserInfo(OfficePostDAO.java:93)
	at com.eclink.dectr.controller.sys.LogonValidatorAction.login(LogonValidatorAction.java:72)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:324)
	at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:280)
	at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:216)
	at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
	at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
	at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1480)
	at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:524)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:284)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:204)
	at com.eclink.dectr.filter.ActionFilter.doFilter(ActionFilter.java:84)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:233)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:204)
	at com.eclink.dectr.filter.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:110)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:233)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:204)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:257)
	at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:567)
	at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:245)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:199)
	at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:567)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:184)
	at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:164)
	at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:149)
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:567)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:156)
	at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:567)
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:972)
	at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:206)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:833)
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:732)
	at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:619)
	at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:688)
	at java.lang.Thread.run(Thread.java:534)
Caused by: 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.java: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.java:468)
	at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:314)
	at org.apache.commons.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:83)
	... 52 more
DBCP borrowObject failed: java.sql.SQLException: 不能在 UTF8 和 UCS2 之间转换: failUTF8Conv

 

发现具体异常是DBCP组件里面抛出来的,参考文章中有一句话:

“后话:应该是因为数据库的密码策略,增加了一步校验的功能,而老驱动则不能识别这个校验;”

刚好我发现,当使用plsql dev连接生产环境时会提示密码即将过期,询问是否要修改密码。于是诊断应该是这个密码校验引起的,将数据库修改一下,再改回来,重启TOMCAT,应用正常。

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics