-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathApp.java
More file actions
19 lines (17 loc) · 693 Bytes
/
Copy pathApp.java
File metadata and controls
19 lines (17 loc) · 693 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class App {
public static void main(String[] args) {
String url = "jdbc:mysql://localhost:3306/metro"; // conecta no banco 'metro' local
String user = "root"; // usuário padrão do mysql
String password = "batata123"; // senha do mysql (altere se precisar)
try {
Connection conn = DriverManager.getConnection(url, user, password);
System.out.println("conectado com sucesso :)");
conn.close();
} catch (SQLException e) {
System.out.println("ops, erro na conexão: " + e.getMessage());
}
}
}