• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

How to call procedure in JDBC

 
Ranch Hand
Posts: 851
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,



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

Best regards
 
Ranch Hand
Posts: 423
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 851
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks from the bottom of my heart

Best regards
 
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Farakh khan
Ranch Hand
Posts: 851
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


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


 
Sheriff
Posts: 3837
66
Netbeans IDE Oracle Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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).
 
The government thinks you are too stupid to make your own lightbulb choices. But this tiny ad thinks you are smart:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic