Complete Example
This section shows the complete program to create, update, and select from a database using JDBC. A longer version of this code comes with the Mckoi database and can be found in directory c:\mckoi\demo\simple. The code has been split into two programs there for convenience, one to create the tables, and one to query them.
/** * Demonstrates how to use JDBC. */import java.sql.*;public class Example { public static void main(String[] args) { // Register the Mckoi JDBC Driver try { Class.forName("com.mckoi.JDBCDriver"); } catch (Exception e) { System.out.println("Can't load JDBC Driver. " + "Make sure classpath is correct"); return; } // This URL specifies we are creating a local database. The ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access