本文整理匯總了Java中java.sql.Connection.prepareCall方法的典型用法代碼示例。如果您正苦於以下問題:Java Connection.prepareCall方法的具體用法?Java Connection.prepareCall怎麽用?Java Connection.prepareCall使用的例子?那麽恭喜您, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.sql.Connection的用法示例。
在下文中一共展示了Connection.prepareCall方法的16個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於我們的係統推薦出更棒的Java代碼示例。
示例1: testBug12417
點讚 4
import java.sql.Connection; //導入方法依賴的package包/類
/**
* Tests fix for Bug#12417 - stored procedure catalog name is case-sensitive
* on Windows (this is actually a server bug, but we have a workaround in
* place for it now).
*
* @throws Exception
* if the test fails.
*/
public void testBug12417() throws Exception {
if (serverSupportsStoredProcedures() && isServerRunningOnWindows()) {
createProcedure("testBug12417", "()\nBEGIN\nSELECT 1;end\n");
Connection ucCatalogConn = null;
try {
ucCatalogConn = getConnectionWithProps((Properties) null);
ucCatalogConn.setCatalog(this.conn.getCatalog().toUpperCase());
ucCatalogConn.prepareCall("{call testBug12417()}");
} finally {
if (ucCatalogConn != null) {
ucCatalogConn.close();
}
}
}
}
開發者ID:bragex,項目名稱:the-vigilantes,代碼行數:27,
示例2: testBug78961
點讚 3
import java.sql.Connection; //導入方法依賴的package包/類
/**
* Tests fix for Bug#78961 - Can't call MySQL procedure with InOut parameters in Fabric environment.
*
* Although this is a Fabric related bug we are able reproduce it using a couple of multi-host connections.
*/
public void testBug78961() throws Exception {
createProcedure("testBug78961", "(IN c1 FLOAT, IN c2 FLOAT, OUT h FLOAT, INOUT t FLOAT) BEGIN SET h = SQRT(c1 * c1 + c2 * c2); SET t = t + h; END;");
Connection highLevelConn = getLoadBalancedConnection(null);
assertTrue(highLevelConn.getClass().getName().startsWith("com.sun.proxy") || highLevelConn.getClass().getName().startsWith("$Proxy"));
Connection lowLevelConn = getMasterSlaveReplicationConnection(null);
// This simulates the behavior from Fabric connections that are causing the problem.
((ReplicationConnection) lowLevelConn).setProxy((MySQLConnection) highLevelConn);
CallableStatement cstmt = lowLevelConn.prepareCall("{CALL testBug78961 (?, ?, ?, ?)}");
cstmt.setFloat(1, 3.0f);
cstmt.setFloat(2, 4.0f);
cstmt.setFloat(4, 5.0f);
cstmt.registerOutParameter(3, Types.FLOAT);
cstmt.registerOutParameter(4, Types.FLOAT);
cstmt.execute();
assertEquals(5.0f, cstmt.getFloat(3));
assertEquals(10.0f, cstmt.getFloat(4));
}
開發者ID:Jugendhackt,項目名稱:OpenVertretung,代碼行數:27,
示例3: deleteTestcase
點讚 3
import java.sql.Connection; //導入方法依賴的package包/類
public void deleteTestcase(
List objectsToDelete ) throws DatabaseAccessException {
StringBuilder testcaseIds = new StringBuilder();
for (Object obj : objectsToDelete) {
testcaseIds.append( ((Testcase) obj).testcaseId);
testcaseIds.append(",");
}
testcaseIds.delete(testcaseIds.length() - 1, testcaseIds.length());
final String errMsg = "Unable to delete testcase(s) with id " + testcaseIds;
Connection connection = getConnection();
CallableStatement callableStatement = null;
try {
callableStatement = connection.prepareCall("{ call sp_delete_testcase(?) }");
callableStatement.setString(1, testcaseIds.toString());
callableStatement.execute();
} catch (SQLException e) {
throw new DatabaseAccessException(errMsg, e);
} finally {
DbUtils.close(connection, callableStatement);
}
}
開發者ID:Axway,項目名稱:ats-framework,代碼行數:25,
示例4: getSuiteMessagesCount
點讚 3
import java.sql.Connection; //導入方法依賴的package包/類
public int getSuiteMessagesCount( String whereClause ) throws DatabaseAccessException {
String sqlLog = new SqlRequestFormatter().add("where", whereClause).format();
Connection connection = getConnection();
CallableStatement callableStatement = null;
ResultSet rs = null;
try {
callableStatement = connection.prepareCall("{ call sp_get_suite_messages_count(?) }");
callableStatement.setString(1, whereClause);
rs = callableStatement.executeQuery();
int messagesCount = 0;
if (rs.next()) {
messagesCount = rs.getInt("messagesCount");
}
logQuerySuccess(sqlLog, "suite messages count", messagesCount);
return messagesCount;
} catch (Exception e) {
throw new DatabaseAccessException("Error