Advertisement
Guest User

Untitled

a guest
Jan 15th, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. public class DataSource {
  2.  
  3. private static final String USER = "user";
  4. private static final String PASSWORD = "root";
  5. private static final String URL = "jdbc:oracle:thin:@localhost:1521:xe";
  6.  
  7. public static Connection getConnection() {
  8. Connection connection = null;
  9. try {
  10. Class.forName("oracle.jdbc.driver.OracleDriver");
  11. connection = DriverManager.getConnection(URL, USER, PASSWORD);
  12. }
  13. catch (SQLException e) {
  14. System.err.println("Unable to connect");
  15. }
  16. catch (ClassNotFoundException e) {
  17. System.err.println("No driver");
  18. }
  19. return connection;
  20. }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement