title: Jython - Trying to connect to database results in java.sq l.SQLException: No suitable driver found
body: <p>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.</p>
  
  <p>I'm trying to connect to an Oracle database to query some values.  Here's my code:</p>
  
  <pre><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)
  </code></pre>
  
  <p>Running this results in the following error (note: real hostname, port, and sid removed):</p>
  
  <pre><code>ERROR: Cannot connect to database host port sid: java.sql.SQLException: No suitable driver found for jdbc:oracle:thin:@host:port:sid.
  </code></pre>
  
  <p>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)</p>
  
  <p>Process args:</p>
  
  <pre><code>argv[21]: -classpath
  argv[22]: :&lt;install_path&gt;/atlassian-confluence-4.3.1/lib/ojdbc6.jar:&lt;install_path&gt;/atlassian-confluence-4.3.1/bin/bootstrap.jar
  </code></pre>
  
  <p>catalina.out:</p>
  
  <pre><code>*sys-package-mgr*: processing new jar, '&lt;install_path&gt;/atlassian-confluence-4.3.1/lib/ojdbc6.jar'
  </code></pre>
  
  <p>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?</p>
  
  <ul>
  <li>JDK: Sun 1.6.0_33-b03</li>
  <li>Jython: 2.5.2 </li>
  <li>Confluence: 4.3.1 </li>
  <li>Script Plugin: 4.1.0 </li>
  <li>OS: SunOS 5.10</li>
  <li>App Server: Apache Tomcat/6.0.32</li>
  </ul>