Hi all,
I  started working on starter Bug Metamodel 156 titled 
"JdbcDataContext.getDefaultSchemaName return SchemaName error".
Currently it finds database from URL using contains method, but if host name or 
directory (in case of HSQLDB) or any custom driver specific property name and 
schema name (non-default) are same then we can get wrong result. So I think we 
need to handle database specific URLs as much as possible and keep current 
behaviour as fail-safe mechanism.
Example : for MySQL  , database URL format is 
jdbc:mysql://[host1][:port1][,[host2][:port2]]...[/[database]] 
[?propertyName1=propertyValue1[&propertyName2=propertyValue2]...](Referred from 
https://dev.mysql.com/doc/connector-j/5.1/en/connector-j-reference-configuration-properties.html)
So we can do following steps1. find last index of /2. find first index of ?3. 
If ? index is -1 then substring (last index of /) + 1 to end of url4. If ? 
index is not -1 then substring (last index of /)+1 to (first index of ?)5. If 
substring length is greater than 0 after trim then its databasename.

Above is just pseducode , we can come with better strategy.  Same way we can do 
it for MSSQL, DB2, Hive, HSQLDB. For Microsoft SQL Server , we can handle both 
JTDS and Microsoft Driver URL formats.   If our new strategy fails to get 
database name due to different driver issues then current behaviour with bug 
fix can remain as fail-safe mechanism.

Please do share your thoughts on this.

Thanks ,Mr.Sagar Gandhi,Senior Software Engineer,eQ Technologic Inc.Pune- 
India(+91)9028440503                                    

Reply via email to