[EMAIL PROTECTED] wrote: > 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.
No answer directly to your question, but another idea. What do you want to do, have a unique (the next) number for the next insert? Why don't you use sequences resp. DEFAULT SERIAL resp. the datatype SERIAL as described here http://www.sapdb.org/7.4/how_tos/numbergen/howto_producenumgen_eng.htm and discussed in this list several times. Maybe this could solve the problem you want to handle with your lock/select/unlock- sequence ... Elke SAP Labs Berlin > 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] -- MaxDB Discussion Mailing List For list archives: http://lists.mysql.com/maxdb To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]
