Questions tagged [callable-statement]

CallableStatement is a JDBC API class that provides a way to call stored procedures in a standard way for all RDBMSs. A stored procedure is stored in a database; the call to the stored procedure is what a CallableStatement object contains. This call is written in an escape syntax that may take one of two forms: one form with a result parameter, and the other without one.

CallableStatement is a JDBC API class that provides a way to call stored procedures in a standard way for all RDBMSs. A stored procedure is stored in a database; the call to the stored procedure is what a CallableStatement object contains. This call is written in an escape syntax that may take one of two forms: one form with a result parameter, and the other without one. A result parameter, a kind of OUT parameter, is the return value for the stored procedure. Both forms may have a variable number of parameters used for input (IN parameters), output (OUT parameters), or both (INOUT parameters). A question mark serves as a placeholder for a parameter.

The syntax for invoking a stored procedure using the JDBC API is shown here. Note that the square brackets indicate that what is between them is optional; they are not themselves part of the syntax.

{call procedure_name[(?, ?, ...)]}

The syntax for a procedure that returns a result parameter is:

  {? = call procedure_name[(?, ?, ...)]}

The syntax for a stored procedure with no parameters would look like this:

{call procedure_name}
194 questions
14
votes
2 answers

stored procedures as queries: CallableStatement vs. PreparedStatement

PostgreSQL documentation recommends using a CallableStatement to call stored procedures. In the case of a stored procedure that returns a rowset, what are the differences between using CallableStatement: String callString = "{ call rankFoos(?, ?)…
6
votes
1 answer

Oracle from Java. CallableStatement and Null for object parameter?

I've got, what started as a fairly complex stored procedure boils down to a very simple use case that doesn't seem to be working as i'm expecting. The stored procedure now looks like this for my test: CREATE OR REPLACE PROCEDURE…
Beta033
  • 1,975
  • 9
  • 35
  • 48
5
votes
1 answer

Performance Degradation on CallableStatement

I have a stored procedure in Oracle 11g that I'm calling from a Java program using the Oracle thin database driver and a CallableStatement. This stored procedure is invoked thousands of times in a loop on the same connection. The…
Samhain
  • 1,767
  • 1
  • 12
  • 20
4
votes
1 answer

JDBC Call to a stored procedure returns null

I've got some problems with a stored procedure on an Oracle database. I just want to call a procedure (which has 50 IN parameters and 2 IN OUT parameters) and get these 2 OUT parameters. I'm trying to execute() the associated CallableStatement but…
Fabiz
  • 43
  • 2
  • 8
4
votes
2 answers

Java CallableStatement registerOutParameter, what does it do?

I'm following a guide regarding callable statements. In this guide, it says that I need to register the out parameter with the follow statement: callsts.registerOutParameter(2, java.sql.Types.VARCHAR); QUESTION: Why do I need to do this/what does…
neilnm
  • 183
  • 1
  • 3
  • 8
4
votes
4 answers

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

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…
JonnyWizz
  • 170
  • 1
  • 2
  • 8
3
votes
0 answers

CompletableFuture gets finished by leaving the rest of codes after CallableStatement executed

I wrote a java block to execute a task asynchronously by using the "CompletableFuture". It worked well thru all the codes above the "CallableStatement" block, but it didn't execute all the codes below the block. I tried to return simple response…
Wilson
  • 39
  • 6
3
votes
3 answers
3
votes
1 answer

DatabaseMetaData getProcedureColumns stored procedure column names order?

I use databasemetadata to get columns (read parameters) of a stored procedure on SQL server: Connection connection = getConnection(); //getting the connection - DatabaseMetaData dbMetaData = connection.getMetaData(); HashMap
HBK
  • 735
  • 1
  • 11
  • 29
3
votes
2 answers

Cannot retrieve the value I desired to Select using Stored Procedure

I'm trying to find a record. Which let me choose to find a existing record in my database using Stored Procedure. When I tried to search a existing data it doesn't give me the value that I want. When I hit the search button it's not printing the…
Francisunoxx
  • 1,440
  • 3
  • 22
  • 45
3
votes
1 answer

SQLException: Cannot submit statement in current context

I encountered this exception when calling a stored procedure through a prepared statement, however, it works for callable statement. I am wondering if it is a must to use callable statement for invoking a stored procedure in voltdb? String sql =…
David
  • 420
  • 2
  • 5
  • 18
3
votes
0 answers

Calling procedure from Java and using RAISERROR to throw exceptions

I’m calling MsSql procedures from JAVA to create invoices using following code: CallableStatement cstmt = conn.prepareCall(sql); cstmt.registerOutParameter(1, java.sql.Types.VARCHAR); cstmt.execute(); resultValue = cstmt.getString(1); … And in my…
Kiki
  • 2,243
  • 5
  • 30
  • 43
3
votes
3 answers

Is CallableStatement really immune to SQL injection?

We have a Java application that communicates with multiple SQL Server databases on the same box. The number of and names of these databases vary. By and large, we use almost exclusively stored procedures with CallableStatement to access the…
Brandon
  • 9,822
  • 3
  • 27
  • 37
3
votes
3 answers

How do you get multiple resultset from a single CallableStatement?

When I call the stored proc from command line I get the following. CALL `events`.`get_event_by_id`(10) +---------+----------+-------------+---------------------+---------------------+---------------------+--------+----------+ | evet_id | name …
James
  • 9,694
  • 5
  • 32
  • 38
2
votes
2 answers

How to execute Multiple Return types Oracle Procedure with Hibernate?

For single output types my code is working fine but I couldn't get how to execute Oracle Procedure which has multiple output parameters and what will be the Output i.e ResultSet, Number etc. abcProcedure(param1 OUT NUMBER,param2 OUT NUMBER,param3…
Shehzad
  • 2,870
  • 17
  • 21
1
2 3
12 13