package ProjectConnection; import java.sql.*; import oracle.jdbc.*; import oracle.jdbc.pool.OracleDataSource; import java.sql.Statement; public class ConnectionBean { OracleDataSource ods; Connection connSelect; Connection connUpdate; Statement statementSelect; Statement statementUpdate; String url; String errMessage; public ConnectionBean() { try { // create an OracleDataSource instance ods = new OracleDataSource(); // Oracle connection string url = "jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=prediction.rutgers.edu)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=prediction.rutgers.edu)(PORT=1521))(LOAD_BALANCE=on))(CONNECT_DATA=(SERVICE_NAME=stud.rutgers.edu)))"; // make the connection ods.setURL(url); ods.setUser(""); // change to your username ods.setPassword(""); // change to your password connSelect = ods.getConnection(); connUpdate = ods.getConnection(); statementSelect=connSelect.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY); statementUpdate=connUpdate.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); } catch (SQLException e) { errMessage = "driver not loaded"; connSelect = null; connUpdate = null; } } public ResultSet getResult(String sql)throws SQLException{ // SQLException caught by caller if it occurs return statementSelect.executeQuery(sql); } public int doUpdate(String sql) throws SQLException { // SQLException caught by caller if it occurs return statementUpdate.executeUpdate(sql); } }