Advertisement
Guest User

Untitled

a guest
Jul 31st, 2016
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. import java.sql.Connection;
  2. import java.sql.DriverManager;
  3. import java.sql.ResultSet;
  4. import java.sql.SQLException;
  5. import java.sql.Statement;
  6.  
  7. public class Sample {
  8.  
  9. public static void main(String args[]) {
  10.  
  11. try {
  12.  
  13. Class.forName("oracle.jdbc.driver.OracleDriver");
  14. ^
  15. <!--This is a Type 4 Driver. This implements the
  16. interface provided by the JDBC specification
  17. (java.sql.Driver)-->
  18.  
  19. String url = "jdbc:oracle:thin:@10.184.132.128:1521:devdb";
  20. Connection conn = DriverManager.getConnection(url,"dev1201st","develop1201");
  21. Statement stmt = conn.createStatement();
  22. ResultSet rset = stmt.executeQuery("select sysdate from dual");
  23.  
  24. while (rset.next()) {
  25. System.out.println(rset.getString(1));
  26. }
  27. }
  28. catch (ClassNotFoundException e)
  29. {
  30. e.printStackTrace();
  31. }
  32. catch (SQLException e)
  33. {
  34. e.printStackTrace();
  35. }
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement