schemacrawler / SchemaCrawler-Database-Plugins

SchemaCrawler plugins for additional databases
http://www.schemacrawler.com/
Other
9 stars 5 forks source link

SAP IQ connector appears to "support" all jdbc URLs (causing wrong selector to be chosen from DatabaseConnectorRegistry) #47

Open aormerod-gs opened 1 year ago

aormerod-gs commented 1 year ago

It looks like the the SAPIQDatabaseConnector is "supporting" non-Sybase URLs. Is this intentional / required?

https://github.com/schemacrawler/SchemaCrawler-Database-Plugins/blob/26944d552eee36ed94c4acc91526b5ca23fba3f1/schemacrawler-sapiq/src/main/java/schemacrawler/server/sapiq/SAPIQDatabaseConnector.java#L41

Connection connection = .... //with JDBC URL "jdbc:h2:tcp://127.0.0.1:50491/mem:"
DatabaseConnector dbConnector = DatabaseConnectorRegistry.getDatabaseConnectorRegistry().findDatabaseConnector(connection);

assert(!dbConnector.databaseSystemIdentifier.contains('sapiq'))

Should it be changed to

url -> url.startsWith("jdbc:sybase:Tds:") || url.startsWith("jdbc:sqlanywhere:") 

thanks,

sualeh commented 1 year ago

@aormerod-gs - I am happy to change it as you suggest. However, this was intentional by the original author, since there are two connectors. I am not a Sybase/ SAP expert, so please tell me if we still need two connectors. If we do not need two, we can remove one of them.

aormerod-gs commented 1 year ago

Apologies for the delayed reply.

I agree that in the simple use case where you have only one driver type in the application, then it doesn't matter too much. In my use case, the system has connections to multiple different DB types so there would be multiple SchemaCrawler DatabaseConnector plug-ins on the classpath / loaded.

Probably I could create a direct mapping, rather than using the "find" but I assumed that was the purpose of the url check

For prefixes: https://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.help.sqlanywhere.12.0.1/dbprogramming/url-using-jdbc.html https://help.sap.com/docs/SAP_SQL_Anywhere/98ad9ec940e2465695685d98e308dff5/3bd5b17c6c5f1014945fd2b7ec7cba6a.html?version=17.0

sualeh commented 1 year ago

@aormerod-gs - if you are using SchemaCrawler programmatically, you can select a database connector like in this code example.