我正在使用此站点上提供的课程:https ://www.oracle.com/technetwork/articles/dsl/jruby-oracle11g-330825.html我正在设置 SSL,我需要将 java.util.properties 列表传递给驱动程序管理器。我想我会做这样的事情......# jdbc_connection.rbrequire 'java'java_import 'oracle.jdbc.OracleDriver'java_import 'java.sql.DriverManager'java_import 'java.util.Properties' #<---Import hereclass OracleConnection @conn = nil def initialize (url) @url = url #I want to create the array of properties here and populate it with my SSL properties. I'm really lost here. # Load driver class oradriver = OracleDriver.new DriverManager.registerDriver oradriver #I want to pass the Properties to DriverManager. @conn = DriverManager.get_connection url, properties @conn.auto_commit = false end我很想知道如何在 ruby 中创建属性并传递它们。有任何想法吗?
1 回答
SMILET
TA贡献1796条经验 获得超4个赞
将java.util.PropertiesJava 类视为 Ruby 类(其所有API方法均可用)
另外,如果您查看文档Properties extends Hashtable并且Hashtable是 (implements) Map。
JRuby 为所有地图类型提供扩展,使其非常像 Ruby Hash。
properties = java.util.Properties.new
properties.put 'a.ssl.key', 'A-VALUE' # Java style (put inherited from Hashtable)
properties['another.ssl.key'] = 'ANOTHER' # Ruby Hash style
添加回答
举报
0/150
提交
取消