package databaseexample; import java.sql.*; public class DatabaseExampleClass { public static void main(String[] args) { Connection connection = null; try { // locate the driver Class.forName("org.gjt.mm.mysql.Driver"); // create the connection connection = DriverManager.getConnection("jdbc:mysql://james.cedarville.edu/test", "cs3610", ""); // create a dynamic SQL statement Statement Stmt = connection.createStatement(); // execute the SQL query ResultSet results = Stmt.executeQuery("SELECT * from names"); // display the query results while (results.next()) { for (int i = 1; i <= 2; i++) { System.out.print(results.getString(i) + "\t"); } System.out.println("\n"); } } catch (ClassNotFoundException cnfe) {} catch (SQLException sqle) {} finally { try { // close the connection if (connection != null) { connection.close(); } } catch (SQLException sqle) {} } } }