DataSource: getConnection()
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!");
}
}
Related examples in the same category