Forked from
DM / dm-docs
261 commits behind, 647 commits ahead of the upstream repository.
-
Barbara B. Frosik authoredBarbara B. Frosik authored
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
OracleConnection.java 1.41 KiB
package gov.anl.dm.esafsync;
import java.sql.CallableStatement;
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Types;
import java.util.Properties;
public class OracleConnection {
Connection connection = null;
Statement statement;
void connect(Properties config) throws SQLException {
DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
connection = DriverManager.getConnection(
"jdbc:oracle:thin:@ra.aps.anl.gov:1527:aps1",
"glob_conn",
"ur2ytkownicy2u");
}
String getExperiments(String sector, String lower, String upper) throws SQLException {
CallableStatement callableStatement =
connection.prepareCall("{? = call safety.esaf_exp0001.get_exps(?,?,?,?)}");
callableStatement.registerOutParameter(1, Types.VARCHAR);
callableStatement.setObject(2, "");
callableStatement.setString(3, sector);
callableStatement.setString(4, lower);
callableStatement.setString(5, upper);
callableStatement.execute();
return callableStatement.getString(1);
}
void close() {
try {
if (statement != null) {
statement.close();
}
if (connection != null) {
connection.close();
}
} catch (SQLException ex) {
// nothing to do here
}
}
}