Thursday, March 28, 2013

Insufficient Access Exception when adding new column to SQL statement

I had a strange thing happen today.   I needed to add a new column to an existing java agent that uses JDBC to pull from Oracle.  

I had two agents that do the same thing except pull from different tables.   Yesterday I added the new column to the first agent and everything ran fine.   Today I was fixing the second agent, and after adding the new column, I got  an "Insufficient Access Exception" from Oracle.   I added it the exact same way as I did to the first agent. 

After trying all sorts of things and talking with the DBA, he moved the column to a different place with the statement and it worked.   Crazy!!   Before changing it, the statement worked when you copied it and ran in an TOra Oracle client.   For some reason, changing the order fixed the issues and the column read fine and caused no exceptions.  

When I first added the column, I added to the end.  Moving towards the beginning of the statement fixed the issue.   Note:  there was no comma after the last column, and there was a space before the FROM.  The syntax was correct.

Lesson:   In JDBC, changing column order can sometimes fix strange exceptions.   Why:  who knows.

No comments:

Post a Comment