Advertisement
Guest User

Untitled

a guest
May 13th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.10 KB | None | 0 0
  1. /*
  2.  * To change this template, choose Tools | Templates
  3.  * and open the template in the editor.
  4.  */
  5.  
  6. package refresher;
  7.  
  8. import oracle.sql.*;
  9. import java.sql.*;
  10. import oracle.jdbc.*;
  11. import oracle.jdbc.pool.*;
  12.  
  13. import java.sql.Connection;
  14. import java.sql.DriverManager;
  15. import java.sql.PreparedStatement;
  16. import java.sql.ResultSet;
  17. import java.sql.Statement;
  18. import java.sql.ResultSet;
  19.  
  20. public class Main {
  21.     public static void main(String[] args) throws ClassNotFoundException, SQLException
  22.     {
  23.         DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
  24.         //Class.forName("oracle.jdbc.driver.OracleDriver");
  25.  
  26.         String url = "jdbc:oracle:thin:@localhost:1521:XE";
  27.         Connection conn = DriverManager.getConnection(url, "HR", "hr");
  28.  
  29.         conn.setAutoCommit(false);
  30.         Statement stmt = conn.createStatement();
  31.         ResultSet rset = stmt.executeQuery("select * from JOBS");
  32.  
  33.         while(rset.next())
  34.         {
  35.             System.out.println(rset.getString(1));
  36.         }
  37.  
  38.         stmt.close();
  39.         System.out.println("Finished!");
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement