Guest User

Untitled

a guest
Apr 24th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. class JDBCVersion
  2. {
  3. public static void main (String args[]) throws SQLException
  4. {
  5. OracleDataSource ods = new OracleDataSource();
  6. ods.setURL("jdbc:oracle:thin:jdbc/jdbc@localhost:1521/XE");
  7. Connection conn = ods.getConnection();
  8.  
  9. // Create Oracle DatabaseMetaData object
  10. DatabaseMetaData meta = conn.getMetaData();
  11.  
  12. // gets driver info:
  13. System.out.println("JDBC driver version is " + meta.getDriverVersion());
  14. }
  15. }
  16.  
  17. String jdbcUrl = "jdbc:oracle:thin:@localhost:1521/XE"
  18. String userid = "hr";
  19. String password = "hr";
  20. Connection conn;
  21.  
  22. public void getDBConnection() throws SQLException{
  23. OracleDataSource ds;
  24. ds = new OracleDataSource();
  25. ds.setURL(jdbcUrl);
  26. conn=ds.getConnection(userid,password);
  27.  
  28. }
Add Comment
Please, Sign In to add comment