DataSource.java Source code

Java tutorial

Introduction

Here is the source code for DataSource.java

Source

import javax.sql.*;
import java.sql.*;
import oracle.jdbc.driver.*;
import oracle.jdbc.pool.*;

public class DataSource {

    public static void main(String[] args) {
        try {
            OracleDataSource ods = new OracleDataSource();

            ods.setUser("yourName");
            ods.setPassword("mypwd");
            ods.setDriverType("thin");
            ods.setDatabaseName("ORCL");
            ods.setServerName("localhost");
            ods.setPortNumber(1521);

            Connection conn = ods.getConnection();

        } catch (SQLException se) {
            se.printStackTrace();
        }
    }
}