Thanks Kerry. It turns out there are many "driver delegaters" out there. 
One I find interesting 
is: 
http://www.nic.uoregon.edu/~amorris/regression/testtau/tau2/tools/src/perfdmf/src/database/DBConnector.java
 
It's not designed for H2 backend but highlights the transformation you can 
do in a JDBC proxy and log the result before/after.

Aside from overriding the DBProductName, I still believe it's best to 
contribute to further H2's MODE functionality and expand on other DB 
compatibility when the issue is either dialect or missing scalar functions 
(if it can be mimic'd in Java) - the idea for a generic regex replace 
through properties file therefore still stands in my mind...

As for your commission, will see ;-) Need first to find someone who can 
develop this as I am not a Java expert - will start looking and be happy to 
share with the community to take over.

On Wednesday, January 18, 2017 at 2:15:56 AM UTC-5, Kerry Sainsbury wrote:
>
> 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 <yannick.e...@gmail.com <javascript:>> 
> 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 h2-database...@googlegroups.com <javascript:>.
>> To post to this group, send email to h2-da...@googlegroups.com 
>> <javascript:>.
>> 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 h2-database+unsubscr...@googlegroups.com.
To post to this group, send email to h2-database@googlegroups.com.
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