Get connection from DataSource
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();
}
}
}
Related examples in the same category