use of java.sql.CallableStatement in project binnavi by google.
the class PostgreSQLNativeViewCreator method createNativeCallgraphView.
/**
* Creates the native call graph view of a module.
*
* @param connection Connection to the database.
* @param moduleId ID of the BinNavi module where the view is created.
*
* @return The ID of the created view.
*
* @throws SQLException Thrown if creating the view failed.
*/
public static int createNativeCallgraphView(final CConnection connection, final int moduleId) throws SQLException {
Preconditions.checkNotNull(connection, "IE00706: connection argument can not be null");
final String query = "{ ? = call create_native_call_graph_view(?) }";
final CallableStatement call = connection.getConnection().prepareCall(query);
call.registerOutParameter(1, Types.INTEGER);
call.setInt(2, moduleId);
call.execute();
return call.getInt(1);
}
use of java.sql.CallableStatement in project binnavi by google.
the class PostgreSQLNativeViewCreator method createNativeFlowgraphEdges.
/**
* Creates the native flow graph edges of a module.
*
* @param connection Connection to the database
* @param rawModuleId ID of the raw module that provides the data.
* @param moduleId ID of the BinNavi module where the edges are created.
*
* @throws SQLException Thrown if creating the edges nodes failed.
*/
public static void createNativeFlowgraphEdges(final CConnection connection, final int rawModuleId, final int moduleId) throws SQLException {
Preconditions.checkNotNull(connection, "IE01634: connection argument can not be null");
final String query = " { call create_native_flowgraph_edges(?,?) }";
final CallableStatement call = connection.getConnection().prepareCall(query);
call.setInt(1, rawModuleId);
call.setInt(2, moduleId);
call.execute();
}
use of java.sql.CallableStatement in project binnavi by google.
the class PostgreSQLNativeViewCreator method createNativeCallgraphEdges.
/**
* Creates the edges of the native call graph of a module.
*
* @param connection Connection to a BinNavi database.
* @param rawModuleId ID of the raw module that provides the data.
* @param moduleId ID of the BinNavi module where the edges are created.
*
* @throws SQLException Thrown if creating the edges failed.
*/
public static void createNativeCallgraphEdges(final CConnection connection, final int rawModuleId, final int moduleId) throws SQLException {
Preconditions.checkNotNull(connection, "IE01870: connection argument can not be null");
final String query = " { call create_native_callgraph_edges(?, ?) } ";
final CallableStatement call = connection.getConnection().prepareCall(query);
call.setInt(1, rawModuleId);
call.setInt(2, moduleId);
call.execute();
}
use of java.sql.CallableStatement in project hibernate-orm by hibernate.
the class PostgreSQLStoredProcedureTest method testFunctionWithJDBCByName.
@Test
public void testFunctionWithJDBCByName() {
EntityManager entityManager = createEntityManager();
entityManager.getTransaction().begin();
try {
Session session = entityManager.unwrap(Session.class);
Long phoneCount = session.doReturningWork(new ReturningWork<Long>() {
@Override
public Long execute(Connection connection) throws SQLException {
CallableStatement function = null;
try {
function = connection.prepareCall("{ ? = call sp_count_phones(?) }");
function.registerOutParameter("phoneCount", Types.BIGINT);
function.setLong("personId", 1L);
function.execute();
return function.getLong(1);
} finally {
if (function != null) {
function.close();
}
}
}
});
assertEquals(Long.valueOf(2), phoneCount);
} catch (Exception e) {
assertEquals(SQLFeatureNotSupportedException.class, e.getCause().getClass());
} finally {
entityManager.getTransaction().rollback();
entityManager.close();
}
}
use of java.sql.CallableStatement in project hibernate-orm by hibernate.
the class PostgreSQLStoredProcedureTest method testFunctionWithJDBC.
@Test
public void testFunctionWithJDBC() {
EntityManager entityManager = createEntityManager();
entityManager.getTransaction().begin();
try {
Session session = entityManager.unwrap(Session.class);
Long phoneCount = session.doReturningWork(new ReturningWork<Long>() {
@Override
public Long execute(Connection connection) throws SQLException {
CallableStatement function = null;
try {
function = connection.prepareCall("{ ? = call sp_count_phones(?) }");
function.registerOutParameter(1, Types.BIGINT);
function.setLong(2, 1L);
function.execute();
return function.getLong(1);
} finally {
if (function != null) {
function.close();
}
}
}
});
assertEquals(Long.valueOf(2), phoneCount);
} finally {
entityManager.getTransaction().rollback();
entityManager.close();
}
}
Aggregations