• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

JDBC Driver, Oracle sequence number problems

 
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

This is the code I'm using:
 
author & internet detective
Posts: 39343
755
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
K DeLucia
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks! Makes sense. I'll give it a try!
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!