不支持的字符集 (在类路径中添加 orai18n.jar): ZHS16GBK
不支持的字符集 (在类路径中添加 orai18n.jar): ZHS16GBK
报错图示:
报错内容:
Exception in thread "main" java.sql.SQLException: 不支持的字符集 (在类路径中添加 orai18n.jar): ZHS16GBK
at oracle.sql.CharacterSetUnknown.failCharsetUnknown(CharacterSetFactoryThin.java:233)
at oracle.sql.CharacterSetUnknown.convert(CharacterSetFactoryThin.java:194)
at oracle.jdbc.driver.PhysicalConnection.throughDbCharset(PhysicalConnection.java:10402)
at oracle.jdbc.driver.PhysicalConnection.enquoteIdentifier(PhysicalConnection.java:10479)
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.getString(GeneratedResultSet.java:596)
at com.courage.apacheDBUtils.DBUtilsTest.main(DBUtilsTest.java:17)
解决方案:
根据报错信息提示,导入orai18n.jar或者在pom.xml中添加orai18n.jar的依赖
<!-- https://mvnrepository.com/artifact/com.oracle.database.nls/orai18n -->
<dependency>
<groupId>com.oracle.database.nls</groupId>
<artifactId>orai18n</artifactId>
<version>19.7.0.0</version>
</dependency>