Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / October 2005

Tip: Looking for answers? Try searching our database.

Build and execute stored procedure 'on the fly'

Thread view: 
iksrazal@terra.com.br - 17 Oct 2005 15:35 GMT
Hi all,

I've been requested to build a String that represents a stored
procedure (SP) dynamically at runtime, and afterwards execute it. The
DB is beta mysql5. My questions are:

1) Is it mandatory that in JDBC a SP be called by a CallableStatement?
For example, a SELECT statement can be built and executed at runtime,
could this also be done for a SP?
2) Does a SP need to be installed into the DB before being invoked?

I ask because I think I my need to install the SP at runtime, after
being built, and then call it via a CallableStatement. This would
require, I believe, redirecting the SP to a SQL client shell via Java
and stdin, and afterwards, invoke the CallableStatement.

Any ideas?
iksrazal
Bjorn Abelli - 17 Oct 2005 22:17 GMT
<iksrazal@terra.com.br> wrote...

> 1) Is it mandatory that in JDBC a SP be called by a CallableStatement?

Yes, although "some" JDBC-drivers could provide other means...

> For example, a SELECT statement can be built and
> executed at runtime, could this also be done for a SP?

That depends on the actual JDBC-driver, but I would say that it should work
in most cases.

But the creation of an SP is "just" a statement (CREATE PROCEDURE...), so
you should use a simple "execute(...)" on a simple "Statement" for that.

> 2) Does a SP need to be installed into the DB before being invoked?

By its nature an SP is an element in the database, so I can't see how it
would be possible to call it otherwise... ?

There's a reason why it's named *stored* procedures... ;-)

// Bjorn A


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.