What exactly are you trying to do?
Perhaps there is a better way...
I want to use a seq file to replace an oracle sequence.
I place the file in my EJB project,read it and increase it.
Can't you just stick the value in a property file in the deployment?
what is property file?
oracle sequence.nextval only can get the one value,I want get more,sometimes 10,sometimes 100
So I use a file to record the value,I get 10,I icrease 10,
If i can not icrease the value ,I would get a repeat value when I restart the Jboss.
For convenience,I put it in my EJB project,when I move the server,I just need to move the jar.
Umm. Why don't you just bypass the sequence altogether (since you're not really using it as a sequence)?. Store the last used value in a table row and use some "for update" to handle concurrency. Reading and writing a physcial file doesn't feel that robust.
that is the way i am using now.
select .... for update and then update it.
but sometimes it stuck.Looks like a deadlock,after 5000ms jboss throw a timeout Exception.
Maybe there some conflict with lock escalation
Show the entire stack trace if available. In any case, I would say that is the path to follow instead of fiddling with files.
I try to use synchronized,and it didnot happen since now.