aspose file tools*
The moose likes JDBC and the fly likes How to call procedure in JDBC Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "How to call procedure in JDBC" Watch "How to call procedure in JDBC" New topic
Author

How to call procedure in JDBC

Farakh khan
Ranch Hand

Joined: Mar 22, 2008
Posts: 726
Hello,



I want to call above Oracle PL/SQL from Java JDBC. Any help please

Best regards
Ireneusz Kordal
Ranch Hand

Joined: Jun 21, 2008
Posts: 423
Hi,

PL/SQL can be executed from JDBC using CallableStatement or PreparedStatement, like ordinary SQL
Here is a simple example:




You can bind values (use parameters) in your PL/SQL query

Farakh khan
Ranch Hand

Joined: Mar 22, 2008
Posts: 726
Thanks from the bottom of my heart

Best regards
Soumyajit Hazra
Ranch Hand

Joined: Jun 26, 2007
Posts: 136
If the stored procedure is already there then better to use the CallableStatement directly. No need of writing the same stored procedure inside the connection.prepareStatement(). Directly use the CallableStatement with the stored procedure name
Check the link Call Stored Procedure from Java


Java Programmer | SCJP 1.5 | SCWCD 1.4
Farakh khan
Ranch Hand

Joined: Mar 22, 2008
Posts: 726
Soumyajit Hazra wrote:If the stored procedure is already there then better to use the CallableStatement directly. No need of writing the same stored procedure inside the connection.prepareStatement(). Directly use the CallableStatement with the stored procedure name
Check the link Call Stored Procedure from Java


Very very helpful

Appreciated. I am grateful to you

Best regards
Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234



Cant this thing can be done using a normal Statement ??



Save India From Corruption - Anna Hazare.
Martin Vajsar
Sheriff

Joined: Aug 22, 2010
Posts: 3435
    
  47

Ravi Kiran Pattu wrote:
Cant this thing can be done using a normal Statement ??

Yes, it definitely can be run using a Statement. However if it would be used over and over again with just the differences in literal values, then by using the PreparedStatement or CallableStatment you get the benefit of:

1) Sql injection prevention (no arbitrary strings concatenated directly into your SQL code), and

2) faster processing and higher scalability (reusing the PreparedStatement with different values of bind parameters generally saves on database processing by skipping the parse phase, which can be resource consuming and non-scalable in Oracle).
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to call procedure in JDBC
 
Similar Threads
Request.getParameterValues related question
Inserting arrays into database
Search query is taking too long to search
CallableStatement Error on Oracle Stored Procedure.
Displaying record not exists