【问题标题】:DBD::Oracle How to set v$session.program BEFORE connectDBD::Oracle 如何在连接前设置 v$session.program
【发布时间】:2016-02-18 04:44:14
【问题描述】:

我必须使用 DBD::Oracle 连接到具有 LOGON 触发器的 Oracle 数据库,该触发器在登录时验证我的 v$session.program。

我试过了:

use strict;
use warnings;

use DBI;

DBI->connect ('dbi:Oracle:host=<ip>;sid=<sid>', 'test', 'TEST', 
    { ora_module_name => 'My Program'}) || die DBI::errstr;

但这不起作用,因为 DBD::Oracle 直到连接之后才设置 v$session.program。

但是,JDBC 确实支持在连接前设置,通过:

Properties props = new Properties();
props.setProperty("user", username);
props.setProperty("password", password);
props.put("v$session.program", "My Program");
Class driver = Class.forName(driverClass);

但我没有使用 Java。我正在使用 Perl。有什么建议吗?!

[更新]

在进程上运行“strace”确定 DBD::Oracle 模块正在执行以下操作:

open("/proc/self/cmdline", O_RDONLY) = 4 读(4, "perl\0test.pl\0", 255) = 13

所以是的,理论上我可以创建一个名为“我的程序”的脚本(或软链接)并将其用作命令行来运行我的文件。但这在“非常悲伤而且一点也不好”的等级上相当高。 :(

【问题讨论】:

  • 建议删除 Java 标记,因为这纯粹是 Perl 和 Oracle 连接/属性/触发器讨论。

标签: java oracle perl session


【解决方案1】:

http://docs.oracle.com/cd/B19306_01/server.102/b14237/dynviews_2088.htm

PROGRAM     VARCHAR2(48)    Operating system program name

这意味着您应该以某种方式将二进制文件重命名为预期值。

这样做有一些提示: http://www.perlmonks.org/?node_id=500714

perldoc perlvar:

   $0      Contains the name of the program being executed.

           On some (but not all) operating systems assigning to $0
           modifies the argument area that the "ps" program sees. On some
           platforms you may have to use special "ps" options or a
           different "ps" to see the changes. Modifying the $0 is more
           useful as a way of indicating the current program state than it
           is for hiding the program you're running.

...

【讨论】:

  • 标记为正确。但是...实际上这是不可能的。请参阅下面的我的自我评论。
猜你喜欢
  • 1970-01-01
  • 2011-08-24
  • 2020-01-12
  • 1970-01-01
  • 1970-01-01
  • 2011-03-24
  • 2016-01-05
  • 1970-01-01
  • 2016-11-11
相关资源
最近更新 更多