[java] Unable to execute a simple SQL statement
At work I need to instruct our Sybase Adaptive Server IQ DB to bulk load from a file at periodic times. The LOAD TABLE command seemed to fit the ticket perfectly, so I built the command and the options from an Interactive SQL session, verifying that the statement was correct. However, when I moved it over to a Java program, it doesn't seem to really do anything. Upon inspection of the server logs, it shows the server as claiming it can't find the end of the record -- which is bollocks.
I'm not sure what would cause it to work in one place, and not another. I'm using Sybase's JDBC driver and just barely changing example code from their website. I looked at this all day. Usenet isn't a ton of help, some people claim you can't issue a LOAD TABLE command from JDBC, while others claim you can. I investigated dynamic SQL creation in Sybase, but that is not as easy as one would think, however.
Just in case it might be something simple. Make sure you do not have a semi-colon on your SQL that is issued from JDBC.
I would point the finger of blame at the JDBC driver.
Bear in mind that most JDBC drivers are pretty crap when it comes down to the infrequently used functions. Whenever I get a problem like this, I:
- check whether I've got the latest driver (they get updated fairly often for most vendors)
- check the bugs list (If I have access to it)
- file a new bug report, and see what happens
If it works on the interactive client then, theoretically, you have good grounds for logging a bug.
Unless you've got a "funky" client setup which is doing some post-processing of your query before sending it?
Bear in mind that most JDBC drivers are pretty crap when it comes down to the infrequently used functions. Whenever I get a problem like this, I:
- check whether I've got the latest driver (they get updated fairly often for most vendors)
- check the bugs list (If I have access to it)
- file a new bug report, and see what happens
If it works on the interactive client then, theoretically, you have good grounds for logging a bug.
Unless you've got a "funky" client setup which is doing some post-processing of your query before sending it?
"Finger of blame?"
For many times I got alot of errors in jdbc driver
untill i started use PrepareStatement before each sqlstring and this ocassionaly ? solved all my problems with this "crap driver" :)
For many times I got alot of errors in jdbc driver
untill i started use PrepareStatement before each sqlstring and this ocassionaly ? solved all my problems with this "crap driver" :)
Quote:Original post by HellCreator
For many times I got alot of errors in jdbc driver
untill i started use PrepareStatement
With a decent IDE you shouldn't get many of those. Certainly, it's not particualrly relevant for this thread, since the OP said he'd tested it in an interactive session and it worked.
If you do enough JDBC work, you discover plenty of situations where your SQL is perfect but the driver (or DB) is broken.
However, if you have problems with typos, I strongly suggest picking up an abstraction layer, or something like Hibernate - I agree it's annoying that there's no compile-time checking on SQL queries embedded in java code.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement