Hi.
I am having problems with LOCK and JAVA.

I need to make sure that no other Process is reading from a table, because in that 
table are unique numbers.
So i want to lock the table, select a number(select * and read the first numer), 
delete this number and release.

But somehow the lock is not working.
Here is what I have tried:

      Connection con = getCon();
      Statement stmt = con.createStatement();
      stmt.execute("LOCK (NOWAIT) TABLE benutzer IN SHARE MODE TABLE benutzer IN 
EXCLUSIVE MODE ");
      System.out.println("before insert");
      stmt.execute("INSERT into test (name) values ('hallo')");
      System.out.println("after insert");

      Thread.sleep(10000);

      stmt.execute("UNLOCK TABLE benutzer IN SHARE MODE TABLE benutzer IN EXCLUSIVE 
MODE ");
      //resultSet.close();
      stmt.close();
      con.close();
      System.out.println("done");


I am starting this twice and both tell me instantly before insert, after insert.
AS I understand lock, the first task should tell me that, but the second should only 
tell before!

What am I doing wrong?

How can I prevent that a unique number is read twice by different task?

Please help!

Phil


-- 
MaxDB Discussion Mailing List
For list archives: http://lists.mysql.com/maxdb
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to