• 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 execute two SQL stmts. simulteneously ?

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When using prepareStatement(String sqlstatement), I want to know how to execute more than one sql statements simulteneously ? Like creating a table and inserting a record while using one prepareStatement(String sqlstatement).
stat=con.prepareStatement("insert into searchResult b_number,b_name,b_author,b_publisher,topic,date_of_postage) values(?,?,?,?,?,?)");
The above is with only one sql statement, what if I want to create a table before inserting in the same prepareStatement().
Certainly, there is a way out, but I do not know.

 
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is no way to execute more than one sql query simultaneously . It depends on the database u r using whether it allows u to do it or not. generally database servers perform multitasking, there it is possible using multithreading in java. one connection accesses the database through a dsn which is explicitly locked so it is possible only through multithreading that too u should not use jdbc-odbc bridge driver. it does not provide this facility.
 
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Vikrant,
You can execute multiple SQL statements by bunching them together as a Stored Procedure and then call CallableStatement object to execute the stored procedure.
Regards,
Milind
 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Milind,
Things will get more clearer if you can kindly give an example.
Waiting for the reply.
Regards,

Originally posted by Milind Kulkarni:
Hi Vikrant,
You can execute multiple SQL statements by bunching them together as a Stored Procedure and then call CallableStatement object to execute the stored procedure.
Regards,
Milind


 
Milind Kulkarni
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Sam,
Stored procedure that is stored in a database can be called using CallableStatement object.
Here are 2 simple examples of CallableStatement object:
Example 1:
CallableStatement cstmt = con.prepareCall("{call getValues(?, ?)}");
Here Connection method prepareCall is used to create a CallableStatement Object. The example above creates an instance of CallableStatement that contains a call to the stored procedure getValues. It has two arguments and no result parameter.
Example 2:
CallableStatement cstmt = con.prepareCall("{? = call getValues[(?, ?, ...)]}");
Here procedure returns a result parameter.
Hope this helps !!
Regards,
Milind

[This message has been edited by Milind Kulkarni (edited July 01, 2000).]
 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Milind ,
I think you can also call it through a cursor though I am not sure.

Originally posted by Milind Kulkarni:
Hi Vikrant,
You can execute multiple SQL statements by bunching them together as a Stored Procedure and then call CallableStatement object to execute the stored procedure.
Regards,
Milind

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic