Programming with JDBC and SQL

To start things off, we're going to create a table, insert some values, and query them.

Import the DriverManager and Class classes to load the JDBC driver.

>>> from java.sql import DriverManager
>>> from java.lang import Class

Load the driver using Class.forName, which dynamically loads a class into the Java Virtual Machine (JVM). (See the Java API documentation for more details.) For Microsoft Access via ODBC (or any ODBC database):

>>> Class.forName("sun.jdbc.odbc.JdbcOdbcDriver")
<jclass sun.jdbc.odbc.JdbcOdbcDriver at -416861389>

For InstantDB:

>>> Class.forName("jdbc.idbDriver")
<jclass jdbc.idbDriver at -282805662>

Just as an HTML page has an HTTP URL, so a database has a JDBC URL. The last part of the ...

Get Python Programming with the Java™ Class Libraries: A Tutorial for Building Web and Enterprise Applications with Jython now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.