Using JDBC with Java Applications and (Storefront hosting) Applets 68

Using JDBC with Java Applications and Applets 68 private void displaySQLErrors(SQLException e) { System.out.println(”SQLException: ” + e.getMessage()); System.out.println(”SQLState: ” + e.getSQLState()); System.out.println(”VendorError: ” + e.getErrorCode()); } public Hello() { try { Class.forName(”com.mysql.jdbc.Driver”).newInstance(); } catch (SQLException e) { System.err.println(”Unable to find and load driver”); System.exit(1); } } public void connectToDB() { try { connection = DriverManager.getConnection( “jdbc:mysql://localhost/accounts?user=&password=”); } catch(SQLException e) { displaySQLErrors(e); } } public void executeSQL() { try { Statement statement = connection.createStatement(); ResultSet rs = statement.executeQuery( “SELECT * FROM acc_acc”); while (rs.next()) { System.out.println(rs.getString(1)); } rs.close(); statement.close(); connection.close(); } catch(SQLException e) { displaySQLErrors(e); } } public static void main(String[] args) { Listing 5.1 Hello World. (continues)
Note: If you are looking for top 10 and very good webhost to host and run your jsp application check Actions jsp hosting services

Comments are closed.