Method: MySQL#query

Defined in:
lib/DrbDB/MyMultiSQL/jdbc.rb,
lib/DrbDB/MyMultiSQL/mysql-ruby.rb

#query(sql) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/DrbDB/MyMultiSQL/jdbc.rb', line 25

def query(sql)
  return nil if sql.nil? or sql.length ==0
  begin
    stmt = @conn.createStatement
    res = stmt.executeQuery(sql)
  rescue SQLException => err
#     case err
#       when 2006, 2013
#         einfo("connection dropped: retrying")
#         reconnect
#         retry
#       when 1062
        #duplicate
#         res=-1
#       else
        eerror("#{err} in\n#{sql}")
        raise "#{err}\n#{sql}\n"
#     end
  rescue CommunicationsException => e
        edebug("comm error")
        eerror("#{e} in\n#{sql}")
        raise "#{e}\n#{sql}\n"
  rescue =>e
        edebug("other error: #{e.class.name}")
        eerror("#{err} in\n#{sql}")
  end
  return res
end