如何在WINDOWS中更改TOMCAT的默认区域设置?

时间:2016-01-16 14:16:06

标签: java oracle internationalization tomcat8 jdbcrealm

从照片中可以看出,伊朗已定位。

enter image description here

我在“%CATALINA_HOME%\ conf \ server.xml”中使用了realm标记。

 <Realm  className="org.apache.catalina.realm.JDBCRealm"
                driverName="oracle.jdbc.driver.OracleDriver"
                connectionURL="jdbc:oracle:thin:@localhost:1521:xe"
                connectionName="Arash" connectionPassword="who"
                userTable="users" userNameCol="USER_NAME" userCredCol="USER_PASS"
                userRoleTable="USER_ROLES" roleNameCol="ROLE_NAME"  />

当TOMCAT运行并连接到数据库时,会出现以下错误。

java.sql.SQLException: Locale not recognized
    at oracle.jdbc.driver.T4CTTIoauthenticate.setSessionFields(T4CTTIoauthenticate.java:1059)
    at oracle.jdbc.driver.T4CTTIoauthenticate.<init>(T4CTTIoauthenticate.java:261)
    at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:565)
    at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:715)
    at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:385)
    at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:30)
    at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:564)
    at org.apache.catalina.realm.JDBCRealm.open(JDBCRealm.java:663)
    at org.apache.catalina.realm.JDBCRealm.startInternal(JDBCRealm.java:726)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:155)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:899)
    at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:155)
    at org.apache.catalina.core.StandardService.startInternal(StandardService.java:441)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:155)
    at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:769)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:155)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:649)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:351)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:485)

我将此代码放入“%CATALINA_HOME%\ bin \ catalina.bat”

set -Duser.language=en -Duser.country=US

仍然发生错误。

1 个答案:

答案 0 :(得分:1)

您需要为用户设置区域,而不是设置国家/地区。所以正确的java opts将是:-Duser.language=en -Duser.region=US