Java JRuby OJDBC,无错误,但插入不';你不来吗?
我一直在关注来自Oracle的JDBC驱动程序,并将其与Oracle数据库和JRuby一起使用。我有所需的JRuby连接器类,并且修改了它们的一些代码。我只想做一个简单的insert语句并从脚本中执行它。一旦这样做了,我可能要做10+000次 我使用的是oracle数据库11g。CentOS 7.2 x64 这是我做这项工作的代码:Java JRuby OJDBC,无错误,但插入不';你不来吗?,java,ruby,jdbc,oracle11g,jruby,Java,Ruby,Jdbc,Oracle11g,Jruby,我一直在关注来自Oracle的JDBC驱动程序,并将其与Oracle数据库和JRuby一起使用。我有所需的JRuby连接器类,并且修改了它们的一些代码。我只想做一个简单的insert语句并从脚本中执行它。一旦这样做了,我可能要做10+000次 我使用的是oracle数据库11g。CentOS 7.2 x64 这是我做这项工作的代码: def insert_row insert_stmt = nil begin conn = OracleConnection.create(@dbuser, @
def insert_row
insert_stmt = nil
begin
conn = OracleConnection.create(@dbuser, @dbpass, @dburl)
insert_sql = <<-EOH
INSERT INTO TESTTABLE2(COLUMN1)
VALUES('JRUBY')
EOH
puts insert_sql
insert_stmt = conn.prepare_statement(insert_sql)
insert_stmt.execute
rescue
puts "\n** Error occured **\n"
puts "Failed executing Oracle demo from JRuby ", $!, "\n"
ensure
# We have to ensure everything is closed here.
if (!insert_stmt.nil?)
insert_stmt.close
end
end
end
def插入_行
插入\u stmt=nil
开始
conn=OracleConnection.create(@dbuser、@dbpass、@dburl)
insert_sql=如果您使用的是您提供的链接中的示例代码,那么它在代码中的某个地方有@conn.auto_commit=false
,该示例显示了在insert_stmt.execute
之后使用conn.commit
,因此这很可能是您需要执行的操作
简言之,添加缺少的conn.commit
call.是的,对此我很抱歉。我花了一上午的时间试图弄明白这一点,我在这里发布后才发现这一点。谢谢你。