Permalink
Browse files

Oracle adapter change to catch connection errors and reraise a Sequel…

…::DatabaseDisconnectError.
  • Loading branch information...
1 parent 35bd9ac commit 2e8753b66849c8519771814c19e25514d91233d3 @jdunphy jdunphy committed with Dec 3, 2008
Showing with 17 additions and 3 deletions.
  1. +17 −3 lib/sequel_core/adapters/oracle.rb
@@ -6,6 +6,12 @@ module Oracle
class Database < Sequel::Database
include DatabaseMethods
set_adapter_scheme :oracle
+
+ # ORA-00028: your session has been killed
+ # ORA-01012: not logged on
+ # ORA-03113: end-of-file on communication channel
+ # ORA-03114: not connected to ORACLE
+ CONNECTION_ERROR_CODES = [ 28, 1012, 3113, 3114 ]
def connect(server)
opts = server_opts(server)
@@ -28,9 +34,17 @@ def dataset(opts = nil)
def execute(sql, opts={})
log_info(sql)
synchronize(opts[:server]) do |conn|
- r = conn.exec(sql)
- yield(r) if block_given?
- r
+ begin
+ r = conn.exec(sql)
+ yield(r) if block_given?
+ r
+ rescue OCIException => e
+ if CONNECTION_ERROR_CODES.include?(e.code)
+ raise(Sequel::DatabaseDisconnectError)
+ else
+ raise
+ end
+ end
end
end
alias_method :do, :execute

0 comments on commit 2e8753b

Please sign in to comment.