• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Invalid Column Name - Java Exception

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I have an issue which user has reported only in production environment. It works fine in Local Environment with production db.

I need to get the next sequence id from a sequence using dual table and then assigned to a variable to insert into the data into the table. Then get the sequence value from Result Set.
When i try to get the value from result set. It raised Invalid Column Name exception only in production environment.
It worked fine in Dev environment with Same DB.

I verified the column name and its fine.

code which caused error :
--------------------------------

rs = ps.executeQuery("SELECT STATUS_LOG_SEQ.nextval as seqId FROM DUAL");
if (rs.next())
{
sequenceId = rs.getInt("seqId");
}

Error message in log file:
------------------------------

2013-11-06 08:18:45,253 ERROR [STATUS_LOG.class] Unable to insert the data into status_log table Invalid column name

I am wondering why the issue is not replicated in local environment with same DB.

Any suggestion most welcome..
 
Ranch Hand
Posts: 1143
1
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sudhir,
I assume you are working with Oracle database.
The query that you are executing may return a value greater than the maximum allowed "int" value.
When retrieving numerical values from Oracle database via JDBC, I recommend using method "getBigDecimal" rather than method "getInt".
Of-course I'm not guaranteeing that this will solve your problem, but I don't think it will make things worse.
Note that in my experience, Oracle error messages can sometimes be misleading.
Just because the error message is Invalid Column Name doesn't mean that that is the actual problem.

Good Luck,
Avi.
 
sudhir pavan
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I seen the sequence value its within the integer range.
current seq value is 74589.
 
Sheriff
Posts: 3837
66
Netbeans IDE Oracle Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Avi, I don't see Oracle error message anywhere there. Oracle's messages have the ORA-XXXXX code, which - even for misleading messages, and there certainly are some - at least allows to google it for more information.

I'd suggest logging complete stack trace with the exception, not only the error message. Without it there is no way to be sure about where the exception originated. The error message mentions the status_log table, but it is nowhere to be seen in the code snippet that was posted. We have no way to tell that the exception really came from that code.

And by the way, this isn't the most efficient way to handle sequences. Oracle (if you really are on Oracle) allows you to use the sequence in the VALUES clause of the INSERT statement itself. If you need to know the value of the generated key(s), you can either use the JDBC mechanism for reading back generated keys, or an Oracle specific RETURNING clause. By reading the value from a sequence you're quite firmly tied to your target database anyway.
 
reply
    Bookmark Topic Watch Topic
  • New Topic