// small demo program showing JDBC access to an IMAGE/SQL database import java.sql.*; class JdbcProgram { public static void main(String[] args) throws ClassNotFoundException, SQLException { // load the appropriate database driver Class.forName("com.hp.jdbc.allbase.JdbcDriver"); // on a PC you might also use another driver // Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); // which provides access to the JDBC-ODBC bridge // quite handy for local PC prototyping... // establish connection to database on server Connection con = DriverManager.getConnection( "jdbc:allbase://your3k/musicdbe.grp.acct", "user.acct", "upass,apass" // or with JdbcOdbc bridge "jdbc:odbc:YourDSN", "NoUser", "NoPass" ); // create an SQL statement to be executed Statement st = con.createStatement(); // send a query to the database server ResultSet rs = st.executeQuery( "select composername,birth,death from music.composers" ); // retrieve and display the resulting entries while (rs.next()) { System.out.println( rs.getString("composername") + ", " + rs.getString("birth") + " - " + rs.getString("death") ); } // close resources aquired rs.close(); st.close(); // release the database connection con.close(); } }