Advertisement
Guest User

Untitled

a guest
Jan 14th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. package dbUtil;
  2.  
  3. import java.sql.Connection;
  4. import java.sql.DriverManager;
  5. import java.sql.SQLException;
  6.  
  7. public class dbConnection {
  8.  
  9. private static final String USERNAME = "szpital";
  10. private static final String PASSWORD = "szpital";
  11. private static final String SQCONN = "jdbc:oracle:thin:@localhost:1521:xe";
  12.  
  13. public static Connection getConnection() throws SQLException{
  14.  
  15. try{
  16. Class.forName("oracle.jdbc.driver.OracleDriver");
  17. return DriverManager.getConnection(SQCONN, USERNAME, PASSWORD);
  18.  
  19.  
  20. }catch (SQLException ex) {
  21. System.out.println("Cos poszlo nie tak: " + ex.getMessage());
  22. } catch (ClassNotFoundException e) {
  23. e.printStackTrace();
  24. }
  25. return null;
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement