case sensitivity with field names broke with version 1.4.198

45 views
Skip to first unread message

Chris Sunderland

unread,
Jul 22, 2020, 12:12:19 PM7/22/20
to H2 Database
It appears that with version 1.4.198, field names are no longer case insensitive with select statements.  I've tried adding IGNORECASE=TRUE and other collation statements but nothing appears to work here.

Is there something I need to add now to my connection string or to the create table statement to allow for case insensitive queries again?

With this example code, this works fine in 1.4.197 but fails with 1.4.198

package example;


import java.io.File;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;


public class Test {


   
public static void main(String[] args) throws Exception {
       
Class.forName("org.h2.Driver");


       
File file = new File("c:/temp/h2db.mv.db");
        file
.delete();


       
String url = "jdbc:h2:c:/temp/h2db;DATABASE_TO_UPPER=FALSE;MODE=MSSQLServer;LOCK_TIMEOUT=30;";
       
Connection conn = DriverManager.getConnection(url, "sa", "");


       
Statement cs = conn.createStatement();
        cs
.execute("create cached table IF NOT EXISTS [MyTable] (\"ColTest\" VARCHAR_IGNORECASE)");
        cs
.close();


       
Statement ss = conn.createStatement();
       
ResultSet rs = ss.executeQuery("select coltest from MyTable");
        rs
.close();
        ss
.close();


        conn
.close();
   
}


}


Thanks

Evgenij Ryazanov

unread,
Jul 22, 2020, 9:56:07 PM7/22/20
to H2 Database
Hello.

In old versions of H2 there was only one setting for case of identifiers. With DATABASE_TO_UPPER=FALSE unquoted identifiers aren't converted to upper case and all identifiers are not case sensitive.

In new versions of H2 there are three separate settings. DATABASE_TO_UPPER, DATABASE_TO_LOWER, and CASE_INSENSITIVE_IDENTIFIERS.

It looks like you need CASE_INSENSITIVE_IDENTIFIERS=TRUE setting.
Reply all
Reply to author
Forward
0 new messages