Advertisement
Guest User

DBCon

a guest
Mar 20th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. import java.sql.*;
  2.  
  3. public class DatabaseConnector {
  4.  
  5.  
  6. public static Connection setUpConnection() {
  7. String url = "jdbc:mysql://mysql.stud.ntnu.no:3306/minhhd_gr69?verifyServerCertificate=false&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=CET";
  8. String username = "minhhd_aubergine69";
  9. String password = "eggplante69";
  10.  
  11. try {
  12. Class.forName("com.mysql.jdbc.Driver").newInstance();
  13. System.out.println("ayyyyy");
  14. Connection connection = DriverManager.getConnection(url,username,password);
  15.  
  16. return connection;
  17. }catch (Exception e){
  18. System.out.println("Du klarte ikke aa koble til databasen.");
  19. e.printStackTrace();
  20. }
  21. return null;
  22. }
  23.  
  24.  
  25. public static ResultSet createRS(Statement statement, String query) throws SQLException {
  26. ResultSet result = statement.executeQuery(query);
  27. return result;
  28. }
  29.  
  30.  
  31. public static void main(String[] args) {
  32. setUpConnection();
  33. }
  34.  
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement