db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rick Hillegas (JIRA)" <j...@apache.org>
Subject [jira] [Created] (DERBY-5967) Create some type mapping functions for use in turning JDBC type information into human-readable strings.
Date Mon, 29 Oct 2012 13:28:12 GMT
Rick Hillegas created DERBY-5967:
------------------------------------

             Summary: Create some type mapping functions for use in turning JDBC type information
into human-readable strings.
                 Key: DERBY-5967
                 URL: https://issues.apache.org/jira/browse/DERBY-5967
             Project: Derby
          Issue Type: Improvement
          Components: Tools
    Affects Versions: 10.10.0.0
            Reporter: Rick Hillegas
         Attachments: TypeMapper.java

I will attach a set of type mapping functions which turn JDBC type information into human-readable
type names. The two functions do the following:

mapType() - This function turns the JDBC type info into an SQL type name suitable for use
in a Derby CREATE TABLE statement.

mapToJavaType() - This turns the JDBC type info into the corresponding Java type name given
in table B-3 of the JDBC spec.

I am posting these functions in response to the following discussion on derby-user: http://old.nabble.com/export-from-systables-to34607734.html#a34607734

Here is an example of how to use these functions in conjunction with the DatabaseMetaData
wrapper functions attached to DERBY-3973:

connect 'jdbc:derby:memory:db;create=true';

create procedure registerPublicStaticMethods( in connectionURL varchar( 200 ), in printSQL
boolean )
language java parameter style java modifies sql data
external name 'DBMDWrapper.registerPublicStaticMethods';

call registerPublicStaticMethods( 'jdbc:default:connection', false );

create function mapType( jdbcType int, precision int, scale int, foreignTypeName varchar(
100 ) )
returns varchar( 100 )
language java parameter style java deterministic no sql
external name 'TypeMapper.mapType';

create function mapToJavaType( jdbcType int, foreignTypeName varchar( 100 ) )
returns varchar( 100 )
language java parameter style java deterministic no sql
external name 'TypeMapper.mapToJavaType';

select c.table_schem, c.table_name, c.column_name,
       mapType( c.data_type, c.column_size, c.decimal_digits, c.type_name ),
       mapToJavaType( c.data_type, c.type_name )
from table( getColumns( null, null, '%', '%' ) ) c;


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message