import java.sql.*; public class DBConnect { public static void main(String[] args){ Connection con = null; PreparedStatement stmt = null; ResultSet rs = null; try{ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); con = DriverManager.getConnection("jdbc:odbc:confrage"); stmt = con.prepareStatement("select * from tbl_emp"); rs = stmt.executeQuery(); while(rs.next()){ System.out.println(rs.getInt(1)); System.out.println(rs.getInt(2)); System.out.println(rs.getInt(3)); } }catch(SQLException e){ e.printStackTrace(); }catch (Exception e) { e.printStackTrace(); }finally{ try { if(rs != null){ rs.close(); } } catch (SQLException e) { e.printStackTrace(); } try { if(stmt != null){ stmt.close(); } } catch (SQLException e) { e.printStackTrace(); } try { if(con != null){ con.close(); } } catch (SQLException e) { e.printStackTrace(); } } } }