Code example for DatabaseMetaData

Methods: getColumnsstoresLowerCaseIdentifiers

0
			// DBs treat the meta information differently, in particular case sensitivity. 
			// We need to use the meta information to find out how to treat names 
			String tableNamePattern = generateFinalNamePattern( meta, SOME_ENTITY_TABLE_NAME );
			String columnNamePattern = generateFinalNamePattern( meta, columnName );
 
			ResultSet columnInfo = meta.getColumns( null, null, tableNamePattern, columnNamePattern );
			s.getTransactionCoordinator().getJdbcCoordinator().register(columnInfo, columnInfo.getStatement());
			assertTrue( columnInfo.next() );
			int dataType = columnInfo.getInt( "DATA_TYPE" );
			s.getTransactionCoordinator().getJdbcCoordinator().release( columnInfo );
			assertEquals( 
					columnName,
					JdbcTypeNameMapper.getTypeName( expectedJdbcTypeCode ),
					JdbcTypeNameMapper.getTypeName( dataType )
			); 
		} 
 
		private String generateFinalNamePattern(DatabaseMetaData meta, String name) throws SQLException {
			if ( meta.storesLowerCaseIdentifiers() ) {
				return name.toLowerCase();
			} 
			else { 
				return name;
			}