Write a java program to retrieve the data from emp database?



import java.sql.*;
class SelectData {
 public static void main(String[] args) throws Exception {
  DriverManager.registerDriver(new Sun.jdbc.odbc.JdbcOdbcDriver());
  System.out.println("DRIVERS LOADED...");
  Connection con = DriverManager.getConnection("jdbc:odbc:oradsn", "scott", "tiger");
  System.out.println("CONNECTION ESTABLISHED...");
  Statement st = con.createStatement();
  ResultSet rs = st.executeQuery("select * from dept");
  while (rs.next()) {
   System.out.println(rs.getString(1) + " " + rs.getString(2) + " " + rs.getString(3));
  }
  con.close();
 }
};


No comments:

Post a Comment