【发布时间】:2014-07-01 23:12:27
【问题描述】:
我有 oracle 用户数据库。系统在 LDAP 上有用户。我想在用户插入/更新/删除时保留用户的日志。但是如何在 jdbc 连接上将用户名或用户 ip 和用户密码传递给 oracle?
我使用 weblogic。只需一个用户和密码即可连接系统。此用户正在设置 weblogic 通用数据源。
我的 jdbc 连接类是
public class DBFactory {
private static javax.sql.DataSource dataSource = null;
public static Connection getConnection(String user, String password) {
Connection connection = null;
try {
if (dataSource == null) {
//weblogic app server
javax.naming.InitialContext ctx = new javax.naming.InitialContext();
dataSource = (javax.sql.DataSource) ctx.lookup("jdbc/XXXX");
}
connection=dataSource.getConnection();
Statement statement = connection.createStatement();
statement.execute("ALTER SESSION SET NLS_SORT=XTURKISH_AI");
statement.execute("ALTER SESSION SET NLS_COMP=LINGUISTIC");
statement.close();
return connection;
} catch (Exception ex) {
throw new DBFactoryException(ex.getMessage());
}
}
我能做什么?还是其他解决方案?
【问题讨论】:
-
请澄清。您想使用 LDAP 用户的凭据连接到数据库,或者您想知道哪个用户执行了 DML?
-
好的,我解释清楚了。每个表都有触发器,这个触发器在插入/更新/删除之后插入日志表。日志表有 activite_user 字段,默认值为 USER(Oracle 用户)但我的 jdbc 只连接一个用户(在 weblogic 服务器上设置 user= asdf)。在每个日志记录中写入activite_user = asdf。这是问题。我想使用 LDAP 用户 getconnection(user,password) 类。例如 LDAP 用户是 abc。 Oracle 用户是 abc。用户登录系统时,与该用户打开连接。不是 asdf(设置 weblogic 的数据库用户名)