Win a copy of Microservices Testing (Live Project) this week in the Spring forum!
  • 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

JDBC Driver, Oracle sequence number problems

 
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 41184
848
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks! Makes sense. I'll give it a try!
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic