本文整理汇总了Java中java.sql.CallableStatement.setLong方法的典型用法代码示例。如果您正苦于以下问题:Java CallableStatement.setLong方法的具体用法?Java CallableStatement.setLong怎么用?Java CallableStatement.setLong使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.sql.CallableStatement
的用法示例。
在下文中一共展示了CallableStatement.setLong方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testBadProcedureName
import java.sql.CallableStatement; //导入方法依赖的package包/类
@Test
public void testBadProcedureName() throws SQLException {
CallableStatement cs = conn.prepareCall("{call Oopsy(?)}");
cs.setLong(1, 99);
try {
cs.execute();
} catch (SQLException e) {
assertEquals(e.getSQLState(), SQLError.GENERAL_ERROR);
}
}
示例2: testDoubleInsert
import java.sql.CallableStatement; //导入方法依赖的package包/类
@Test
public void testDoubleInsert() throws SQLException {
CallableStatement cs = conn.prepareCall("{call InsertOrders(?, ?, ?, ?, ?, ?, ?, ?)}");
cs.setLong(1, 1L);
cs.setLong(2, 1L);
cs.setLong(3, 1L);
cs.setLong(4, 1L);
cs.setLong(5, 1L);
cs.setLong(6, 1L);
cs.setLong(7, 1L);
cs.setLong(8, 1L);
cs.execute();
try {
cs.setLong(1, 1L);
cs.setLong(2, 1L);
cs.setLong(3, 1L);
cs.setLong(4, 1L);
cs.setLong(5, 1L);
cs.setLong(6, 1L);
cs.setLong(7, 1L);
cs.setLong(8, 1L);
cs.execute();
} catch (SQLException e) {
// Since it's a GENERAL_ERROR we need to look for a string by pattern.
assertEquals(e.getSQLState(), SQLError.GENERAL_ERROR);
assertTrue(e.getMessage().contains("violation of constraint"));
}
}
示例3: testLostConnection
import java.sql.CallableStatement; //导入方法依赖的package包/类
@Test
public void testLostConnection() throws SQLException, ClassNotFoundException {
// Break the current connection and try to execute a procedure call.
CallableStatement cs = conn.prepareCall("{call Oopsy(?)}");
stopServer();
cs.setLong(1, 99);
try {
cs.execute();
} catch (SQLException e) {
assertEquals(e.getSQLState(), SQLError.CONNECTION_FAILURE);
}
// Restore a working connection for any remaining tests
startServer();
}
示例4: endCheckpoint
import java.sql.CallableStatement; //导入方法依赖的package包/类
public void endCheckpoint(
CheckpointInfo runningCheckpointInfo,
long endTimestamp,
long transferSize,
int result,
boolean closeConnection ) throws DatabaseAccessException {
final String errMsg = "Unable to end checkpoint with name '" + runningCheckpointInfo.getName()
+ "', checkpoint summary id " + runningCheckpointInfo.getCheckpointSummaryId()
+ ", id " + runningCheckpointInfo.getCheckpointId();
endTimestamp = inUTC(endTimestamp);
final int indexRowsInserted = 8;
CallableStatement callableStatement = null;
try {
refreshInternalConnection();
callableStatement = connection.prepareCall("{ call sp_end_checkpoint(?, ?, ?, ?, ?, ?, ?, ?) }");
callableStatement.setInt(1, runningCheckpointInfo.getCheckpointSummaryId());
callableStatement.setInt(2, runningCheckpointInfo.getCheckpointId());
callableStatement.setInt(3,
(int) (endTimestamp - runningCheckpointInfo.getStartTimestamp()));
callableStatement.setLong(4, transferSize);
callableStatement.setInt(5, result);
callableStatement.setInt(6, checkpointLogLevel.toInt());
callableStatement.setTimestamp(7, new Timestamp(endTimestamp));
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);
}
}
}
示例5: testBug87704
import java.sql.CallableStatement; //导入方法依赖的package包/类
/**
* Tests fix for BUG#87704 (26771560) - THE STREAM GETS THE RESULT SET ?THE DRIVER SIDE GET WRONG ABOUT GETLONG().
*
* @throws Exception
* if an error occurs.
*/
public void testBug87704() throws Exception {
if (!serverSupportsStoredProcedures()) {
return;
}
createProcedure("testBug87704",
"(IN PARAMIN BIGINT, OUT PARAM_OUT_LONG BIGINT, OUT PARAM_OUT_STR VARCHAR(100))\nBEGIN\nSET PARAM_OUT_LONG = PARAMIN + 100000;\nSET PARAM_OUT_STR = concat('STR' ,PARAM_OUT_LONG);end\n");
final Properties props = new Properties();
props.setProperty("useSSL", "false");
props.setProperty("useServerPrepStmts", "true");
props.setProperty("cachePrepStmts", "true");
props.setProperty("prepStmtCacheSize", "500");
props.setProperty("prepStmtCacheSqlLimit", "2048");
props.setProperty("useOldAliasMetadataBehavior", "true");
props.setProperty("rewriteBatchedStatements", "true");
props.setProperty("useCursorFetch", "true");
props.setProperty("defaultFetchSize", "100");
Connection con = getConnectionWithProps(props);
CallableStatement callableStatement = null;
try {
callableStatement = con.prepareCall("call testBug87704(?,?,?)");
callableStatement.setLong(1, 30214567L);
callableStatement.registerOutParameter(2, Types.BIGINT);
callableStatement.registerOutParameter(3, Types.VARCHAR);
callableStatement.execute();
System.out.println(callableStatement.getLong(2));
System.out.println(callableStatement.getString(3));
assertEquals(30314567L, callableStatement.getLong(2));
assertEquals("STR30314567", callableStatement.getString(3));
} finally {
if (callableStatement != null) {
callableStatement.close();
}
if (con != null) {
con.close();
}
}
}