Forums Register Login

How to execute two SQL stmts. simulteneously ?

+Pie Number of slices to send: Send
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.

+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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


+Pie Number of slices to send: Send
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).]
+Pie Number of slices to send: Send
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

 
Those are the largest trousers in the world! Especially when next to this ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1401 times.
Similar Threads
What exactly we mean by Precompiled SQL Statement
prepareStatement returns 0?
Updating tables
Insert CLOB using JDBC
how to convert .csv files into sql server files using java
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 09:05:12.