Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.sql.Connection;
import java.sql.DriverManager;

public class Main {

    public static void main(String[] argv) throws Exception {

        Class.forName("com.mysql.jdbc.Driver");

        System.out.println("MySQL JDBC Driver Registered!");
        Connection connection = null;

        connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/dbName", "root", "password");

        if (connection != null) {
            System.out.println("database now!");
        } else {
            System.out.println("Failed to make connection!");
        }
    }
}