我很难连接到Oracle DB,已经阅读了很多内容,但对结果没有帮助 我有远程Oracle DB,我使用DBVisualizer设置连接来连接它,如下所示:
DB Type : Oracle
Driver (jdbc) : Oracle thin
Database URL: jdbc:oracle:thin:@10.10.100.10:1521/VVV.LOCALDOMAIN
UserIdf: SomeUser
Pass: SomePass
连接正常。
我在Ruby中所做的是:
require 'oci8'
require 'dbi'
...
conn = OCI8.new('SomeUser','SomePass','//10.10.100.10:1521/VVV.LOCALDOMAIN')
...
我得到的是:
ORA-12545: Connect failed because target host or object does not exist
oci8.c:360:in oci8lib.so
答案 0 :(得分:8)
第三个参数需要是TNS主机名,如果你使用SQL plus它也是连接字符串中的第三个参数,你也可以在oracle地图的tnsnames.ora文件中找到它
SQLPlus中的 :连接用户/密码@ hostname;
in oci8: conn = OCI8.new(' SomeUser',' SomePass',主机名)
这是一个工作样本,对当然的参数进行了模糊处理
require 'oci8'
oci = OCI8.new('****','***','****.***')
oci.exec('select * from table') do |record|
puts record.join(',')
end
答案 1 :(得分:-3)
meetings = [
Meeting(0, 1),
Meeting(1, 2),
Meeting(2, 3),
Meeting(3, 5),
Meeting(4, 5)
]
print(max_meetings(meetings)) # => 4
答案 2 :(得分:-4)
require 'oci8'
oci = OCI8.new('system','prasad','127.0.0.1:1521')
oci.exec("insert into states1 values(1,'prasad','visakhapatnam')")
oci.exec("commit")
oci.exec('select * from states1') do |record|
puts record.join(',')
end