Advertisement
Guest User

Untitled

a guest
Nov 11th, 2018
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6.  
  7. package pbo2;
  8.  
  9. import java.sql.*;
  10. import java.util.logging.*;
  11.  
  12. /**
  13. *
  14. * @author admin
  15. */
  16. public class PBO2 {
  17.  
  18. /**
  19. * @param args the command line arguments
  20. */
  21. public static void main(String[] args) {
  22. String host = "172.23.9.185";
  23. String port = "1521";
  24. String sid = "orcl";
  25. String user = "MHS175314019";
  26. String password = "MHS175314019";
  27.  
  28. try {
  29. Class.forName("oracle.jdbc.driver.OracleDriver");
  30. Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@"+host+":"+port+":"+sid,user,password);
  31.  
  32. String query = "select employee_id, first_name, last_name, email from employees";
  33. Statement st = conn.createStatement();
  34. ResultSet rs = st.executeQuery(query);
  35.  
  36. } catch (ClassNotFoundException ex) {
  37. System.out.println(ex.toString());
  38. } catch (SQLException ex) {
  39. System.out.println(ex.toString());
  40. }
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement