longnvarchar column with sql server 2008 causes IllegalAttributeException
-------------------------------------------------------------------------
Key: GEOT-3260
URL: http://jira.codehaus.org/browse/GEOT-3260
Project: GeoTools
Issue Type: Bug
Components: data jdbc
Affects Versions: 2.0.0
Environment: Microsoft SQL Server 2008 with sqljdbc4.jar version 3.0
Reporter: Rini Angreani
Fix For: 2.6.6
I found this bug when accidentally using the wrong config file while fixing
another bug.
There's an ntext column (LONGNVARCHAR) in the SQL database (Microsoft SQL
Server 2008).
When using sqljdbc.jar from version 1.2, I didn't get the error, because the
column was read with a different sqlType (as VARCHAR with sqlType = 12, if I'm
not mistaken ).
When using sqljdbc4.jar from version 3.0, it returns LONGNVARCHAR with sqltype
= -16.
The exception I was getting was: org.geotools.feature.IllegalAttributeException
in gt-app-schema, which is caused by the missing mapping for the type.
Tracing the cause, there was a warning in:
org.geotools.jdbc.JDBCFeatureSource line 263:
{code}
// if still not found, ignore the column we don't know about
if (binding == null) {
getDataStore().getLogger().warning("Could not find mapping
for '" + name
+ "', ignoring the column and setting the feature
type read only");
readOnly = true;
continue;
}
{code}
Then I realised, the sql mapping for LONGNVARCHAR is missing in
SQLDialect.class, and not provided in the subclasses either. This should be a
simple fix in SQLDialect.class:
{code}
public void registerSqlTypeToClassMappings(Map<Integer, Class<?>> mappings) {
mappings.put(new Integer(Types.LONGNVARCHAR), String.class);
{code}
This is no longer required for the client, since we're not using the column
anymore, but might be needed for the future.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
------------------------------------------------------------------------------
This SF.net Dev2Dev email is sponsored by:
Show off your parallel programming skills.
Enter the Intel(R) Threading Challenge 2010.
http://p.sf.net/sfu/intel-thread-sfd
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel