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

MSSQL cannot load all databases with all of their schemas #17

Open
catalyst1987 opened this issue Jun 25, 2023 · 5 comments
Open

MSSQL cannot load all databases with all of their schemas #17

catalyst1987 opened this issue Jun 25, 2023 · 5 comments

Comments

@catalyst1987
Copy link

Hello,
I'm currently using version 4.6.0. I am connect to an MSSQL database using the microsoft JDBC driver. When I connect to a server using Squirrel, I can see all the databases, but when I expand to see the schemas for each database I can only see the system ones. Is this a limitation where I have to set the database in the connection string or is there some kind of setting I can change to get this to load?

my connection string is like this: jdbc:sqlserver://[hostname]:1433;trustServerCertificate=true;domain=[domain name];integratedSecurity=true;authenticationScheme=NTLM

If its a limitation, is there an enhancement request I can follow or a plugin that can be recommended?

Many Thanks.

@gerdwagner
Copy link
Member

I guess you didn't choose the catalog (database) you want to work in, see attached screenshot. By adding ;databaseName= to your connection string (JDBC-URL) you may preselect a catalog at Session start.

CatatlogsCombo

@catalyst1987
Copy link
Author

I guess you didn't choose the catalog (database) you want to work in, see attached screenshot. By adding ;databaseName= to your connection string (JDBC-URL) you may preselect a catalog at Session start.

CatatlogsCombo

Sure, and it will show the tables for that particular database but not for any of the others on the host. What I am looking for is to have all the databases and all of their schemas along with their tables to show up in the tree.

gerdwagner added a commit that referenced this issue Aug 27, 2023
#17
   For databases that support catalogs SQuirreL now allows to specify additional catalogs to load.
   See the new toolbar button with the three dots icon next to the
   catalogs combo box at the upper left of a Session panel.
@gerdwagner
Copy link
Member

The functionality described in the excerpt from SQuirreL's change log below is committed to our GIT repositories and will be available in future snapshots and versions

#17
For databases that support catalogs SQuirreL now allows to specify additional catalogs to load.
See the new toolbar button with the three dots icon next to the
catalogs combo box at the upper left of a Session panel.

@HNKJNSSN
Copy link

I was looking forward to using this.
Trying this on 4.7.1 (using sqlserver 13.00.6435 (2016); ms-jdbc: 8.2.2.0 (8.2)) it changes nothting in the behaviour of the displayed schemas under different (selected or not) databases?
I've selected master, model, msdb, and tmpdb. Only when I switch to the correct catalog (database) it will list the schemas belonging there.
I have not selected anything to (not) load in the connection settings.
A fix or clarification is appreciated :-) Thank you!!
squirrel_catalog_load_2024-08-29

@gerdwagner
Copy link
Member

gerdwagner commented Sep 8, 2024

The problem is in part a problem of SQuirrel and in part a problem of the MSSQL JDBC driver:

SQuirreL:
On the right hand side of your screenshot the schema crud is shown in all catalogs. The is fix is committed to our GIT repositories and will be available in future snapshots and versions. Excerpt from change log:

For databases which support catalogs and schemas, e.g. MSSQL Server, catalog nodes contained schemas
that didn't belong to the catalog.
Technically speaking the result column "TABLE_CATALOG" returned by java.sql.DatabaseMetaData.getSchemas()
was not regarded.

MSSQL JDBC driver:
When calling java.sql.DatabaseMetaData.getSchemas() the driver returns only schemas of the active catalog
and schemas which not associated with any catalog like "dbo". Here's the code to reproduce the problem:

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;

public class MSSQLTest
{
   public static void main(String[] args) throws ClassNotFoundException, SQLException
   {
      Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
      Connection con = DriverManager.getConnection("<JDBC-URL>", "user", "password");

      con.setCatalog("cat1");
      // con.setCatalog("cat2");

      ResultSet schemas = con.getMetaData().getSchemas();

      while(schemas.next())
      {
         System.out.println(schemas.getString("TABLE_CATALOG") + "." + schemas.getString("TABLE_SCHEM"));
      }
   }
}

You may contact your driver vendor on this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants