import java.sql.*; public class JDBCTestMysqlHarbinger { public static void main(java.lang.String[] args) { try { // this is where the driver is loaded Class.forName("com.mysql.jdbc.Driver").newInstance(); //DriverManager.registerDriver(new OracleDriver()); } catch (InstantiationException i) { System.out.println("Unable to load driver Class"); return; } catch (ClassNotFoundException e) { System.out.println("Unable to load driver Class"); return; } catch (IllegalAccessException e) { System.out.println("Unable to load driver Class"); return; } try { //All DB accees is within the try/catch block... Connection con = DriverManager.getConnection("jdbc:mysql://localhost/YOUR_LOGIN_ID?user=YOUR_MYSQL_ID&password=YOUR_MYSQL_PW"); // Do an SQL statement... Statement stmt = con.createStatement(); ResultSet rs = stmt.executeQuery("SELECT name FROM DIVECUST"); // show the Results... while(rs.next()) { System.out.println(rs.getString("Name")); //System.out.println(" " + rs.getString("TITLE") + "."); System.out.println(""); } // Release the db resources... rs.close(); stmt.close(); con.close(); } catch (SQLException se) { // inform user of errors... System.out.println("SQL Exception: " + se.getMessage()); se.printStackTrace(System.out); } } }