In an attempt to migrate from MySQL to H2 I needed to have case
sensitive column
names within the database.

I tried DATABASE_TO_UPPER=FALSE and basically this did what I needed.
However,
it turned out that hibernate (hbm2ddl) did not work with that setup -
and I found two
reasons:

1) values reported by DatabaseMetaData were not adapted to the modified
setting.
2) H2 dialect references information_schema instead of INFORMATION_SCHEMA.

For 2) I am not sure if you feel responsible for fixing it - or should I
post an errror report
to the hibernate team?


I am not sure if attachments will make it through the discussion group.
If not,
I can make them available upon request:

- A test program using hibernate and H2 (HibTest.java)
- A modified H2Dialect.java
- a patch (metadata.patch) for JdbcDatabaseMetaData.java and
JdbcConnection.java. The
  latter is only a quick & dirty solution for getting access to the URL
parameters -
  and there is probably a nicer way to do that.

Stephan

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/h2-database?hl=en.

/**
 * (c) DICOS GmbH, 2011
 *
 * $Id$
 */

package com.shesse.h2test;

import java.io.Serializable;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.cfg.Configuration;

/**
 *
 * @author sth
 */
@Entity
@Table( name = "HibTest" )
public class HibTest
implements Serializable
{
    // /////////////////////////////////////////////////////////
    // Class Members
    // /////////////////////////////////////////////////////////
    
    /** */
    private static final long serialVersionUID = 1L;

    private String id = null;
    
    private int bbb;

    private int cccDdd;

    // /////////////////////////////////////////////////////////
    // Constructors
    // /////////////////////////////////////////////////////////
    /**
     */
    public HibTest()
    {
	this.bbb = 1;
	this.cccDdd = 2;
    }


    /**
     */
    public HibTest(int bbb, int cccDdd)
    {
	this.bbb = bbb;
	this.cccDdd = cccDdd;
    }


   // /////////////////////////////////////////////////////////
    // Methods
    // /////////////////////////////////////////////////////////
    /**
     * @return the id
     */
    @Id 
    @GeneratedValue(generator="system-uuid")
    @GenericGenerator(name="system-uuid", strategy = "uuid")
    public String getId()
    {
        return id;
    }


    /**
     * @param id the id to set
     */
    public void setId(String aaa)
    {
        this.id = aaa;
    }


    /**
     * @return the bbb
     */
    public int getBbb()
    {
        return bbb;
    }


    /**
     * @param bbb the bbb to set
     */
    public void setBbb(int bbb)
    {
        this.bbb = bbb;
    }


    /**
     * @return the cccDdd
     */
    public int getCccDdd()
    {
        return cccDdd;
    }


    /**
     * @param cccDdd the cccDdd to set
     */
    public void setCccDdd(int cccDdd)
    {
        this.cccDdd = cccDdd;
    }

    /**
     * 
     */
    public static void main(String[] args)
    {
	Configuration cfg = new Configuration();

	boolean useH2 = true;
	if (useH2) {
	    cfg = cfg.setProperty("hibernate.connection.driver_class", "org.h2.Driver");
	    cfg = cfg.setProperty("hibernate.connection.url", "jdbc:h2:~/tmp/hibtest;DATABASE_TO_UPPER=FALSE");
	    //cfg = cfg.setProperty("hibernate.dialect", "org.hibernate.dialect.H2Dialect");
	    cfg = cfg.setProperty("hibernate.dialect", "com.shesse.h2test.H2Dialect");
	    cfg = cfg.setProperty("hibernate.connection.username", "sa");
	    cfg = cfg.setProperty("hibernate.connection.password", "");
	} else {
	    cfg = cfg.setProperty("hibernate.connection.driver_class", "com.mysql.jdbc.Driver");
	    cfg = cfg.setProperty("hibernate.connection.url", "jdbc:mysql://localhost:3306/hibtest");
	    cfg = cfg.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQLDialect");
	    cfg = cfg.setProperty("hibernate.connection.username", "hibtest");
	    cfg = cfg.setProperty("hibernate.connection.password", "hibtest");
	}

	cfg = cfg.setProperty("hibernate.connection.pool_size", "1");
	cfg = cfg.setProperty("hibernate.cache.provider_class", "org.hibernate.cache.NoCacheProvider");
	cfg = cfg.setProperty("hibernate.show_sql", "true");
	cfg = cfg.setProperty("hibernate.hbm2ddl.auto", "update");
	cfg = cfg.setProperty("hibernate.connection.release_mode", "auto");
	cfg = cfg.setProperty("hibernate.current_session_context_class", "thread");
	
	cfg = cfg.addAnnotatedClass(HibTest.class);
	    
	SessionFactory sessionFactory = cfg.buildSessionFactory();
	
	Session session = sessionFactory.openSession();
	session.beginTransaction();
	session.save( new HibTest(1, 1) );
	session.save( new HibTest(2, 2) );
	session.getTransaction().commit();
	session.close();

	sessionFactory.close();
    }
    
    
    // /////////////////////////////////////////////////////////
    // Inner Classes
    // /////////////////////////////////////////////////////////


}
/*
 * Hibernate, Relational Persistence for Idiomatic Java
 *
 * Copyright (c) 2010, Red Hat Inc. or third-party contributors as
 * indicated by the @author tags or express copyright attribution
 * statements applied by the authors.  All third-party contributions are
 * distributed under license by Red Hat Inc.
 *
 * This copyrighted material is made available to anyone wishing to use, modify,
 * copy, or redistribute it subject to the terms and conditions of the GNU
 * Lesser General Public License, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
 * for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this distribution; if not, write to:
 * Free Software Foundation, Inc.
 * 51 Franklin Street, Fifth Floor
 * Boston, MA  02110-1301  USA
 */
package com.shesse.h2test;

import java.sql.SQLException;
import java.sql.Types;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.hibernate.cfg.Environment;
import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.function.AvgWithArgumentCastFunction;
import org.hibernate.dialect.function.NoArgSQLFunction;
import org.hibernate.dialect.function.StandardSQLFunction;
import org.hibernate.dialect.function.VarArgsSQLFunction;
import org.hibernate.exception.TemplatedViolatedConstraintNameExtracter;
import org.hibernate.exception.ViolatedConstraintNameExtracter;
import org.hibernate.type.StandardBasicTypes;
import org.hibernate.util.ReflectHelper;

/**
 * A dialect compatible with the H2 database.
 *
 * @author Thomas Mueller
 */
public class H2Dialect extends Dialect {
	private static final Logger log = LoggerFactory.getLogger( H2Dialect.class );

	private String querySequenceString;

	public H2Dialect() {
		super();

		querySequenceString = "select SEQUENCE_NAME from INFORMATION_SCHEMA.SEQUENCES";
		try {
			// HHH-2300
			final Class constants = ReflectHelper.classForName( "org.h2.engine.Constants" );
			final int majorVersion = ( Integer ) constants.getDeclaredField( "VERSION_MAJOR" ).get( null );
			final int minorVersion = ( Integer ) constants.getDeclaredField( "VERSION_MINOR" ).get( null );
			final int buildId = ( Integer ) constants.getDeclaredField( "BUILD_ID" ).get( null );
			if ( buildId < 32 ) {
				querySequenceString = "select NAME from INFORMATION_SCHEMA.SEQUENCES";
			}
			if ( !( majorVersion > 1 || minorVersion > 2 || buildId >= 139 ) ) {
				log.warn(
						"The {} version of H2 implements temporary table creation such that it commits " +
								"current transaction; multi-table, bulk hql/jpaql will not work properly",
						( majorVersion + "." + minorVersion + "." + buildId )
				);
			}
		}
		catch ( Exception e ) {
			// ignore (probably H2 not in the classpath)
		}

		registerColumnType( Types.BOOLEAN, "boolean" );
		registerColumnType( Types.BIGINT, "bigint" );
		registerColumnType( Types.BINARY, "binary" );
		registerColumnType( Types.BIT, "boolean" );
		registerColumnType( Types.CHAR, "char($l)" );
		registerColumnType( Types.DATE, "date" );
		registerColumnType( Types.DECIMAL, "decimal($p,$s)" );
		registerColumnType( Types.NUMERIC, "decimal($p,$s)" );
		registerColumnType( Types.DOUBLE, "double" );
		registerColumnType( Types.FLOAT, "float" );
		registerColumnType( Types.INTEGER, "integer" );
		registerColumnType( Types.LONGVARBINARY, "longvarbinary" );
		registerColumnType( Types.LONGVARCHAR, "longvarchar" );
		registerColumnType( Types.REAL, "real" );
		registerColumnType( Types.SMALLINT, "smallint" );
		registerColumnType( Types.TINYINT, "tinyint" );
		registerColumnType( Types.TIME, "time" );
		registerColumnType( Types.TIMESTAMP, "timestamp" );
		registerColumnType( Types.VARCHAR, "varchar($l)" );
		registerColumnType( Types.VARBINARY, "binary($l)" );
		registerColumnType( Types.BLOB, "blob" );
		registerColumnType( Types.CLOB, "clob" );

		// Aggregations ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
		registerFunction( "avg", new AvgWithArgumentCastFunction( "double" ) );

		// select topic, syntax from information_schema.help
		// where section like 'Function%' order by section, topic
		//
		// see also ->  http://www.h2database.com/html/functions.html

		// Numeric Functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
		registerFunction( "acos", new StandardSQLFunction( "acos", StandardBasicTypes.DOUBLE ) );
		registerFunction( "asin", new StandardSQLFunction( "asin", StandardBasicTypes.DOUBLE ) );
		registerFunction( "atan", new StandardSQLFunction( "atan", StandardBasicTypes.DOUBLE ) );
		registerFunction( "atan2", new StandardSQLFunction( "atan2", StandardBasicTypes.DOUBLE ) );
		registerFunction( "bitand", new StandardSQLFunction( "bitand", StandardBasicTypes.INTEGER ) );
		registerFunction( "bitor", new StandardSQLFunction( "bitor", StandardBasicTypes.INTEGER ) );
		registerFunction( "bitxor", new StandardSQLFunction( "bitxor", StandardBasicTypes.INTEGER ) );
		registerFunction( "ceiling", new StandardSQLFunction( "ceiling", StandardBasicTypes.DOUBLE ) );
		registerFunction( "cos", new StandardSQLFunction( "cos", StandardBasicTypes.DOUBLE ) );
		registerFunction( "compress", new StandardSQLFunction( "compress", StandardBasicTypes.BINARY ) );
		registerFunction( "cot", new StandardSQLFunction( "cot", StandardBasicTypes.DOUBLE ) );
		registerFunction( "decrypt", new StandardSQLFunction( "decrypt", StandardBasicTypes.BINARY ) );
		registerFunction( "degrees", new StandardSQLFunction( "degrees", StandardBasicTypes.DOUBLE ) );
		registerFunction( "encrypt", new StandardSQLFunction( "encrypt", StandardBasicTypes.BINARY ) );
		registerFunction( "exp", new StandardSQLFunction( "exp", StandardBasicTypes.DOUBLE ) );
		registerFunction( "expand", new StandardSQLFunction( "compress", StandardBasicTypes.BINARY ) );
		registerFunction( "floor", new StandardSQLFunction( "floor", StandardBasicTypes.DOUBLE ) );
		registerFunction( "hash", new StandardSQLFunction( "hash", StandardBasicTypes.BINARY ) );
		registerFunction( "log", new StandardSQLFunction( "log", StandardBasicTypes.DOUBLE ) );
		registerFunction( "log10", new StandardSQLFunction( "log10", StandardBasicTypes.DOUBLE ) );
		registerFunction( "pi", new NoArgSQLFunction( "pi", StandardBasicTypes.DOUBLE ) );
		registerFunction( "power", new StandardSQLFunction( "power", StandardBasicTypes.DOUBLE ) );
		registerFunction( "radians", new StandardSQLFunction( "radians", StandardBasicTypes.DOUBLE ) );
		registerFunction( "rand", new NoArgSQLFunction( "rand", StandardBasicTypes.DOUBLE ) );
		registerFunction( "round", new StandardSQLFunction( "round", StandardBasicTypes.DOUBLE ) );
		registerFunction( "roundmagic", new StandardSQLFunction( "roundmagic", StandardBasicTypes.DOUBLE ) );
		registerFunction( "sign", new StandardSQLFunction( "sign", StandardBasicTypes.INTEGER ) );
		registerFunction( "sin", new StandardSQLFunction( "sin", StandardBasicTypes.DOUBLE ) );
		registerFunction( "tan", new StandardSQLFunction( "tan", StandardBasicTypes.DOUBLE ) );
		registerFunction( "truncate", new StandardSQLFunction( "truncate", StandardBasicTypes.DOUBLE ) );

		// String Functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
		registerFunction( "ascii", new StandardSQLFunction( "ascii", StandardBasicTypes.INTEGER ) );
		registerFunction( "char", new StandardSQLFunction( "char", StandardBasicTypes.CHARACTER ) );
		registerFunction( "concat", new VarArgsSQLFunction( StandardBasicTypes.STRING, "(", "||", ")" ) );
		registerFunction( "difference", new StandardSQLFunction( "difference", StandardBasicTypes.INTEGER ) );
		registerFunction( "hextoraw", new StandardSQLFunction( "hextoraw", StandardBasicTypes.STRING ) );
		registerFunction( "insert", new StandardSQLFunction( "lower", StandardBasicTypes.STRING ) );
		registerFunction( "left", new StandardSQLFunction( "left", StandardBasicTypes.STRING ) );
		registerFunction( "lcase", new StandardSQLFunction( "lcase", StandardBasicTypes.STRING ) );
		registerFunction( "ltrim", new StandardSQLFunction( "ltrim", StandardBasicTypes.STRING ) );
		registerFunction( "octet_length", new StandardSQLFunction( "octet_length", StandardBasicTypes.INTEGER ) );
		registerFunction( "position", new StandardSQLFunction( "position", StandardBasicTypes.INTEGER ) );
		registerFunction( "rawtohex", new StandardSQLFunction( "rawtohex", StandardBasicTypes.STRING ) );
		registerFunction( "repeat", new StandardSQLFunction( "repeat", StandardBasicTypes.STRING ) );
		registerFunction( "replace", new StandardSQLFunction( "replace", StandardBasicTypes.STRING ) );
		registerFunction( "right", new StandardSQLFunction( "right", StandardBasicTypes.STRING ) );
		registerFunction( "rtrim", new StandardSQLFunction( "rtrim", StandardBasicTypes.STRING ) );
		registerFunction( "soundex", new StandardSQLFunction( "soundex", StandardBasicTypes.STRING ) );
		registerFunction( "space", new StandardSQLFunction( "space", StandardBasicTypes.STRING ) );
		registerFunction( "stringencode", new StandardSQLFunction( "stringencode", StandardBasicTypes.STRING ) );
		registerFunction( "stringdecode", new StandardSQLFunction( "stringdecode", StandardBasicTypes.STRING ) );
		registerFunction( "stringtoutf8", new StandardSQLFunction( "stringtoutf8", StandardBasicTypes.BINARY ) );
		registerFunction( "ucase", new StandardSQLFunction( "ucase", StandardBasicTypes.STRING ) );
		registerFunction( "utf8tostring", new StandardSQLFunction( "utf8tostring", StandardBasicTypes.STRING ) );

		// Time and Date Functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
		registerFunction( "curdate", new NoArgSQLFunction( "curdate", StandardBasicTypes.DATE ) );
		registerFunction( "curtime", new NoArgSQLFunction( "curtime", StandardBasicTypes.TIME ) );
		registerFunction( "curtimestamp", new NoArgSQLFunction( "curtimestamp", StandardBasicTypes.TIME ) );
		registerFunction( "current_date", new NoArgSQLFunction( "current_date", StandardBasicTypes.DATE ) );
		registerFunction( "current_time", new NoArgSQLFunction( "current_time", StandardBasicTypes.TIME ) );
		registerFunction( "current_timestamp", new NoArgSQLFunction( "current_timestamp", StandardBasicTypes.TIMESTAMP ) );
		registerFunction( "datediff", new StandardSQLFunction( "datediff", StandardBasicTypes.INTEGER ) );
		registerFunction( "dayname", new StandardSQLFunction( "dayname", StandardBasicTypes.STRING ) );
		registerFunction( "dayofmonth", new StandardSQLFunction( "dayofmonth", StandardBasicTypes.INTEGER ) );
		registerFunction( "dayofweek", new StandardSQLFunction( "dayofweek", StandardBasicTypes.INTEGER ) );
		registerFunction( "dayofyear", new StandardSQLFunction( "dayofyear", StandardBasicTypes.INTEGER ) );
		registerFunction( "monthname", new StandardSQLFunction( "monthname", StandardBasicTypes.STRING ) );
		registerFunction( "now", new NoArgSQLFunction( "now", StandardBasicTypes.TIMESTAMP ) );
		registerFunction( "quarter", new StandardSQLFunction( "quarter", StandardBasicTypes.INTEGER ) );
		registerFunction( "week", new StandardSQLFunction( "week", StandardBasicTypes.INTEGER ) );

		// System Functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
		registerFunction( "database", new NoArgSQLFunction( "database", StandardBasicTypes.STRING ) );
		registerFunction( "user", new NoArgSQLFunction( "user", StandardBasicTypes.STRING ) );

		getDefaultProperties().setProperty( Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE );
	}

	public String getAddColumnString() {
		return "add column";
	}

	public boolean supportsIdentityColumns() {
		return true;
	}

	public String getIdentityColumnString() {
		return "generated by default as identity"; // not null is implicit
	}

	public String getIdentitySelectString() {
		return "call identity()";
	}

	public String getIdentityInsertString() {
		return "null";
	}

	public String getForUpdateString() {
		return " for update";
	}

	public boolean supportsUnique() {
		return true;
	}

	public boolean supportsLimit() {
		return true;
	}

	public String getLimitString(String sql, boolean hasOffset) {
		return new StringBuffer( sql.length() + 20 )
				.append( sql )
				.append( hasOffset ? " limit ? offset ?" : " limit ?" )
				.toString();
	}

	public boolean bindLimitParametersInReverseOrder() {
		return true;
	}

	public boolean bindLimitParametersFirst() {
		return false;
	}

	public boolean supportsIfExistsAfterTableName() {
		return true;
	}

	public boolean supportsSequences() {
		return true;
	}

	public boolean supportsPooledSequences() {
		return true;
	}

	public String getCreateSequenceString(String sequenceName) {
		return "create sequence " + sequenceName;
	}

	public String getDropSequenceString(String sequenceName) {
		return "drop sequence " + sequenceName;
	}

	public String getSelectSequenceNextValString(String sequenceName) {
		return "next value for " + sequenceName;
	}

	public String getSequenceNextValString(String sequenceName) {
		return "call next value for " + sequenceName;
	}

	public String getQuerySequencesString() {
		return querySequenceString;
	}

	public ViolatedConstraintNameExtracter getViolatedConstraintNameExtracter() {
		return EXTRACTER;
	}

	private static ViolatedConstraintNameExtracter EXTRACTER = new TemplatedViolatedConstraintNameExtracter() {
		/**
		 * Extract the name of the violated constraint from the given SQLException.
		 *
		 * @param sqle The exception that was the result of the constraint violation.
		 * @return The extracted constraint name.
		 */
		public String extractConstraintName(SQLException sqle) {
			String constraintName = null;
			// 23000: Check constraint violation: {0}
			// 23001: Unique index or primary key violation: {0}
			if ( sqle.getSQLState().startsWith( "23" ) ) {
				final String message = sqle.getMessage();
				int idx = message.indexOf( "violation: " );
				if ( idx > 0 ) {
					constraintName = message.substring( idx + "violation: ".length() );
				}
			}
			return constraintName;
		}
	};

	@Override
	public boolean supportsTemporaryTables() {
		return true;
	}

	@Override
	public String getCreateTemporaryTableString() {
		return "create cached local temporary table if not exists";
	}

	@Override
	public Boolean performTemporaryTableDDLInIsolation() {
		return Boolean.FALSE;
	}

	@Override
	public boolean dropTemporaryTableAfterUse() {
		return false;
	}

	public boolean supportsCurrentTimestampSelection() {
		return true;
	}

	public boolean isCurrentTimestampSelectStringCallable() {
		return false;
	}

	public String getCurrentTimestampSelectString() {
		return "call current_timestamp()";
	}

	public boolean supportsUnionAll() {
		return true;
	}


	// Overridden informational metadata ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

	@Override
	public boolean supportsLobValueChangePropogation() {
		return false;
	}

	@Override
	public boolean supportsTupleDistinctCounts() {
		return false;
	}

	@Override
	public boolean doesReadCommittedCauseWritersToBlockReaders() {
		// see http://groups.google.com/group/h2-database/browse_thread/thread/562d8a49e2dabe99?hl=en
		return true;
	}
}
Index: src/main/org/h2/jdbc/JdbcConnection.java
===================================================================
--- src/main/org/h2/jdbc/JdbcConnection.java	(revision 3705)
+++ src/main/org/h2/jdbc/JdbcConnection.java	(working copy)
@@ -70,6 +70,7 @@
 
     private String url;
     private String user;
+    ConnectionInfo connectionInfo;
 
     // ResultSet.HOLD_CURSORS_OVER_COMMIT
     private int holdability = 1;
@@ -118,6 +119,7 @@
                         + ", " + quote(user) + ", \"\");");
             }
             this.url = ci.getURL();
+            this.connectionInfo = ci;
             closeOld();
             watcher = CloseWatcher.register(this, session, keepOpenStackTrace);
         } catch (Exception e) {
@@ -135,6 +137,7 @@
         setTrace(trace, TraceObject.CONNECTION, id);
         this.user = clone.user;
         this.url = clone.url;
+        this.connectionInfo = clone.connectionInfo;
         this.catalog = clone.catalog;
         this.commit = clone.commit;
         this.getGeneratedKeys = clone.getGeneratedKeys;
@@ -154,6 +157,7 @@
         setTrace(trace, TraceObject.CONNECTION, id);
         this.user = user;
         this.url = url;
+        this.connectionInfo = new ConnectionInfo(url, new Properties());
     }
 
     private void closeOld() {
Index: src/main/org/h2/jdbc/JdbcDatabaseMetaData.java
===================================================================
--- src/main/org/h2/jdbc/JdbcDatabaseMetaData.java	(revision 3703)
+++ src/main/org/h2/jdbc/JdbcDatabaseMetaData.java	(working copy)
@@ -15,6 +15,7 @@
 //## Java 1.6 end ##
 import java.sql.SQLException;
 
+import org.h2.constant.DbSettings;
 import org.h2.constant.SysProperties;
 import org.h2.engine.Constants;
 import org.h2.message.Trace;
@@ -2258,9 +2259,33 @@
      *
      * @return false
      */
-    public boolean supportsMixedCaseIdentifiers() {
+    public boolean supportsMixedCaseIdentifiers()
+    throws SQLException {
         debugCodeCall("supportsMixedCaseIdentifiers");
-        return false;
+        return !isDatabaseToUpper(); 
+    }
+    
+    /**
+     * @throws SQLException 
+     * 
+     */
+    private boolean isDatabaseToUpper() throws SQLException
+    {
+	String url = conn.connectionInfo.getOriginalURL();
+	final String toUpper = ";DATABASE_TO_UPPER=";
+	int tui = url.indexOf(toUpper);
+	if (tui < 0) {
+	    return true;
+	}
+	
+	int etuv = url.indexOf(";", tui+1);
+	if (etuv < 0) {
+	    etuv = url.length();
+	}
+	
+	String tuv = url.substring(tui+toUpper.length(), etuv);
+	
+	return Boolean.parseBoolean(tuv);
     }
 
     /**
@@ -2280,9 +2305,9 @@
      *
      * @return true
      */
-    public boolean storesUpperCaseIdentifiers() {
+    public boolean storesUpperCaseIdentifiers()  throws SQLException {
         debugCodeCall("storesUpperCaseIdentifiers");
-        return true;
+        return isDatabaseToUpper();
     }
 
     /**
@@ -2291,7 +2316,7 @@
      *
      * @return false
      */
-    public boolean storesLowerCaseIdentifiers() {
+    public boolean storesLowerCaseIdentifiers() throws SQLException {
         debugCodeCall("storesLowerCaseIdentifiers");
         return false;
     }
@@ -2302,9 +2327,9 @@
      *
      * @return false
      */
-    public boolean storesMixedCaseIdentifiers() {
+    public boolean storesMixedCaseIdentifiers() throws SQLException {
         debugCodeCall("storesMixedCaseIdentifiers");
-        return false;
+        return !isDatabaseToUpper();
     }
 
     /**

Reply via email to