• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to create a stored procedure in jdbc

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can anyone please let me know how to create a stored procedure in jdbc

eg: I m having a DDL for creating a oracle stored procedure as a string like string query = "create or repalce procedure ...";

When i m trying to execute this query using statement or prepared statement its creating a stored procedure but without a delimiter(';') at the end of procedure.

So running the procedure throwing error.

CallableStatement is used for calling a stored procedure.So i cant use callable statements .



 
Bartender
Posts: 1111
Eclipse IDE Oracle VI Editor
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
why are you trying to do this?
if it changes slightly on every run you should create parameters to encompass those changes...
 
Selvapandian Balasubramanian
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I m creating a swing application.In that application i m taking .sql files and running that scripts .The .sql files can contain all types sql scripts like insert,update, store procedures and functions etc...

I m not using any client program for running this scripts.
 
Wendy L Gibbons
Bartender
Posts: 1111
Eclipse IDE Oracle VI Editor
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
is this for fun or is your boss telling you to?

[edited: why did i think this was a mysql question?]
 
Wendy L Gibbons
Bartender
Posts: 1111
Eclipse IDE Oracle VI Editor
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can you show us a small example of trying to create a stored procedure.

So all the program needs to do is have a string defined of the package you want to create, the connection, the jdbc commands to create the package, and the full stack trace of any exceptions that are thrown. (there is a link about this but couldn't find it)
 
Selvapandian Balasubramanian
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I m reading the .sql file in my swing application and separating each different queries by a delimiter and executing one at a time

I given the full stored procedure create query as input to the jdbc statement and executing the statement.An executing the statement creating a store procedure in Oracle Db

with showing error symbol.After compiling the created procedure in sql client the error will gone and the procedure is executing..
 
Sheriff
Posts: 3837
66
Netbeans IDE Oracle Firefox Browser
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What do you use as a delimiter in the SQL scripts?

You're in effect replicating SQL*plus or SQL Developer. The syntax of SQL scripts is perhaps more complicated. Generally, SQL statements are delimited by semicolons, but PL/SQL blocks are delimited by forward slashes; semicolons inside PL/SQL blocks (this includes definitions of packages and procedures) have to be passed on to the database. Moreover, SQL*plus allows you to override both delimiters, if I'm not mistaken.

My advice: write the exact text of all SQL statements as you're executing them in the database on a console or to the log file. When the exception occurs, you'll have the exact text of the statement you've executed right before. Post here that exact text of the command that is failing; without this, no one is probably able to help.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic