I'm using the Confluence Script Plugin to write Jython macros in Confluence. I have some code that recently stopped working after an upgrade to Confluence and the Plugin. I've tried various possible solutions found here on SO and the web without any luck.
I'm trying to connect to an Oracle database to query some values. Here's my code:
import sys
from oracle.jdbc.driver import OracleDriver
from java.sql import DriverManager, SQLRecoverableException
def connect(user, pw, sid, host, port):
connection = None
DriverManager.registerDriver(OracleDriver())
try:
connection = DriverManager.getConnection("jdbc:oracle:thin:@"+host+":"+port+":"+sid, user, pw)
except SQLRecoverableException, e:
print 'ERROR: Cannot connect to database %s %s %s: %s.' % (host, port, sid, e)
except:
print 'ERROR: Cannot connect to database %s %s %s: %s.' % (host, port, sid, sys.exc_info()[1])
return connection
conn = connect(db_user, db_pw, db_sid, db_host, db_port)
Running this results in the following error (note: real hostname, port, and sid removed):
ERROR: Cannot connect to database host port sid: java.sql.SQLException: No suitable driver found for jdbc:oracle:thin:@host:port:sid.
This error made me think that ojdbc6.jar couldn't be found or isn't in the right directory. Just in case, I explicitly added it to the classpath. This still didn't work. After adding it to the classpath, I verified that the classpath is properly being set by checking the process args and I see that ojdbc6.jar is being processed in catalina.out. (note: real install path removed)
Process args:
argv[21]: -classpath
argv[22]: :<install_path>/atlassian-confluence-4.3.1/lib/ojdbc6.jar:<install_path>/atlassian-confluence-4.3.1/bin/bootstrap.jar
catalina.out:
*sys-package-mgr*: processing new jar, '<install_path>/atlassian-confluence-4.3.1/lib/ojdbc6.jar'
I've also verified that we're currently using jdk1.6.0_33, so ojdbc6.jar should be the right thin client. Anybody know what could be causing the error?
- JDK: Sun 1.6.0_33-b03
- Jython: 2.5.2
- Confluence: 4.3.1
- Script Plugin: 4.1.0
- OS: SunOS 5.10
- App Server: Apache Tomcat/6.0.32