Peter Heide wrote:
I think that the JdbcRowSetImpl class is not a part of the JDK 7. It could be in a JDBC Driver 4.1 from Microsoft. According to my knowledge there is no such driver from Microsoft realesed so far.
Any Ideas?
I got the same results you did. I got curious about why it failed. Your code worked fine when used on real databases, but the jdbc-odbc driver fails with Excel data sources. (I found that this driver is widely hated. There are alternatives, but I didn't investigate those)
jdbcRowSetImpl IS part of JDK 7, but the source of it is only available in openJDK for reasons I do not understand. To see the actual source, you have to look at the openJDK (
http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/com/sun/rowset/JdbcRowSetImpl.java).
I grabbed that class and debugged it. Your code fails when JdbcRowSetImpl.java tries to call its own setProperties() method and the following two blocks don't work with Excel, apparently:
when I commented those two blocks out of my version of JdbcRowSetImpl, the query to excel worked! So, I guess what you would want to do is create your own class that extends
JdbcRowSetImpl and provide it a setProperties() method that does not try to set QueryTimeout or maxFieldSize. You could call that class PeterHeidesJdbcRowSetImpl .
since you have to change RowSetFactoryImpl to be able to call PeterHeidesJdbcRowSetImpl and RowSetFactoryImpl is "final"
You would have to just forget the factory and replace in your code:
with:
I don't know the implications of breaking the factory paradigm here or relying on or what may break later by overriding, but I found it interesting.