Advertisement
Guest User

Untitled

a guest
Apr 7th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. import java.sql.Connection;
  2. import java.sql.DriverManager;
  3. import java.sql.SQLException;
  4. import java.util.Properties;
  5.  
  6. /**
  7. * This program demonstrates how to make database connection with Oracle
  8. * database server.
  9. * @author www.codejava.net
  10. *
  11. */
  12. public class Main {
  13.  
  14. public static void main(String[] args) throws SQLException, ClassNotFoundException {
  15.  
  16. Connection conn2 = null;
  17.  
  18.  
  19. String dbURL2 = "jdbc:oracle:thin:c##stops_bd/pocosi12@dsscora12c.aitec.pt:1521:ORA12C";
  20. //String username = "c##stops_bd";
  21. //String password = "pocosi12";
  22. System.out.println("tentar...");
  23. conn2 = DriverManager.getConnection(dbURL2/*, username, password*/);
  24. System.out.println("did it");
  25. if (conn2 != null) {
  26. System.out.println("Connected with connection #2");
  27.  
  28. try {
  29.  
  30. if (conn2 != null && !conn2.isClosed()) {
  31. conn2.close();
  32. }
  33. } catch (SQLException ex) {
  34. ex.printStackTrace();
  35. }
  36. }
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement