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("oracle.jdbc.driver.OracleDriver");
        Connection connection = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:databaseName",
                "username", "password");
        if (connection != null) {
            System.out.println("Connected");
        } else {
            System.out.println("Failed to make connection!");
        }
    }
}