I'm working with jruby and I'm making calls to a DB2/BIGSQL database via the db2jcc4.jar file. I was making connections perfectly fine both inserts and selects, and then all of a sudden I started getting the error "uninitialized constant DriverManager."
The file db2jcc4.jar is readable and has the correct permissions. I even went back to a previously working, earlier version of the code and I get the same error. The only notable change is that the server was restarted.
require 'java'
java_import 'com.ibm.db2.jcc.DB2Driver'
java_import 'java.util.Properties'
url = "jdbc:db2://SERVER-REMOVED:PORT_REMOVED/BIGSQL"
output, rset, stmt, conn = nil
begin
properties = java.util.Properties.new
properties['user'] = 'USER REMOVED'
properties['password'] = 'PASSWORD REMOVED'
# Load driver class
driver = DB2Driver.new
DriverManager.registerDriver driver #this comes out to nil
regDrivers = DriverManager.getDrivers
conn = DriverManager.get_connection url, properties
...
Any idea what happened?
You probably need to import the DriverManager class
java_import 'java.sql.DriverManager'