Question

Can't connect to Azure SQL using JDBC Producer

  • 26 October 2022
  • 7 replies
  • 68 views

Hi everybody,

I have trouble writing to a Azure SQL database using JDBC. This is the error message:

Reference to database and/or server name in 'dbo.schema.table' is not supported in this version of SQL Server.

There is not much information about this error, it seems to have something with Azure SQL not being a full-blown MS SQL server. Also adding `dbo` is not necessary in this case.

My JDBC string looks like this:

jdbc:sqlserver://censored.database.windows.net:1433;database=censored;encrypt=true;trustServerCertificate=false;hostNameInCertificate=*.database.windows.net;loginTimeout=30;

I’ve configured the JDBC connection like this:

 

This method (putting `dbo` as schema and `schema.table` as table name) is the only one that appears to work. All other combinations omitting `dbo` result in errors like these:

Table 'dbo.schema.table' does not exist or PDB is incorrect. Make sure the correct PDB was specified

Any ideas? Has anybody else already connected Azure SQL via JDBC? How did you configure it?

Cheers, Christoph


7 replies

Userlevel 4
Badge

@chisou , have you tried providing just schema name in Schema Name field and table name in Table Name field (without adding the schema name)

@saleempothiwala, yes, this was my first take actually. It always goes “Table 'schema.table' does not exist or PDB is incorrect. Make sure the correct PDB was specified.”

Userlevel 4
Badge

@chisou let me try creating an azure sql db and get back to you with the correct values.

Oh my - I found something. When I don’t use a “sub schema” (or how to call that) it works.
So - “dbo.schema.table” doesn’t work. “dbo.table” works, putting “dbo” in the Schema field.

Any idea why?

Userlevel 4
Badge

every jdbc driver has its own way of specifying things… even though there is a lot of standardisation.

 

Does this solve your problem? 

Userlevel 5
Badge +1

@chisou 

Your schema name should be “schema” and table name should be “table”.

Data base name not needed here.

All, I think I found it. It appears that the JDBC driver is not build for a nested schema layout. I got rid of the `dbo` part in the database and then it’s working as expected. 

I sure hope that native support for Azure SQL will come at some point, JDBC feels a bit like last resort.

Cheers everybody for pointing me in the right direction!

Reply