Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Main {
- private static final String driverName = "com.mysql.jdbc.Driver";
- private static final String URL = "jdbc:mysql://localhost:3306/mydbtest?useSSL=false";
- private static final String USERNAME = "root";
- private static final String PASSWORD = "root";
- public static void main(String[] args) {
- try {
- Class.forName(driverName);
- } catch (ClassNotFoundException e) {
- System.out.println("Can't get class. No driver found");
- return;
- }
- Connection connection = null;
- try {
- connection = DriverManager.getConnection(URL, USERNAME, PASSWORD);
- } catch (SQLException e) {
- System.out.println("Can't get connection. Incorrect URL");
- return;
- }
- try {
- connection.close();
- } catch (SQLException e) {
- System.out.println("Can't close connection");
- return;
- }
- }
Add Comment
Please, Sign In to add comment