rajamit872

Implementing Type1 JDBC program to fetch table from DataBase

Jan 26th, 2015
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.56 KB | None | 0 0
  1. import java.sql.*;
  2. class Jdbc2{
  3. public static void main(String args[]) throws Exception{
  4. Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  5. Connection con = DriverManager.getConnection("jdbc:odbc:oradsn","scott","tiger");
  6. Statement st = con.createStatement();
  7. String query = "select * from rajesh";
  8. ResultSet rs = st.executeQuery(query);
  9.  
  10. while(rs.next()!=false)
  11. System.out.println(rs.getInt("sno") + "  " + rs.getString("name") + "  "
  12.     +rs.getString("sex") + "  " + rs.getString("address") +
  13.     "  "+ rs.getInt("age"));
  14.  
  15. rs.close();
  16. st.close();
  17. con.close();
  18. }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment