JDBC type to Java type mapping

Different JDBC drivers can have different mappings of JDBC types (or SQL types) to Java types. Because the Service Virtualization virtual JDBC driver does not know what database runs behind your real JDBC driver, the mapping cannot be performed automatically. In some cases, you may need to manually amend or override the default mapping.

Mapping file syntax is a simple key-value pair, where a number on the left side represents the JDBC type, and the Java class which should be used for this particular JDBC type is on the right. For example this is a default mapping file:

Example:  

# According to JDBC recommendation

# TINYINT:

-6 = java.lang.Integer

# SHORTINT:

5 = java.lang.Integer

JDBC type to Java type mapping can be different for different databases, but you can have only one virtual JDBC driver on the classpath. For that reason, Service Virtualization enables you to override default mapping file for each connection you create via the Service Virtualization JDBC driver.

To override default type mapping, you need to specify the typeMapping property. For J2SE you define it in the connection string. For J2EE you define it in the typeMapping property of the data source.

Define the value of the typeMapping property as follows:

  • For a resource on the classpath: typeMapping=META-INF/myTypeMappingProperties
  • For a file on the file system: typeMapping=file:///c:/myMapping.properties

See also: