callable-statement

How do you get multiple resultset from a single CallableStatement?

蓝咒 提交于 2020-07-29 03:23:03
问题 When I call the stored proc from command line I get the following. CALL `events`.`get_event_by_id`(10) +---------+----------+-------------+---------------------+---------------------+---------------------+--------+----------+ | evet_id | name | description | starttime | endtime | last_modified | active | addre_id | +---------+----------+-------------+---------------------+---------------------+---------------------+--------+----------+ | 10 | samole 3 | sanely | 2013-11-27 17:37:00 | 2013-11

How do you get multiple resultset from a single CallableStatement?

别说谁变了你拦得住时间么 提交于 2020-07-29 03:22:00
问题 When I call the stored proc from command line I get the following. CALL `events`.`get_event_by_id`(10) +---------+----------+-------------+---------------------+---------------------+---------------------+--------+----------+ | evet_id | name | description | starttime | endtime | last_modified | active | addre_id | +---------+----------+-------------+---------------------+---------------------+---------------------+--------+----------+ | 10 | samole 3 | sanely | 2013-11-27 17:37:00 | 2013-11

How in JDBC can you call a stored procedure when only setting some parameters

谁都会走 提交于 2019-12-19 03:38:40
问题 What is the best way to make a call to a stored procedure using JDBC if you only want to set some of the parameters? If I was just using SQL, I could set the paramerers by name in the SQL to call the sproc. E.g. if I have a stored procedure with nine parameters and I wanted to set parameters 1,2 and 9, leaving the rest to their default values, I can run this SQL: exec my_stored_procedure @parameter_1 = "ONE", @parameter_2 = "TWO", @parameter_9 = "NINE" Using JDBC (Specifically jConnect 6.0),

Error in rendering data using ResultSet

房东的猫 提交于 2019-12-13 15:53:45
问题 I'm having an error while rendering data using ResultSet. I'm having this error java.sql.SQLException: ResultSet is from UPDATE. No Data. Here's my code snippet ArrayList<String> arrayList = new ArrayList<String>(); Session session = null; Connection conn = null; CallableStatement callableStatement = null; try { // test BeanLocator beanLocator = PortletBeanLocatorUtil .getBeanLocator("Mrcos-services-portlet"); BasicDataSource bds = (BasicDataSource) beanLocator .locate("mrcosDataSourceTarget"

Jaybird CallableStatement not executed until getting output parameter

余生长醉 提交于 2019-12-13 15:41:14
问题 I have this Java code: Connection conn = connectionProvider.getConnection(); statement = conn.prepareCall("execute procedure rm_set_coordinates(?,?,?)"); statement.setInt(1, userId); statement.setString(2, String.valueOf(location.getLatitude())); statement.setString(3, String.valueOf(location.getLongitude())); statement.execute(); Where rm_set_coordinates is Firebird stored procedure: create or alter procedure RM_SET_COORDINATES ( PCAR_LOGIN integer, PLAT varchar(20) = 0, PLNG varchar(20) = 0

How to resolve: CallableStatement executing returns error “ORA-06502: PL/SQL: numeric or value error: character to number conversion error”?

两盒软妹~` 提交于 2019-12-11 14:20:03
问题 I try to put data from string filed of one table to number field of another table. If I do this in some IDE like Oracle SQL Developer or Toad it works fine, but if I do this in my java code I got error. How to resolve it? There is my example below. database: I create two tables - t_num with number field and t_str with varchar2 field - and put values to second table t_str drop table t_num; create table t_num(num number(10,2)); drop table t_str; create table t_str(str varchar2(10)); insert into

Issue with iterating through list of callable

蓝咒 提交于 2019-12-11 13:17:55
问题 I am having an issue with iterating over a list of callables in python. The callables are supposed to be called on a generator of strings. The current behaviour is that the last callable in the list is called as many times as there are callables in the list. My current code: for m in list_of_callables: strings = (m(s) for s in strings) In the above code strings is initially of type 'Generator'. I have also tried the following: for i in range(len(list_of_callables)): strings = (list__of

Passing Scala Option[List[_]] to Java JDBC Array using statement.setArray()

大城市里の小女人 提交于 2019-12-11 13:10:11
问题 I'm trying to build an interface from Scala to JDBC callableStatements. For the most part, it's straightforward, except for Lists . I need to be able to take a Scala List of some type, and convert it into a Java Array that can be passed to statement.setArray(type, array) and I'm not having any luck (partly because I don't know Java and JDBC very well). Here's what I'm trying to do: for (parameter <- ps.parameters) { case GPArrayIn(None, t) => callableStatement.setNull(index, t) case GPIn(v:

CallableStatement.getResultSet() always return null when calling an Oracle function

房东的猫 提交于 2019-12-11 05:55:38
问题 I am executing the following code: CallableStatement cs; cs = conn.prepareCall("{ ? = call mypackage.myfunc()}"); cs.registerOutParameter(1, OracleTypes.CURSOR); System.out.println(cs.execute()); System.out.println(cs.getResultSet()); ResultSet rs = (ResultSet) cs.getObject(1); System.out.println(rs); The function is declared as follows: CREATE OR REPLACE PACKAGE BODY myuser.mypackage AS FUNCTION myfunc return sys_refcursor is a_cursor sys_refcursor; begin open a_cursor for select * from

Parameter number 2 is not an OUT parameter

孤者浪人 提交于 2019-12-02 21:29:55
问题 String sqlString = "{CALL MyStoredProcedure(?,?)}"; CallableStatement sqlStm = connection.prepareCall(sqlString); sqlStm.setString(1, username); sqlStm.registerOutParameter(2, Types.DECIMAL, 0); // <---- ERROR sqlStm.execute(); This is my error stacktrace: java.sql.SQLException: Parameter number 2 is not an OUT parameter at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1073) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:987) at com.mysql.jdbc.SQLError