Advertisement
Guest User

Untitled

a guest
Dec 20th, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. public Connection connectToDatabase(String adress, int port) {
  2. Properties connectionProps = new Properties();
  3. connectionProps.put("user", "root");
  4. connectionProps.put("password", "root");
  5. try {
  6. connection = DriverManager.getConnection("jdbc:mysql://" + adress + ":" + port + "/",
  7. connectionProps);
  8. } catch (SQLException e) {
  9. System.out.println("Error when connecting to the database");
  10. e.printStackTrace();
  11. }
  12. return connection;
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement