我正在使用此站點上提供的課程:https ://www.oracle.com/technetwork/articles/dsl/jruby-oracle11g-330825.html我正在設(shè)置 SSL,我需要將 java.util.properties 列表傳遞給驅(qū)動程序管理器。我想我會做這樣的事情......# 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 中創(chuàng)建屬性并傳遞它們。有任何想法嗎?
1 回答

SMILET
TA貢獻(xiàn)1796條經(jīng)驗 獲得超4個贊
將java.util.PropertiesJava 類視為 Ruby 類(其所有API方法均可用)
另外,如果您查看文檔Properties extends Hashtable并且Hashtable是 (implements) Map。
JRuby 為所有地圖類型提供擴(kuò)展,使其非常像 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
提交
取消