Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reference to database and/or server name in 'master.sys.schemas' is not supported in this version of SQL Server. #12291

Closed
lukaseder opened this issue Aug 10, 2021 · 2 comments

Comments

@lukaseder
Copy link
Member

When doing the following on an Azure SQL database:

Meta meta = ctx.meta();

Catalog catalog = meta.getCatalog("test");
Schema schema = catalog.getSchema("dbo");

Table<?> table = schema.getTable("t_book");
List<? extends ForeignKey<?, ?>> fks = table.getReferences();

Then there's an exception like this:

Exception in thread "main" org.jooq.exception.DataAccessException: Error while running ConnectionCallable
	at org.jooq.impl.DefaultDSLContext.connectionResult(DefaultDSLContext.java:662)
	at org.jooq.impl.MetaImpl.meta(MetaImpl.java:187)
	at org.jooq.impl.MetaImpl$MetaCatalog.getSchemas(MetaImpl.java:284)
	at org.jooq.impl.MetaImpl.lambda$2(MetaImpl.java:242)
	at org.jooq.impl.Tools.flatMap(Tools.java:2107)
	at org.jooq.impl.MetaImpl.getSchemas0(MetaImpl.java:242)
	at org.jooq.impl.AbstractMeta.lambda$1(AbstractMeta.java:152)
	at org.jooq.impl.AbstractMeta.get(AbstractMeta.java:371)
	at org.jooq.impl.AbstractMeta.initSchemas(AbstractMeta.java:152)
	at org.jooq.impl.AbstractMeta.getSchemas(AbstractMeta.java:144)
	at org.jooq.impl.MetaImpl$MetaTable.getReferences(MetaImpl.java:824)
	at org.jooq.testscripts.JDBC.main(JDBC.java:45)
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Reference to database and/or server name in 'master.sys.schemas' is not supported in this version of SQL Server.
	at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:262)
	at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1632)
	at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPreparedStatement.java:602)
	at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(SQLServerPreparedStatement.java:524)
	at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:7418)
	at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:3272)
	at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:247)
	at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:222)
	at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeQueryInternal(SQLServerPreparedStatement.java:460)
	at com.microsoft.sqlserver.jdbc.SQLServerDatabaseMetaData.getSchemasInternal(SQLServerDatabaseMetaData.java:1498)
	at com.microsoft.sqlserver.jdbc.SQLServerDatabaseMetaData.getSchemas(SQLServerDatabaseMetaData.java:1508)
	at org.jooq.impl.MetaImpl$MetaCatalog.lambda$0(MetaImpl.java:288)
	at org.jooq.impl.MetaImpl.lambda$0(MetaImpl.java:187)
	at org.jooq.impl.DefaultDSLContext.connectionResult(DefaultDSLContext.java:656)
	... 11 more
@lukaseder
Copy link
Member Author

The problem is that our DatabaseMetaData backed MetaImpl tries to fetch all the catalogs and their schemas, when this isn't possible on SQL Azure, even though this call is possible: connection.getMetaData().getCatalogs()

@lukaseder
Copy link
Member Author

Fixed in jOOQ 3.16.0, 3.15.2 (#12292), and 3.14.14 (#12293)

3.16 Other improvements automation moved this from To do to Done Aug 10, 2021
lukaseder added a commit that referenced this issue Aug 12, 2021
'master.sys.schemas' is not supported in this version of SQL Server.

Including:

- Added Azure SQL connection strings
- Added test script to JDBC
lukaseder added a commit that referenced this issue Aug 12, 2021
'master.sys.schemas' is not supported in this version of SQL Server.

Including:

- Added Azure SQL connection strings
- Added test script to JDBC
lukaseder added a commit that referenced this issue Aug 19, 2021
'master.sys.schemas' is not supported in this version of SQL Server.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Development

No branches or pull requests

1 participant