Git Product home page Git Product logo

Comments (19)

pastelto avatar pastelto commented on June 12, 2024 1

from schemacrawler.

pastelto avatar pastelto commented on June 12, 2024 1

Hello, I solved this problem. When it comes to database name contains Uppercase, it returns with extra "" ,for example, ""User"". That was the problem. Thanks a lot. Hope you have a great day.

from schemacrawler.

sualeh avatar sualeh commented on June 12, 2024

If the database reports that that object names are case-sensitive, SchemaCrawler will enclose the names with double-quotes. Please provide more details of the actual command-line you are using.

from schemacrawler.

pastelto avatar pastelto commented on June 12, 2024

The database doesn't report any messages. I'm using it as a library, and it just returns that there is no schema when I tried to get a schema from database which has capital letter in its name, although there is.

When I have a database name list in SQL Server, for example: ['user', 'user1', 'User2', 'user3'], and I want to get all the schemas from 'User2', the same thing happens like this:
image

The real schema name value is 'User2', but when it goes through the normalizeCatalogName function, it returns the name in lowercase. Then the returned value, which is 'user2', can't be found in the database name list in SQL Server, which I wrote as an example: ['user', 'user1', 'User2', 'user3']. I think it doesn't recognize the 'User2' with 'user2' then it means sql server is case-sensitivie when getting a schema.
image

It works okay with Oracle because Oracle is not case-sensitive. However, when it comes to SQL Server, if a user saves the database name as 'UserName', it will be saved exactly like that. So, I think the return value should be the exact same name as the real schema value, not the lowercase applied one.

This case can be reproduced easily just creating a database name in sql server with only lower case letter and one starts with a capital letter.

from schemacrawler.

pastelto avatar pastelto commented on June 12, 2024

Oh I accidently closed the issue.

from schemacrawler.

sualeh avatar sualeh commented on June 12, 2024

@pastelto I cannot read your code from the screenshot. Please could you paste that code snippet in text on this issue?

from schemacrawler.

pastelto avatar pastelto commented on June 12, 2024

Oh, Those screenshot are from https://github.com/schemacrawler/SchemaCrawler/issues/176#issuecomment-810962748. Because it was exactly same issue with mine.

I'm using library and so I can't debug deeper.. I can debug until here.

    private void crawlSchemas() throws Exception {
        SchemaRetriever retriever = new SchemaRetriever(this.retrieverConnection, this.catalog, this.options);
        this.taskRunner.add("retrieveSchemas", () -> {
            retriever.retrieveSchemas(this.options.getLimitOptions().get(DatabaseObjectRuleForInclusion.ruleForSchemaInclusion));
        }, new SchemaInfoRetrieval[0]).submit();
        this.taskRunner.add("filterAndSortSchemas", () -> {
            this.catalog.reduce(Schema.class, ReducerFactory.getSchemaReducer(this.options));
        }, new SchemaInfoRetrieval[0]).submit();
        **NamedObjectList<SchemaReference> schemas = retriever.getAllSchemas();**
        if (schemas.isEmpty()) {
            throw new ExecutionRuntimeException("No matching schemas found");
        } else {
            LOGGER.log(Level.INFO, new StringFormat("Retrieved %d schemas", new Object[]{schemas.size()}));
        }
    }

and those bold code is where I get a error. All the data are correct until there and then after "retriever.getAllSchemas()" I can't get the schema and I do have tables and column in that database. It works okay perfectly with all lower case database name but it doesn't work when database name has a single captial letter. I tested a lot with database name.

from schemacrawler.

sualeh avatar sualeh commented on June 12, 2024

@pastelto I will need your code, so I can see what you are doing, and try to reproduce it. Can you create some sample code in a GitHub Gist, and send me a link? I will debug through the SchemaCrawler code once I have a test case set up.

from schemacrawler.

pastelto avatar pastelto commented on June 12, 2024

https://gist.github.com/pastelto/00b530b025aabaf43263147cd733131a

Thanks for waiting. Here is the code!
It's not working in sql server only when database name starts with capital letter or has a capital letter in the database.

from schemacrawler.

sualeh avatar sualeh commented on June 12, 2024

@pastelto Thanks for your code. I have included in an Apache Maven project to try and reproduce the issue. I cannot reproduce it.

Please clone https://github.com/sualeh/schemacrawler-issue1460 and follow the instructions in the README exactly. You will need Docker available to run the code.

from schemacrawler.

sualeh avatar sualeh commented on June 12, 2024

@pastelto Please let me know if you have tried the sample code I provided.

from schemacrawler.

pastelto avatar pastelto commented on June 12, 2024

Hello. I started testing the code you provided today. However I followed the ReadMe instructions, but it's not working properly. It seems to be a problem caused by my lack of knowledge about Docker, because it's my first time using docker, so I'm currently researching Docker-related issues.

us.fatehi.utility.SQLRuntimeException: Could not connect to <jdbc:sqlserver://localhost:1433;DatabaseName=AdventureWorks;encrypt=false>, for <user 'SA'>, with properties <{}> at us.fatehi.utility.datasource.AbstractDatabaseConnectionSource.getConnection(AbstractDatabaseConnectionSource.java:126) at us.fatehi.utility.datasource.SimpleDatabaseConnectionSource.get(SimpleDatabaseConnectionSource.java:113) at us.fatehi.utility.datasource.SimpleDatabaseConnectionSource.get(SimpleDatabaseConnectionSource.java:49) at schemacrawler.tools.utility.SchemaCrawlerUtility.matchSchemaRetrievalOptions(SchemaCrawlerUtility.java:144) at schemacrawler.tools.utility.SchemaCrawlerUtility.getCatalog(SchemaCrawlerUtility.java:80) at com.example.Main.main(Main.java:48)

from schemacrawler.

pastelto avatar pastelto commented on June 12, 2024

Hello, I've tried to run the sample code, but I couldn't connect to the docker database. I just want to check if there is anything I need to change the provided database url to run the main.java? like changing localhost to another ip address?? <jdbc:sqlserver://localhost:1433~

Thanks

from schemacrawler.

sualeh avatar sualeh commented on June 12, 2024

@pastelto Please look at the Docker documentation, since I am using an image that is publicly available. Please tweak the code as needed.

from schemacrawler.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.