This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 245366

Summary: Wrong mapping from NVARCHAR to VARCHAR
Product: db Reporter: cstadler
Component: CodeAssignee: matthias42
Status: RESOLVED FIXED    
Severity: normal Keywords: PATCH_AVAILABLE
Priority: P3    
Version: 8.0   
Hardware: All   
OS: All   
Issue Type: DEFECT Exception Reporter:
Attachments: patch for database metadata model v1
patch for dbschema v1
patch for j2ee.persistence v1

Description cstadler 2014-07-03 05:43:31 UTC
in class org.netbeans.modules.db.metadata.model.jdbc.JDBCUtils.getSQLType(...)

there is a mapping from Unicode-suuporting types to non-Unicode supporting types:

case TypesJDBC4.LONGNVARCHAR: return SQLType.LONGVARCHAR;
case TypesJDBC4.NCHAR: return SQLType.CHAR;
case TypesJDBC4.NCLOB: return SQLType.CLOB;
case TypesJDBC4.NVARCHAR: return SQLType.VARCHAR;

It seems to be wrong, because it should be so:

case TypesJDBC4.LONGNVARCHAR: return SQLType.LONGNVARCHAR;
case TypesJDBC4.NCHAR: return SQLType.NCHAR;
case TypesJDBC4.NCLOB: return SQLType.NCLOB;
case TypesJDBC4.NVARCHAR: return SQLType.NVARCHAR;
Comment 1 j.boesl 2014-08-12 17:20:28 UTC
This is an issue for me, too. 
This mapping must be from pre JDBC4 times. Since it's really simple to fix this is an easy win.
Comment 2 matthias42 2014-08-12 19:12:18 UTC
Created attachment 148658 [details]
patch for database metadata model v1

I'll attach two more patches - this is a revised version of tan older (2009) patch:

http://hg.netbeans.org/main-golden/rev/5e8071a09f05

With the references JDBC types now part of the JDK, the extra definitions can be dropped.

This is not tested - the changes look simple, they compile.

As netbeans still fails to compile with a jdk8 javac and/or against JDK8, I won't put time into running unittests, that flood my console with warnings and errors...
Comment 3 matthias42 2014-08-12 19:13:05 UTC
Created attachment 148659 [details]
patch for dbschema v1
Comment 4 matthias42 2014-08-12 19:15:34 UTC
Created attachment 148660 [details]
patch for j2ee.persistence v1
Comment 5 matthias42 2015-02-01 19:54:32 UTC
Ok - I applied the changes to core-main:

http://hg.netbeans.org/core-main/rev/7ef5e068a091

To be frank: They are the cleanup I promised, but the change is untested, as I did not manage to find a database that reports it columns as SQLType NVARCHAR/NCHAR/NCLOB/...

I tested:

- derby (no matching jdbc type)
- sqlite (fails to retrieve necessary metadata)
- mysql (convert tables created with nchar/nvarchar to the non "N"-Type
- Informix (creates column with the datatype, reports them as basic column type without N)
- oracle (creates column with the datatype, reports them as OTHER datatype)

=> In the next few days a nightly build with this fix will be available and a message will be appended here. Please try that version and check whether you agree, that it is fixed. If you verify, please change the status of this bug to VERIFIED.