Guest User

Untitled

a guest
Jul 3rd, 2017
25
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. package com.seed;
  2.  
  3. import java.io.FileReader;
  4. import java.sql.Connection;
  5. import java.sql.DriverManager;
  6. import java.util.Properties;
  7.  
  8. public class connprovider {
  9. static Connection con;
  10. public static Connection getConnectionWithDB()
  11. {
  12. try{
  13. FileReader fr=new FileReader("dbinfo.properties");
  14. Properties pr=new Properties();
  15. pr.load(fr);
  16. String username=pr.getProperty("un");
  17. String password=pr.getProperty("password");
  18. Class.forName("oracle.jdbc.driver.OracleDriver");
  19. con=DriverManager.getConnection(pr.getProperty("path_url"),username,password);
  20.  
  21. //con=DriverManager.getConnection("jdbc:oracle:thin:@tcet-PC:1521:XE","scott","TIGER");
  22. }
  23. catch(Exception e)
  24. {
  25. e.printStackTrace();
  26. }
  27. return con;
  28. }
  29. }
Add Comment
Please, Sign In to add comment