You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@metamodel.apache.org by "Kasper Sørensen (JIRA)" <ji...@apache.org> on 2014/11/17 09:47:33 UTC
[jira] [Commented] (METAMODEL-97) getDefaultSchema() indexOf()
[ https://issues.apache.org/jira/browse/METAMODEL-97?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14214423#comment-14214423 ]
Kasper Sørensen commented on METAMODEL-97:
------------------------------------------
Right ... I guess this is because the two schema names overlap ... Maybe you can propose a solution that takes into account not just "a match" but "the best match" ?
> getDefaultSchema() indexOf()
> ------------------------------
>
> Key: METAMODEL-97
> URL: https://issues.apache.org/jira/browse/METAMODEL-97
> Project: Metamodel
> Issue Type: Bug
> Affects Versions: 4.1.0-incubating, 4.2.0-incubating
> Reporter: xgl1991714
>
> There are two databases:'mydb' and 'mydb2'
> But when I run:
> {quote}
> Class.forName({color:blue}"com.mysql.jdbc.Driver"{color});
> Connection conn = DriverManager.getConnection({color:blue}"jdbc:mysql://localhost:3306/mydb2?user=root&password=xxxx"{color});
> DataContext dataContext=DataContextFactory.createJdbcDataContext(conn);
> System.out.println({color:blue}"default schema is:"{color}+dataContext.getDefaultSchema());
> {quote}
> The reslut is:
> {quote}
> default schema is:mydb
> {quote}
> the code of method getDefaultSchema() in JdbcDataContext:
> {quote}
> ...
> for (int i = 0; i < schemaNames.length && !found; i++) {
> String schemaName=schemaNames\[i];
> if(lastToken.{color:red}indexOf{color}(schemaName) != -1) {
> result = schemaName;
> found = true;
> }
> }
> ...
> {quote}
> the lastToken is {color:blue}'mydb2?user=root&password=xxxx'{color} and the schemaName is {color:blue}'mydb'{color}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)