title: JayDeBeApi triggers java.sql.SQLException: No suitable driver found
body: <p>I'm trying to connect to a <strong>Teradata</strong> database in <strong>Python 3</strong> using the package <strong>JayDeBeApi</strong>. This is part of an API project using <strong>Flask</strong> and <strong>Flask-Restplus</strong></p>
  
  <p>Here is a minimal working example to reproduce the issue.
  In a terminal Window, type the following commands to setup your workstation:</p>
  
  <pre><code># Install JVM
  sudo apt-get install default-jre
  
  # Create Python virtual environment
  sudo apt-get install python3-venv
  python3 -m venv jdbc
  source jdbc/bin/activate
  
  # Install Python packages in virtual environment
  pip3 install --upgrade pip
  pip3 install jaydebeapi
  pip3 install flask
  </code></pre>
  
  <p>Create a file app.py with the following content:</p>
  
  <pre><code>from flask import Flask
  import jaydebeapi
  
  app = Flask(__name__)
  
  
  def get_jdbc_connection():
      connection = jaydebeapi.connect(
          'com.teradata.jdbc.TeraDriver',
          'jdbc:teradata://edw-dev.company.org',
          {'user': 'LOGIN', 'password': 'PASSWORD', 'tmode': 'TERA', 'charset': 'UTF8'},
          '/home/alexis/teradataDriverJdbc.jar')
      return connection
  
  
  @app.route('/hello/')
  def hello_world():
      print('Init second connection')
      get_jdbc_connection()
      print('Success')
      return 'Hello world!'
  
  
  if __name__ == '__main__':
      print('Init connection')
      test_connection = get_jdbc_connection()
      test_connection.close()
      print('Init connection closed')
      app.run(host='localhost', port=5000, threaded=True, debug=True)
  </code></pre>
  
  <p>In your terminal windows with the virtual environment activated, type the following:</p>
  
  <pre><code>python3
  &gt;&gt;&gt; import app
  &gt;&gt;&gt; app.get_jdbc_connection()
  &lt;jaydebeapi.Connection object at 0x7f28ecb2ebe0&gt;
  </code></pre>
  
  <p>The snippet above works and the method <code>get_jdbc_connection()</code> returns a connection object.
  Now try running it with Flask. In a terminal window with the virtual environment activated, type the following:</p>
  
  <pre><code>python3 app.py
  Init connection
  Init connection closed
   * Running on http://localhost:5000/ (Press CTRL+C to quit)
   * Restarting with stat
  Init connection
  Init connection closed
   * Debugger is active!
   * Debugger PIN: 301-429-987
  </code></pre>
  
  <p>In your browser, navigate to <a href="http://localhost:5000/hello/" rel="nofollow noreferrer">http://localhost:5000/hello/</a>
  You will get the following error message which is the same as the one I pasted in my first message above:</p>
  
  <p><a href="https://i.stack.imgur.com/lOhRG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lOhRG.png" alt="enter image description here"></a></p>
  
  <pre><code>Init second connection
  127.0.0.1 - - [08/Mar/2018 16:00:30] "GET /hello/ HTTP/1.1" 500 -
  Traceback (most recent call last):
    File "/home/alexis/dq/lib/python3.5/site-packages/flask/app.py", line 2000, in __call__
      return self.wsgi_app(environ, start_response)
    File "/home/alexis/dq/lib/python3.5/site-packages/flask/app.py", line 1991, in wsgi_app
      response = self.make_response(self.handle_exception(e))
    File "/home/alexis/dq/lib/python3.5/site-packages/flask/app.py", line 1567, in handle_exception
      reraise(exc_type, exc_value, tb)
    File "/home/alexis/dq/lib/python3.5/site-packages/flask/_compat.py", line 33, in reraise
      raise value
    File "/home/alexis/dq/lib/python3.5/site-packages/flask/app.py", line 1988, in wsgi_app
      response = self.full_dispatch_request()
    File "/home/alexis/dq/lib/python3.5/site-packages/flask/app.py", line 1641, in full_dispatch_request
      rv = self.handle_user_exception(e)
    File "/home/alexis/dq/lib/python3.5/site-packages/flask/app.py", line 1544, in handle_user_exception
      reraise(exc_type, exc_value, tb)
    File "/home/alexis/dq/lib/python3.5/site-packages/flask/_compat.py", line 33, in reraise
      raise value
    File "/home/alexis/dq/lib/python3.5/site-packages/flask/app.py", line 1639, in full_dispatch_request
      rv = self.dispatch_request()
    File "/home/alexis/dq/lib/python3.5/site-packages/flask/app.py", line 1625, in dispatch_request
      return self.view_functions[rule.endpoint](**req.view_args)
    File "/home/alexis/app.py", line 19, in hello_world
      get_jdbc_connection()
    File "/home/alexis/app.py", line 12, in get_jdbc_connection
      '/home/alexis/teradataDriverJdbc.jar')
    File "/home/alexis/dq/lib/python3.5/site-packages/jaydebeapi/__init__.py", line 381, in connect
      jconn = _jdbc_connect(jclassname, url, driver_args, jars, libs)
    File "/home/alexis/dq/lib/python3.5/site-packages/jaydebeapi/__init__.py", line 199, in _jdbc_connect_jpype
      return jpype.java.sql.DriverManager.getConnection(url, *dargs)
  jpype._jexception.java.sql.SQLExceptionPyRaisable: java.sql.SQLException: No suitable driver found for jdbc:teradata://edw-dev.company.org
  </code></pre>
  
  <p><em>Remark:</em> I have also created an issue on the Github project: <a href="https://github.com/baztian/jaydebeapi/issues/66" rel="nofollow noreferrer">https://github.com/baztian/jaydebeapi/issues/66</a></p>
  
  <p><em>Edit:</em> Following the recommendation of baztian, I have raised the issue on the jPype Github project: <a href="https://github.com/originell/jpype/issues/290" rel="nofollow noreferrer">https://github.com/originell/jpype/issues/290</a></p>