Concurrent transactions(threading) on the same database on SQL server
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Bhagat_Singh
Posted On:   Friday, September 30, 2005 03:40 PM

Bhagat Singh Concurrent transactions(threading) on the same database on SQL server I wrote a program to connect to a database on SQL server usnig Microsoft JDBC Driver for SQL server. I want to delete two tables simultaneously. One table takes 2 mins to delete and another takes one min to delete. I wrote two class (one each for each table to be deleted) which extend thread. Then I called this for the main method of the third program. like this... Table1Class System.out.println("Table1Class start delete : " + System.currentTimeMillis()); stmt.execute("delete table1"); System.out.println("Table1Class finish d   More>>

Bhagat Singh



Concurrent transactions(threading) on the same database on SQL server


I wrote a program to connect to a database on SQL server usnig Microsoft JDBC Driver for SQL server. I want to delete two tables simultaneously. One table takes 2 mins to delete and another takes one min to delete. I wrote two class (one each for each table to be deleted) which extend thread. Then I called this for the main method of the third program. like this...



Table1Class


System.out.println("Table1Class start delete : " + System.currentTimeMillis());


stmt.execute("delete table1");


System.out.println("Table1Class finish delete : " + System.currentTimeMillis());




Table2Class


System.out.println("Table2Class start delete : " + System.currentTimeMillis());


stmt.execute("delete table2");


System.out.println("Table2Class finish delete : " + System.currentTimeMillis());



Main Program calls the below code.


Table2Class table1= new Table1Class (database Connection object);


table1.start();


Table1Class table2 = new Table1Class (database Connection object);


table2.start();




But when I look at the time I see that the second deletion starts after one table is deleted



Could anyone help me to make these deletions run concurrently.

Thanks,
Bhagat Singh

   <<Less

Re: Concurrent transactions(threading) on the same database on SQL server

Posted By:   srini_vasan  
Posted On:   Tuesday, October 4, 2005 10:59 AM


Hi

Eventhough u can create two threads to run two different
queries, the result will be based on ur Database Internals.



i tried this query with oracle, i got execution time
as if i executed queries sequentially.



i got same result for two different database connections
also.




thanks,

srini

Re: Concurrent transactions(threading) on the same database on SQL server

Posted By:   Joost_Schouten  
Posted On:   Friday, September 30, 2005 06:49 PM

how about:

stmt.execute("DROP TABLE 'table1', 'table2';");

Cheers,

Joost
About | Sitemap | Contact