Code example for DatabaseMetaData

Methods: getDatabaseMajorVersion, getDatabaseProductName

0
	public static class MySpecialDB2Dialect extends Dialect { 
	} 
 
	public static class MyDialectResolver1 extends AbstractDialectResolver { 
		protected Dialect resolveDialectInternal(DatabaseMetaData metaData) throws SQLException {
			String databaseName = metaData.getDatabaseProductName();
			int databaseMajorVersion = metaData.getDatabaseMajorVersion();
			if ( "MyDatabase1".equals( databaseName ) ) {
				return new MyDialect1(); 
			} 
			if ( "MyDatabase2".equals( databaseName ) ) {
				if ( databaseMajorVersion >= 2 ) {
					return new MyDialect22(); 
				} 
				if ( databaseMajorVersion >= 1 ) {
					return new MyDialect21(); 
				} 
			} 
			return null; 
		} 
	}