I have a web application where users enter some data onto a jsp page. When they submit, a record is created in an Oracle database. I need a sequencial 'Request Number' for my form and I came upon sequences in Oracle. Sounds like it will do just what I need. However, apparently there is a bug with the jdbc drivers where if you try to insert more than 7 field values, you get an ArrayIndexOutOfBoundsException (here is a discussion about it: http://forums.oracle.com/forums/thread.jspa?messageID=2698647 ). This link says it should work with the ojdbc14.jar driver, but I have the same problem when I use that driver. My code does work if I only insert 6 or 7 fields. If I attempt to insert all 11 that I need, I run into the error. So, now I'm working on finding an alternate way to do this. Has anyone run into this before?
The only thing I can think of to work around this is to insert my partial record, then immediately follow that up with an update to that record with the rest of the fields I need inserted. Is this the right way to handle this? I'm pretty new to java so any suggestions are welcome.
Another workaround I've used is another way of dealing with two steps.
1) Write a query to get the next sequence value and return it to your application.
2) Insert a row with all the fields you want including the sequence number.
The advantage to this approach is that you don't have to change any db constraints.