本文整理汇总了Java中java.sql.CallableStatement.getInt方法的典型用法代码示例。如果您正苦于以下问题:Java CallableStatement.getInt方法的具体用法?Java CallableStatement.getInt怎么用?Java CallableStatement.getInt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.sql.CallableStatement
的用法示例。
在下文中一共展示了CallableStatement.getInt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: populateCheckpointSummary
import java.sql.CallableStatement; //导入方法依赖的package包/类
public int populateCheckpointSummary( int loadQueueId, String name, String transferRateUnit,
boolean closeConnection ) throws DatabaseAccessException {
final String errMsg = "Unable to populate checkpoint summary '" + name + "' in load queue " + loadQueueId;
final int indexCheckpointSummaryId = 4;
CallableStatement callableStatement = null;
try {
refreshInternalConnection();
callableStatement = connection.prepareCall("{ call sp_populate_checkpoint_summary(?, ?, ?, ?) }");
callableStatement.setInt(1, loadQueueId);
callableStatement.setString(2, name);
callableStatement.setString(3, transferRateUnit);
callableStatement.registerOutParameter(indexCheckpointSummaryId, Types.INTEGER);
callableStatement.execute();
if (callableStatement.getInt(indexCheckpointSummaryId) == 0) {
throw new DatabaseAccessException(errMsg + " - checkpoint summary ID returned was 0");
}
return callableStatement.getInt(indexCheckpointSummaryId);
} catch (Exception e) {
throw new DatabaseAccessException(errMsg, e);
} finally {
if (closeConnection) {
DbUtils.close(connection, callableStatement);
} else {
DbUtils.closeStatement(callableStatement);
}
}
}
示例2: getResult
import java.sql.CallableStatement; //导入方法依赖的package包/类
public Object getResult(CallableStatement cs, int columnIndex) throws SQLException {
int i = cs.getInt(columnIndex);
if (cs.wasNull()) {
return null;
}
else {
return new Integer(i);
}
}
示例3: endLoadQueue
import java.sql.CallableStatement; //导入方法依赖的package包/类
public void endLoadQueue(
int result,
long timestamp,
int loadQueueId,
boolean closeConnection ) throws DatabaseAccessException {
final String errMsg = "Unable to end load queue with id " + loadQueueId;
timestamp = inUTC(timestamp);
final int indexRowsInserted = 4;
CallableStatement callableStatement = null;
try {
refreshInternalConnection();
callableStatement = connection.prepareCall("{ call sp_end_loadqueue(?, ?, ?, ?) }");
callableStatement.setInt(1, loadQueueId);
callableStatement.setInt(2, result);
callableStatement.setTimestamp(3, new Timestamp(timestamp));
callableStatement.registerOutParameter(indexRowsInserted, Types.INTEGER);
callableStatement.execute();
if (callableStatement.getInt(indexRowsInserted) != 1) {
throw new DatabaseAccessException(errMsg);
}
} catch (Exception e) {
throw new DatabaseAccessException(errMsg, e);
} finally {
if (closeConnection) {
DbUtils.close(connection, callableStatement);
} else {
DbUtils.closeStatement(callableStatement);
}
}
}
示例4: getNullableResult
import java.sql.CallableStatement; //导入方法依赖的package包/类
@Override
public Minutes getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
int minutes = cs.getInt(columnIndex);
return cs.wasNull() ? null : Minutes.of(minutes);
}
示例5: getNullableResult
import java.sql.CallableStatement; //导入方法依赖的package包/类
@Override
public Weeks getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
int weeks = cs.getInt(columnIndex);
return cs.wasNull() ? null : Weeks.of(weeks);
}
示例6: getNullableResult
import java.sql.CallableStatement; //导入方法依赖的package包/类
@Override
public DayOfYear getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
int dayOfYear = cs.getInt(columnIndex);
return dayOfYear == 0 ? null : DayOfYear.of(dayOfYear);
}
示例7: getNullableResult
import java.sql.CallableStatement; //导入方法依赖的package包/类
@Override
public DayOfMonth getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
int dayOfMonth = cs.getInt(columnIndex);
return dayOfMonth == 0 ? null : DayOfMonth.of(dayOfMonth);
}
示例8: populateSystemStatisticDefinition
import java.sql.CallableStatement; //导入方法依赖的package包/类
public int populateSystemStatisticDefinition(
String name,
String parentName,
String internalName,
String unit,
String params ) throws DatabaseAccessException {
if (parentName == null) {
parentName = "";
}
if (internalName == null) {
internalName = "";
}
CallableStatement callableStatement = null;
Connection con = null;
boolean useLocalConnection = false;
try {
if (connection == null || connection.isClosed()) {
// connection not set externally so use new connection only for
// this method invocation
useLocalConnection = true;
con = getConnection();
} else {
useLocalConnection = false;
con = connection;
}
final int statisticId = 6;
callableStatement = con.prepareCall("{ call sp_populate_system_statistic_definition(?, ?, ?, ?, ?, ?) }");
callableStatement.setString(1, parentName);
callableStatement.setString(2, internalName);
callableStatement.setString(3, name);
callableStatement.setString(4, unit);
callableStatement.setString(5, params);
callableStatement.registerOutParameter(statisticId, Types.INTEGER);
callableStatement.execute();
return callableStatement.getInt(statisticId);
} catch (Exception e) {
String errMsg = "Unable to populate statistic '" + name + "' with unit '" + unit
+ "' and params '" + params + "'";
throw new DatabaseAccessException(errMsg, e);
} finally {
DbUtils.closeStatement(callableStatement);
if (useLocalConnection) {
DbUtils.closeConnection(con);
}
}
}
示例9: getNullableResult
import java.sql.CallableStatement; //导入方法依赖的package包/类
@Override
public Integer getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
return cs.getInt(columnIndex);
}
示例10: getNullableResult
import java.sql.CallableStatement; //导入方法依赖的package包/类
@Override
public Years getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
int years = cs.getInt(columnIndex);
return cs.wasNull() ? null : Years.of(years);
}
示例11: getNullableResult
import java.sql.CallableStatement; //导入方法依赖的package包/类
@Override
public Seconds getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
int seconds = cs.getInt(columnIndex);
return cs.wasNull() ? null : Seconds.of(seconds);
}
示例12: getNullableResult
import java.sql.CallableStatement; //导入方法依赖的package包/类
@Override
public Days getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
int days = cs.getInt(columnIndex);
return cs.wasNull() ? null : Days.of(days);
}
示例13: startRun
import java.sql.CallableStatement; //导入方法依赖的package包/类
/**
* Insert a new run in the database
*
* @param runName
* name of the run
* @param osName
* name of the OS
* @param productName
* name of the product
* @param versionName
* version of the product
* @param buildName
* build version
* @param timestamp
* @param hostName
* name/IP of the machine , from which the run was started
* @return
*/
public int startRun(
String runName,
String osName,
String productName,
String versionName,
String buildName,
long timestamp,
String hostName,
boolean closeConnection ) throws DatabaseAccessException {
final String errMsg = "Unable to insert run with name " + runName;
timestamp = inUTC(timestamp);
// then start the run
final int indexRowsInserted = 8;
final int indexRunId = 9;
CallableStatement callableStatement = null;
try {
refreshInternalConnection();
callableStatement = connection.prepareCall("{ call sp_start_run(?, ?, ?, ?, ?, ?, ?, ? ,?) }");
callableStatement.setString(1, productName);
callableStatement.setString(2, versionName);
callableStatement.setString(3, buildName);
callableStatement.setString(4, runName);
callableStatement.setString(5, osName);
callableStatement.setTimestamp(6, new Timestamp(timestamp));
callableStatement.setString(7, hostName);
callableStatement.registerOutParameter(indexRowsInserted, Types.INTEGER);
callableStatement.registerOutParameter(indexRunId, Types.INTEGER);
callableStatement.execute();
if (callableStatement.getInt(indexRowsInserted) == 1) {
// check if the run ID is correct
if (callableStatement.getInt(indexRunId) == 0) {
throw new DatabaseAccessException(errMsg + " - run ID returned was 0");
}
} else {
throw new DatabaseAccessException(errMsg);
}
// get the result
return callableStatement.getInt(indexRunId);
} catch (Exception e) {
throw new DatabaseAccessException(errMsg, e);
} finally {
if (closeConnection) {
DbUtils.close(connection, callableStatement);
} else {
DbUtils.closeStatement(callableStatement);
}
}
}
示例14: startSuite
import java.sql.CallableStatement; //导入方法依赖的package包/类
public int startSuite(
String packageName,
String suiteName,
long timestamp,
int runId,
boolean closeConnection ) throws DatabaseAccessException {
final String errMsg = "Unable to start suite with name " + suiteName;
// create a new suite
timestamp = inUTC(timestamp);
CallableStatement callableStatement = null;
try {
refreshInternalConnection();
// TODO : remove me after 3.6.0
String dbVersionString = getDatabaseVersion();
int dbVersion = Integer.parseInt(dbVersionString.replace(".", ""));
if (dbVersion >= 350) {
callableStatement = connection.prepareCall("{ call sp_start_suite(?, ?, ?, ?, ?, ?) }");
if (packageName == null) {
packageName = "";
}
callableStatement.setString("@package", packageName);
} else {
callableStatement = connection.prepareCall("{ call sp_start_suite(?, ?, ?, ?, ?) }");
}
callableStatement.setString("@suiteName", suiteName);
callableStatement.setInt("@runId", runId);
callableStatement.setTimestamp("@dateStart", new Timestamp(timestamp));
callableStatement.registerOutParameter("@RowsInserted", Types.INTEGER);
callableStatement.registerOutParameter("@suiteId", Types.INTEGER);
callableStatement.execute();
if (callableStatement.getInt("@RowsInserted") != 1) {
throw new DatabaseAccessException(errMsg);
} else {
if (callableStatement.getInt("@suiteId") == 0) {
throw new DatabaseAccessException(errMsg + " - suite ID returned was 0");
}
}
// get the result
return callableStatement.getInt("@suiteId");
} catch (Exception e) {
throw new DatabaseAccessException(errMsg, e);
} finally {
if (closeConnection) {
DbUtils.close(connection, callableStatement);
} else {
DbUtils.closeStatement(callableStatement);
}
}
}
示例15: startCheckpoint
import java.sql.CallableStatement; //导入方法依赖的package包/类
public CheckpointInfo startCheckpoint(
String name,
long startTimestamp,
String transferRateUnit,
int loadQueueId,
boolean closeConnection ) throws DatabaseAccessException {
final String errMsg = "Unable to start checkpoint '" + name + "' in load queue " + loadQueueId;
startTimestamp = inUTC(startTimestamp);
final int indexCheckpointSummaryId = 5;
final int indexCheckpointId = 6;
CallableStatement callableStatement = null;
try {
refreshInternalConnection();
callableStatement = connection.prepareCall("{ call sp_start_checkpoint(?, ?, ?, ?, ?, ?) }");
callableStatement.setInt(1, loadQueueId);
callableStatement.setString(2, name);
callableStatement.setInt(3, checkpointLogLevel.toInt());
callableStatement.setString(4, transferRateUnit);
callableStatement.registerOutParameter(indexCheckpointSummaryId, Types.INTEGER);
callableStatement.registerOutParameter(indexCheckpointId, Types.INTEGER);
callableStatement.execute();
// we always update the checkpoint summary table
if (callableStatement.getInt(indexCheckpointSummaryId) == 0) {
throw new DatabaseAccessException(errMsg + " - checkpoint summary ID returned was 0");
}
// we update the checkpoint table only in FULL mode
if (checkpointLogLevel == CheckpointLogLevel.FULL
&& callableStatement.getInt(indexCheckpointId) == 0) {
throw new DatabaseAccessException(errMsg + " - checkpoint ID returned was 0");
}
int checkpointSummaryId = callableStatement.getInt(indexCheckpointSummaryId);
int checkpointId = callableStatement.getInt(indexCheckpointId);
return new CheckpointInfo(name, checkpointSummaryId, checkpointId, startTimestamp);
} catch (Exception e) {
throw new DatabaseAccessException(errMsg, e);
} finally {
if (closeConnection) {
DbUtils.close(connection, callableStatement);
} else {
DbUtils.closeStatement(callableStatement);
}
}
}