当前位置: 代码迷 >> 综合 >> java.sql.SQLException: 不支持的字符集 (在类路径中添加 orai18n.jar): ZHS16GBK
  详细解决方案

java.sql.SQLException: 不支持的字符集 (在类路径中添加 orai18n.jar): ZHS16GBK

热度:61   发布时间:2024-02-04 17:14:39.0

文章目录

  • 1、报错
  • 2、解决方法

1、报错

java.sql.SQLException: 不支持的字符集 (在类路径中添加 orai18n.jar): ZHS16GBK

"C:\Program Files\Java\jdk1.8.0_161\bin\java" "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA 2017.3.7\lib\idea_rt.jar=65420:C:\Program Files\JetBrains\IntelliJ IDEA 2017.3.7\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\Java\jdk1.8.0_161\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_161\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.8.0_161\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jdk1.8.0_161\jre\lib\ext\cldrdata.jar;C:\Program Files\Java\jdk1.8.0_161\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.8.0_161\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1.8.0_161\jre\lib\ext\jfxrt.jar;C:\Program Files\Java\jdk1.8.0_161\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.8.0_161\jre\lib\ext\nashorn.jar;C:\Program Files\Java\jdk1.8.0_161\jre\lib\ext\sunec.jar;C:\Program Files\Java\jdk1.8.0_161\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.8.0_161\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.8.0_161\jre\lib\ext\sunpkcs11.jar;C:\Program Files\Java\jdk1.8.0_161\jre\lib\ext\zipfs.jar;C:\Program Files\Java\jdk1.8.0_161\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.8.0_161\jre\lib\jce.jar;C:\Program Files\Java\jdk1.8.0_161\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.8.0_161\jre\lib\jfxswt.jar;C:\Program Files\Java\jdk1.8.0_161\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_161\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.8.0_161\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.8.0_161\jre\lib\resources.jar;C:\Program Files\Java\jdk1.8.0_161\jre\lib\rt.jar;D:\gitProject\test02\target\classes;D:\gitProject\test02\lib\spring-aspects-5.2.3.RELEASE.jar;D:\gitProject\test02\lib\spring-context-support-5.2.3.RELEASE.jar;D:\gitProject\test02\lib\spring-aop-5.2.3.RELEASE.jar;D:\gitProject\test02\lib\spring-expression-5.2.3.RELEASE.jar;D:\gitProject\test02\lib\spring-instrument-5.2.3.RELEASE.jar;D:\gitProject\test02\lib\spring-beans-5.2.3.RELEASE.jar;D:\gitProject\test02\lib\spring-jms-5.2.3.RELEASE.jar;D:\gitProject\test02\lib\spring-jdbc-5.2.3.RELEASE.jar;D:\gitProject\test02\lib\spring-context-5.2.3.RELEASE.jar;D:\gitProject\test02\lib\spring-oxm-5.2.3.RELEASE.jar;D:\gitProject\test02\lib\spring-core-5.2.3.RELEASE.jar;D:\gitProject\test02\lib\spring-orm-5.2.3.RELEASE.jar;D:\gitProject\test02\lib\spring-messaging-5.2.3.RELEASE.jar;D:\gitProject\test02\lib\aopalliance-1.0.jar;D:\gitProject\test02\lib\commons-logging-1.2.jar;D:\gitProject\test02\lib\spring-tx-5.2.3.RELEASE.jar;D:\gitProject\test02\lib\spring-test-5.2.3.RELEASE.jar;D:\soft\apache-maven-3.6.1\repository\repository1\org\springframework\spring-aop\4.0.4.RELEASE\spring-aop-4.0.4.RELEASE.jar;D:\soft\apache-maven-3.6.1\repository\repository1\aopalliance\aopalliance\1.0\aopalliance-1.0.jar;D:\soft\apache-maven-3.6.1\repository\repository1\org\springframework\spring-beans\4.0.4.RELEASE\spring-beans-4.0.4.RELEASE.jar;D:\soft\apache-maven-3.6.1\repository\repository1\org\springframework\spring-core\4.0.4.RELEASE\spring-core-4.0.4.RELEASE.jar;D:\soft\apache-maven-3.6.1\repository\repository1\commons-logging\commons-logging\1.1.3\commons-logging-1.1.3.jar;D:\soft\apache-maven-3.6.1\repository\repository1\org\aspectj\aspectjrt\1.9.1\aspectjrt-1.9.1.jar;D:\soft\apache-maven-3.6.1\repository\repository1\org\apache\geronimo\bundles\aspectjweaver\1.6.8_2\aspectjweaver-1.6.8_2.jar;D:\soft\apache-maven-3.6.1\repository\repository1\com\oracle\ojdbc\ojdbc8\19.3.0.0\ojdbc8-19.3.0.0.jar;D:\soft\apache-maven-3.6.1\repository\repository1\com\oracle\ojdbc\ucp\19.3.0.0\ucp-19.3.0.0.jar;D:\soft\apache-maven-3.6.1\repository\repository1\com\oracle\ojdbc\oraclepki\19.3.0.0\oraclepki-19.3.0.0.jar;D:\soft\apache-maven-3.6.1\repository\repository1\com\oracle\ojdbc\osdt_cert\19.3.0.0\osdt_cert-19.3.0.0.jar;D:\soft\apache-maven-3.6.1\repository\repository1\com\oracle\ojdbc\osdt_core\19.3.0.0\osdt_core-19.3.0.0.jar;D:\soft\apache-maven-3.6.1\repository\repository1\com\oracle\ojdbc\simplefan\19.3.0.0\simplefan-19.3.0.0.jar;D:\soft\apache-maven-3.6.1\repository\repository1\com\oracle\ojdbc\ons\19.3.0.0\ons-19.3.0.0.jar;D:\soft\apache-maven-3.6.1\repository\repository1\com\alibaba\druid\1.1.20\druid-1.1.20.jar;D:\soft\apache-maven-3.6.1\repository\repository1\log4j\log4j\1.2.17\log4j-1.2.17.jar" com.test01.jdbc.JdbcExample
java.sql.SQLException: 不支持的字符集 (在类路径中添加 orai18n.jar): ZHS16GBKat oracle.sql.CharacterSetUnknown.failCharsetUnknown(CharacterSetFactoryThin.java:233)at oracle.sql.CharacterSetUnknown.convert(CharacterSetFactoryThin.java:194)at oracle.jdbc.driver.PhysicalConnection.throughDbCharset(PhysicalConnection.java:10365)at oracle.jdbc.driver.PhysicalConnection.enquoteIdentifier(PhysicalConnection.java:10442)at oracle.jdbc.driver.OracleStatement.enquoteIdentifier(OracleStatement.java:6452)at oracle.jdbc.driver.OracleStatement.getColumnIndex(OracleStatement.java:3853)at oracle.jdbc.driver.InsensitiveScrollableResultSet.findColumn(InsensitiveScrollableResultSet.java:270)at oracle.jdbc.driver.GeneratedResultSet.getInt(GeneratedResultSet.java:556)at com.test01.jdbc.JdbcExample.getProduct(JdbcExample.java:25)at com.test01.jdbc.JdbcExample.main(JdbcExample.java:12)
nullProcess finished with exit code 0

2、解决方法

根据报错内容就可以看出:缺少orai18n.jar的jar包。

我是用的maven管理的jar包,本来就有ojdbc的依赖,所以于是在pom文件中加入orai18n相关依赖即可。

        <!--oracle驱动--><dependency><groupId>com.oracle.ojdbc</groupId><artifactId>ojdbc8</artifactId><version>19.3.0.0</version></dependency><dependency><groupId>cn.easyproject</groupId><artifactId>orai18n</artifactId><version>12.1.0.2.0</version></dependency>
  相关解决方案