Closed sstano closed 7 years ago
SchemaCrawler leverages the JDBC driver's built-in functionality to retrieve tables, so I cannot say what query jTDS is using.
./schemacrawler.sh \
-server=sqlserver \
-password= \
-command=schema \
-outputformat=png \
-outputfile=./output/result.png \
-infolevel=standard \
-schemas=.*user\.dbo.* \
-routines= \
-loglevel=ALL \
-url=jdbc:jtds:sqlserver://server.com:1433/DATABASE\;instance=dbinstance\;useNTLMv2=TRUE\;domain=DOMAIN\;user=user\;password=pwd
Internally, both the jTDS JDBC driver and official Microsoft JDBC driver use sp_tables
.
Hi, thanks a lot for digging into this.
Regarding your 1st point, quite a lot schemas were found in the DB, actually. I tried to play around with it and it seems that the problem is because of the backslash in the schema name. I got the desired schema included by the filter when I used .(dot) in the schema regex where the backslash is:
-schemas=\"TESTDB-D1\"\.\"DOMAIN.user\" \
FINE: Including <"TESTDB-D1"."DOMAIN\user"> since it matches /"TESTDB-D1"."DOMAIN.user"/
However, no tables are found.
If I don't want to use the dot, the schema is only matched when I use following regex with 4 backslashes (2 backslashes won't match the schema name):
-schemas=\"TESTDB-D1\"\.\"DOMAIN\\\\user\" \
FINE: Including <"TESTDB-D1"."DOMAIN\user"> since it matches /"TESTDB-D1"."DOMAIN\\user"/
So, a backslash needs to be escaped to be passed as a backslash, but it seems like the string is then passed further (to jTDS?) where it needs to be escaped again (jTDS bug?).
With 4 backslashes in the regex, the schema is found and included, but again, no tables are found.
Then I tried a schema that doesn't have any backslashes in it:
-schemas=master\.dbo
and actually got some tables printed, so I'm getting pretty convinced the backslash is the trouble-maker.
Can you try with the latest Docker image? It is distributed with the official Microsoft JDBC driver. Also, please send me detailed instructions on how to set up a user and schema like the one you have, and I will try to reproduce on Amazon RDS.
Ok, I have this (see screenshot), but I cannot connect using
jdbc:jtds:sqlserver://localhost:1433;instance=SQLEXPRESS;useNTLMv2=true;domain=THOTH;user=Sualeh Fatehi;password=xxxxx
Please help me connect, so I can reproduce your issue.
Ok, I was able to connect, using jdbc:jtds:sqlserver://localhost:53665;useNTLMv2=true;domain=THOTH;user=Sualeh Fatehi;password=xxxxx
- the instance
parameter did not work for me.
I have reproduced the issue. Basically, when jTDS sees DOMAIN\user
, it internally escapes it to DOMAIN[u]ser
before calling sp_tables
. I am looking to see how the Microsoft JDBC Driver for SQL Server escapes that schema before calling sp_tables
.
I confirmed that the Microsoft JDBC Driver for SQL Server that is distributed with the latest version of SchemaCrawler does not have same the escaping issue as jTDS. I was able to get output from the Microsoft JDBC Driver for SQL Server.
On the debian and rpm installers, i have switched to mssql-jdbc-6.1.0.jre8.jar
and removed jtds
.
Did you take a look to the latest pre-release (https://github.com/Microsoft/mssql-jdbc/releases/tag/v6.1.5) ?
Adrien, as always, thanks for keeping the Debian and RPM installers up to date. Yes, I have taken a look at the pre-release, and will upgrade once the release is final. Microsoft JDBC Driver for SQL Server v6.1.0 is working as expected with SchemaCrawler.
v6.1.0 is working as expected with SchemaCrawler.
: that's all i wanted to hear ;-D
Is there any chance it could also be fixed for jTSD driver? I'm having issues connecting with the MS JDBC driver from my Mac. I need to use Windows authentication with a specific user domain and only jTDS was able to get it right.
I can see three possible options to help you:
I have a fix ready for you, and I will release a new version of SchemaCrawler in a couple of days. I will also give you instructions on how to modify your SchemaCrawler configuration file to make this work. I had to work-around the jTDS driver schema name escaping issue by scanning all tables and columns in the database, and this will make SchemaCrawler a little slower, but hopefully not very much.
Please use SchemaCrawler 14.15.03. Add the following lines to your schemacrawler.config.properties
file in the config/
folder of the SchemaCrawler distribution, and re-run.
schemacrawler.schema.retrieval.strategy.tables=metadata_all
schemacrawler.schema.retrieval.strategy.tablecolumns=metadata_all
@sualeh Amazing! Thank you so much! I can see the tables in the logs now :) I'll check the generated image once there's a new Docker image available, but I believe it should be fine now. THANKS!!!
The SchemaCrawler Docker images are available now.
I'm trying to export a schema from MSSQL database using SchemaCrawler & jTDS driver (version 1.3.1) with following command:
It would be helpful if I could somehow get the SQL query it's executing to list the tables.