import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import java.sql.*; public class LoadDriver { public static void main(String[] args) { try { Class.forName("com.mysql.jdbc.Driver").newInstance(); System.out.println("connected!"); Connection conn = DriverManager.getConnection("jdbc:mysql://Localhost/BabyTalkWebLibrary?user=root"); Statement stmt = null; ResultSet rs = null; stmt = conn.createStatement(); rs = stmt.executeQuery("SELECT * FROM Status"); while (rs.next()) { String desc = rs.getString("description"); System.out.println(desc); } stmt.close(); conn.close(); // it is a good idea to release // resources in a finally{} block // in reverse-order of their creation // if they are no-longer needed if (rs != null) { rs.close(); rs = null; } if (stmt != null) { stmt.close(); stmt = null; } } catch (SQLException ex) { System.out.println("SQLException: " + ex.getMessage()); System.out.println("SQLState: " + ex.getSQLState()); System.out.println("VendorError: " + ex.getErrorCode()); } catch (Exception e) { System.out.println("NOT connected:" + e); } } }