码迷,mamicode.com
首页 > 数据库 > 详细

oracle无密码登录

时间:2018-02-05 14:25:56      阅读:227      评论:0      收藏:0      [点我收藏+]

标签:tor   manager   over   throws   权限   方式   create   连接服务器   版本   

oracle wallet使用与维护

从Oracle10gR2开始, 通过使用Oracle Wallet达到任意用户不使用密码登录数据库(非操作系统认证方式),这对于用脚本登录数据库进行操作来说是非常有用的;尤其对于企业安全要求很高,不希望用户名和密码明文存在配置文件中,而且对于密码的维护是极为方便的,比如我把wallet放在指定路径下,当修改密码时,只需统一覆盖wallet即可,对于有大量应用服务器尤为方便。

C:\app\Administrator\virtual\product\12.2.0\dbhome_2\bin>mkstore -wrl e:\wallet -create
Oracle Secret Store Tool: 版本 12.2.0.1.0
版权所有 (c) 2004, 2016, Oracle 和/或其子公司。保留所有权利。

输入口令:
PKI-01002: 口令无效。口令至少要有 8 个字符并且应该同时包含字母和数字 (或特殊字符)。
输入口令:
PKI-01002: 口令无效。口令至少要有 8 个字符并且应该同时包含字母和数字 (或特殊字符)。
C:\app\Administrator\virtual\product\12.2.0\dbhome_2\bin>mkstore -wrl e:\wallet -create
Oracle Secret Store Tool: 版本 12.2.0.1.0
版权所有 (c) 2004, 2016, Oracle 和/或其子公司。保留所有权利。

输入口令:
再次输入口令:

e:\wallet>dir
驱动器 E 中的卷是 新加卷
卷的序列号是 A80D-EB59

e:\wallet 的目录

2018/02/05 10:34 <DIR> .
2018/02/05 10:34 <DIR> ..
2018/02/05 10:34 194 cwallet.sso
2018/02/05 10:34 0 cwallet.sso.lck
2018/02/05 10:34 149 ewallet.p12
2018/02/05 10:34 0 ewallet.p12.lck
4 个文件 343 字节
2 个目录 200,386,322,432 可用字节
tnsping.ora加入
scott_10.8.5.206 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.8.5.206)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME =newtest)
)
)
C:\app\Administrator\virtual\product\12.2.0\dbhome_2\bin>mkstore -wrl e:\wallet -createCredential scott_10.8.5.206 c##scott tiger
Oracle Secret Store Tool: 版本 12.2.0.1.0
版权所有 (c) 2004, 2016, Oracle 和/或其子公司。保留所有权利。

输入 Wallet 口令:

e:\wallet>sqlplus /@scott_10.8.5.206

SQL*Plus: Release 12.2.0.1.0 Production on 星期一 2月 5 11:08:58 2018

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

上次成功登录时间: 星期一 2月 05 2018 11:08:36 +08:00

连接到:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
在客户端使用wallet无密码登录的步骤:

1.创建wallet(tnsname.ora里面的连接串,sqlnet.ora文件内容都要复制到客户端)
2.把wallet复制到客户端指定路径(注意文件权限和属主)
3.修改客户端的tnsname.ora文件里连接服务器的连接串为创建时的连接串,在sqlnet.ora文件里添加如下内容:
WALLET_LOCATION=(SOURCE=(METHOD=FILE)(METHOD_DATA=(DIRECTORY=e:\wallet)))
SQLNET.WALLET_OVERRIDE = TRUE
4.在sqlplus无密码等里测试
sqlplus /@scott_10.8.5.206

在jdbc里连接数据库密码形式如下:
public static Connection getConnection() throws SQLException {
DriverManager.registerDriver(new OracleDriver());
Connection conn = DriverManagerbr/>.getConnection("jdbc:oracle:oci:/@scott_10.8.5.206");
conn.setAutoCommit(false);
return conn;
}

oracle无密码登录

标签:tor   manager   over   throws   权限   方式   create   连接服务器   版本   

原文地址:http://blog.51cto.com/shurk/2068927

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!