• 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 I can call Stored Procedure asynchronously from java function

 
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I want to call one Stored Procedure from java function asynchronously that means my function should not wait whether that Stored Procedure executed or not.It should simply call that Stored Procedure and it should not wait for execution.Can any one please guide me how i can do that.
Below r my codes :-

Thanks & Regards
Bikash
[ February 09, 2004: Message edited by: Bikash Paul ]
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving to JDBC.
 
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i think jdbc calls are all blocking. given that, you can start up a "throwaway" thread to do the call, then have your main thread start up the throwaway and carry on. the extra thread just exits when the stored procedure call returns
 
Bikash Paul
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Can u give me some idea how i can use throwaway thread in my function.
Thanks & Regards
Bikash
 
john guthrie
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sorry, i meant that you just create a thread to do the SP call, then exit. just a regular java thread, pooled or otherwise.
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jus try out this code
//this call is the thread class where one will execute the store procedure
class DBProcess implements Runnable
{
private String sp_name;
DBProcess(String sp_name)
{
this.sp_name = sp_name
}

public void run() throws Exception
{
Connection conn = null;
CallableStatement cstmt= null;
try
{
conn = connect("Pdr");
String query = "{ call "+ sp_name+"(?) }";
cstmt = conn.prepareCall(query);
cstmt.setString(1,"PDR_USER");
cstmt.execute();
}
finally
{
if(cstmt != null)
cstmt.close();
if(conn != null)
close(conn);
}
}
}
the following is the calling class
class RunDB
{

public static void main (String[] args)
{
if (args.length > 0)
{
DBProcess db = new DBProcess (args[0]);
try
{
new Thread(db).start();
}
catch (IllegalThreadStateException e)
{
//add code
}
catch (Exception e)
{
//add code
}
}
}
}
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic