File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes JDBC multiple statements in prepatedStatement? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "JDBC multiple statements in prepatedStatement?" Watch "JDBC multiple statements in prepatedStatement?" New topic
Author

JDBC multiple statements in prepatedStatement?

John Schretz
Ranch Hand

Joined: Sep 10, 2008
Posts: 188

I am currently using preparedStatements to do selects in my web app.

I need to do this:

SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED ;
SELECT * FROM TABLE_NAME ;
SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ ;

So i can have no lock on the table when I select from it.

How would I do that in a prepared statement or regular statement in java?
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30068
    
149

John,
You wouldn't. You would use a transaction manager to control the transaction. I don't follow the example yet. Those isolation levels don't have meaning for just one statement.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
John Schretz
Ranch Hand

Joined: Sep 10, 2008
Posts: 188
I have a website that has a PRODUCT table. when the pages display it selects from this table.

I also have a sync program that sends data to the webserver and either inserts or updates that same product table.

When i monitor the connections in mysql workbench i keep seeing under status for those selects "Locked"

and copying to tmp table. The sync takes forever to finish because of this and then the pages on the website load very slow.

i had this running for 2 years no problem, i dont know if the hosting company messed with the server but i just want to be able to do my inserts and updates on that table without locking when the selects are happening too

the server is set up as MyISAM
 
 
subject: JDBC multiple statements in prepatedStatement?
 
Similar Threads
Transaction isolation level
should we begin and end a transaction for select statement?
Transaction Isolation
concurrency and transaction isolation level
Data concurency