Patched Oracle's code
At first I thought it was a bug in my code, but it turns out it's actually a bug in Oracle's code. Using the debugger, breaking on SqlException and digging around in memory, I found the SQL string that the Oracle code had generated to send to the database, and found a typo in it.
It should have read "SELECT ..., 93 as data_type, ..." but instead it said "SELECT ..., 93as data_type, ...".
Using the javap tool I was able to inspect the JVM instructions the OracleDatabaseMetaData class was using, and confirm there *is* actually a space missing before the word "as" in the SQL and it's out of my control.
Then I got the bright idea to patch the bytecode. :-)
There's a tool called the Class Construction Kit available from the old BCEL site on Sourceforge. It lets you inspect AND modify Java class files.
I loaded the class file using CCK, it was trivially easy to fix the code. Then it was just a matter of putting the exploded jar file into my classpath and bingo, problem solved, no more SqlException, and my application runs!
It's a good thing I just learned the JVM instruction set for our compiler class this term, it would have been a lot harder to diagnose and fix this problem without that experience.
And people say going back to school was a waste. Hardly.




