Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static Connection connection;
- public static void main(String[] args) {
- connection = getConnection();
- }
- private static Connection getConnection() {
- try {
- String url = "jdbc:mysql://localhost:3306";
- String username = "username";
- String password = "password";
- Connection connection = DriverManager.getConnection(url, username, password);
- System.out.println("Connected to MySQL");
- return connection;
- } catch (SQLException e) {
- e.printStackTrace();
- }
- System.err.println("Connection to MySQL failed");
- return null;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement