Following this thread where some of you helped me solve a problem I had to run SQL scripts in Java I ended up using CallableStatement to do so.
The issue now is that sometimes I get errors in some SQL files that run sweet on Interactive SQL.
Namely, the greates issue for the moment comes with scripts which contain some ALTER TABLE xxxxx ADD COLUMN Other scripts containing procedures, ALTER TABLE statements which do not add any column and other stuff are not a problem. Scripts containing ADD COLUMN are.
But when the script contains an ADD COLUMN Statement the process throws a -116 Exception
It demands the table to be empty, which is not feasible for our updating processes. I am using Jconnect 7.0 driver to get the connection, by the way.
Any ideas of what's wrong and how to make it up? Thanks a lot.
asked 12 Sep '13, 08:51
Are you attempting to add a non-nullable column without a DEFAULT value? If so, try adding a DEFAULT.
Ah... I believe Java goes through TDS which has a different default nullability for columns than the SQLAnywhere protocol. Try explicitly adding NULL or NOT NULL to the column specification in your ALTER TABLE statement.
the only time you get that error is if you alter statement doesn't have null as the default and the table has rows in it.
ex: alter table foo add columnX char(50) NULL WILL NOT fail on table that has rows
alter table foo add columnX char(50) WILL FAIL if the the table has rows.