Guest User

Untitled

a guest
Dec 25th, 2017
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. # TNSNAMES.ORA Network Configuration File: C:oraclenetworkADMINtnsnames.ora
  2. # Generated by Oracle configuration tools.
  3.  
  4. INST1_HTTP =
  5. (DESCRIPTION =
  6. (ADDRESS_LIST =
  7. (ADDRESS = (PROTOCOL = TCP)(HOST = 10.10.4.123)(PORT = 1521))
  8. )
  9. (CONNECT_DATA =
  10. (SID = medst)
  11. (SERVER = SHARED)
  12. (PRESENTATION = http://admin)
  13. )
  14. )
  15.  
  16. MED =
  17. (DESCRIPTION =
  18. (ADDRESS_LIST =
  19. (ADDRESS = (PROTOCOL = TCP)(HOST = 10.10.4.113)(PORT = 1521))
  20. )
  21. (CONNECT_DATA =
  22. (SID = med)
  23. )
  24. )
  25.  
  26. db.host = jdbc:mysql://localhost/shop
  27. db.user = shop
  28. db.password = 123456
  29.  
  30. public class DBConnection {
  31. public static Connection getConnection() throws SQLException, IOException {
  32. Properties properties = new Properties();
  33.  
  34. try (InputStream in = Files.newInputStream(Paths.get("db.properties"))) {
  35. properties.load(in);
  36. }
  37.  
  38. String host = properties.getProperty("db.host");
  39. String user = properties.getProperty("db.user");
  40. String password = properties.getProperty("db.password");
  41.  
  42. return DriverManager.getConnection(host, user, password);
  43. }
  44. }
Add Comment
Please, Sign In to add comment