Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.sql.Connection;

import javax.naming.InitialContext;
import javax.sql.DataSource;

public class Main {
    public static void main(String[] argv) throws Exception {
        InitialContext init = new InitialContext();
        DataSource source = (DataSource) init.lookup("dsn");
        Connection connection = source.getConnection();
        System.out.println("Connect to " + connection.getCatalog() + " a success!");
    }
}