import java.sql.*; public class MakeConn { Connection cn; String url; Statement sql; ResultSet rs; public void makeconn() { //trying to load the driver //Below 'try' module is for Connection to a MS-Access Database on Windows-OS. //Connection string differs from OS and Driver used. //Below module is to present an example of an implementation try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); System.out.println("Driver found...."); System.out.println("Waiting for Connection..."); url="jdbc:odbc:ixiaon"; cn=DriverManager.getConnection(url,"username","password"); System.out.println("Connection is Established."); } catch (ClassNotFoundException ce) { System.out.println("1 :Exception : " + ce); } catch (SQLException sqle) { System.out.println("2: Exception : " + sqle); } } public void getData() { try { sql=cn.createStatement(); rs=sql.executeQuery("SELECT * FROM BOOKSHOP"); System.out.println("Presenting Information.."); while(rs.next()) { System.out.print("ID:" + rs.getString(1) + " " ); System.out.print("Title:" + rs.getString(2)+ " " ); System.out.print("Writter:" + rs.getString(3)+ " " ); System.out.println("Cost:" + rs.getString(4)+ " " ); } rs.close(); sql.close(); } catch (SQLException sqle1) { System.out.println("4: Exception:" + sqle1); } } public void breakconn() { try { cn.close(); } catch (Exception e) { System.out.println("3: Exception: " + e); } } public static void main(String[] args) { MakeConn m=new MakeConn(); m.makeconn(); m.getData(); m.breakconn(); } }