Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. public class DBConnection {
  2. public Connection connection;
  3. public Statement st;
  4. public void dbConnection(){
  5. try {
  6.  
  7. Class.forName("oracle.jdbc.driver.OracleDriver");
  8.  
  9. } catch (ClassNotFoundException e) {
  10. e.printStackTrace();
  11.  
  12.  
  13. }
  14.  
  15.  
  16. try {
  17. connection = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe", "OSPEDALE", "marcopolo");
  18. //System.out.println(connection);
  19.  
  20. } catch (SQLException e) {
  21.  
  22. System.out.println("Connection Failed!");
  23. e.printStackTrace();
  24.  
  25.  
  26. }
  27.  
  28. if (connection != null) {
  29. //System.out.println("Database connected.");
  30. } else {
  31. System.out.println("Failed to make connection.");
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement