My cunning idea would be to not put this into H2 at all. Instead create
your own JDBC Driver (it's not that hard -- I've written one) that
delegates to a "real" JDBC Driver. That way you can tell the client app any
lies you like. A quick Google reveals this example
<https://github.com/rpbouman/jjsutils/blob/master/java/org/jjsutils/jdbc/DriverDelegate.java>,
which would be a good start.

You'd also implement your own java.sql.Connection class which does the
regex mangling you describe, prior to passing the SQL off to the real JDBC
Driver's Connection object.

It would have the advantage of being able to work with any JDBC driver and
so be potentially useful to users of non-H2 databases.

I'll be happy to take 30% as a Commission :-)



On 18 January 2017 at 10:35, Yan <[email protected]> wrote:

> Despite all the built-in flexibility of H2 to be compatible with other
> databases, there are instances where apps are designed - and one has no
> access to the source code - to work only with specific RDBMS, say Oracle or
> MSSQL.
> I still want to use h2 for development instances and not go through the
> hassle and cost of installing multiple databases. Setting the MODE
> parameter would not help when the DatabaseProductName is checked upon: it
> would return h2 regardless.
>
> I was thus wondering
>
>    1. could you make the DBName configurable (properties file or
>    parameter in the connection url ) ?
>
>    2. If not, would a code change in the getDatabaseProductName of the h2
>    core library be a license breach or be considered a fork. Note I would not
>    redistribute the H2-mod as only for my own use
>
>    3. beyond the db name, some SQL statements are hardcoded especially
>    DDL so they only work for the identified DBMS.
>    It would be great to have an option to catch known statements and
>    reformat them using regex using a list maintained in properties file e.g.
>    ALTER TABLE (\w*) MODIFY (\w*) TIMESTAMP DEFAULT SYSTIMESTAMP = ALTER
>    TABLE %1 ALTER %2 SET DEFAULT TIMESTAMP
>    This would be evaluated in the executeQuery, executeUpdate and execute
>    methods and allow to transform any statement into H2 dialect without
>    touching the original application code
>
> Does anyone have other ideas to fool an app ?
>
> --
> You received this message because you are subscribed to the Google Groups
> "H2 Database" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/h2-database.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/d/optout.

Reply via email to