ORACLE11g的PASSWORD_VERSIONS导致的JBOSS无法连接数据库

时间:2022-09-09 15:15:26
我们都知道oracle 11g账户密码默认是区分大小写的,由参数sec_case_sensitive_logon控制
而且11g在dba_users里添加了一个新列PASSWORD_VERSIONS提示这个用户是由哪个版本的数据库创建的。
最近一个项目遇到问题,使用expdp/impdp做rac数据库迁移之后发现jboss连接不上数据库,报错error:data source error,但是用plsql却可以连接到数据库
后来发现迁移后的数据库用户的PASSWORD_VERSIONS为11g,原来数据库的PASSWORD_VERSIONS为10g 11g,在数据库里重新修改用户密码后jboss才能连接


在11.2.0.4数据库里创建用户,默认PASSWORD_VERSIONS为10g 11g:

[oracle@bre1 ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Mon Jul 21 12:26:14 2014

Copyright (c) 1982, 2013, Oracle. All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> show parameter sec_ca

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
sec_case_sensitive_logon boolean TRUE

SQL> create user test2 identified by test2;

User created.

SQL> select username,password,PASSWORD_VERSIONS from dba_users where username='TEST2';

USERNAME PASSWORD PASSWORD
------------------------------ ------------------------------ --------
TEST2 10G 11G

将一个10g的dmp文件导入到11g库后,发现PASSWORD_VERSIONS为10g,而且此时这个用户的密码不受sec_case_sensitive_logon控制,不区分大小写

[oracle@bre1 test]$ impdp system/manager directory=test dumpfile=1.dmp logfile=3.log schemas=test

Import: Release 11.2.0.4.0 - Production on Mon Jul 21 12:30:29 2014

Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Master table "SYSTEM"."SYS_IMPORT_SCHEMA_01" successfully loaded/unloaded
Starting "SYSTEM"."SYS_IMPORT_SCHEMA_01": system/******** directory=test dumpfile=1.dmp logfile=3.log schemas=test
Processing object type DATABASE_EXPORT/SCHEMA/USER
Processing object type DATABASE_EXPORT/SCHEMA/GRANT/SYSTEM_GRANT
Processing object type DATABASE_EXPORT/SCHEMA/ROLE_GRANT
Processing object type DATABASE_EXPORT/SCHEMA/DEFAULT_ROLE
Processing object type DATABASE_EXPORT/SCHEMA/PROCACT_SCHEMA
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/TABLE
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/TABLE_DATA
. . imported "TEST"."T3" 874.3 KB 9995 rows
. . imported "TEST"."T1" 5.234 KB 3 rows
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/STATISTICS/TABLE_STATISTICS
Job "SYSTEM"."SYS_IMPORT_SCHEMA_01" successfully completed at Mon Jul 21 12:30:34 2014 elapsed 0 00:00:03

[oracle@bre1 ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Mon Jul 21 12:20:45 2014

Copyright (c) 1982, 2013, Oracle. All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select username,password,PASSWORD_VERSIONS from dba_users where username='TEST';

USERNAME PASSWORD PASSWORD
------------------------------ ------------------------------ --------
TEST 10G

SQL> conn test/test
Connected.
SQL> conn test/TEST
Connected.
SQL> conn test/Test
Connected.

dmp另外一台11g的数据库导入到这个11g库后发现PASSWORD_VERSIONS还是10g 11g
具体不知道是什么原因造成的PASSWORD_VERSIONS变为11g,是不是11.2.0.3.0的问题,当时项目是11.2.0.3的RAC导入到11.2.0.3的RAC。
查了MOS有人遇到过类似的问题Cannot Connect To Oracle Database When Only 11G-Version Passwords Are Allowed (文档 ID 1384368.1)