package com.philmcrew.utility.db; import java.sql.Connection; import java.sql.SQLException; /** * Overrides some methods in a Oracle specific way. Particular problems fixed here include: * - Checking column type before trying to get Statistics Query. * * @author Mitchell J. Friedman */ public class DbSpecificOracle extends DbSpecificBase { public DbSpecificOracle( Connection connection ) throws SQLException { super( connection ); } public String getStatisticsQuery( DbColumnInfo dbColumnInfo ) { String rowName = dbColumnInfo.getColumnName(); String typeName = dbColumnInfo.getTypeName(); StringBuffer buf = new StringBuffer(); buf.append( "select count(distinct " ); buf.append( rowName ); buf.append( "), " ); if( typeName.equals( "bool" ) || typeName.equals( "bytea" ) ) { buf.append( "'na', 'na', " ); } else { buf.append( "min(" ); buf.append( rowName ); buf.append( "), max(" ); buf.append( rowName ); buf.append( "), " ); } if( typeName.equals( "VARCHAR2" ) || typeName.equals( "DATE" ) || typeName.equals( "bool" ) || typeName.equals( "bytea" ) || typeName.equals( "bpchar" ) ) { buf.append( "'na', 'na' " ); } else { buf.append( "avg(" ); buf.append( rowName ); buf.append( "), " ); buf.append( "stddev(" ); buf.append( rowName ); buf.append( ") " ); } // System.out.println("rowName=" + rowName + ";typeName=" + typeName); return buf.toString(); } }