Uploaded image for project: 'Derby'
  1. Derby
  2. DERBY-5967

Create some type mapping functions for use in turning JDBC type information into human-readable strings.

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 10.10.1.1
    • 10.10.1.1
    • Tools
    • None
    • Normal

    Description

      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;

      Attachments

        1. TypeMapper.java
          6 kB
          Richard N. Hillegas

        Issue Links

          Activity

            People

              Unassigned Unassigned
              rhillegas Richard N. Hillegas
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: