[ https://issues.apache.org/jira/browse/METAMODEL-97?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14214452#comment-14214452 ]
xgl1991714 commented on METAMODEL-97: ------------------------------------- Maybe we can use connection.getCatalog()? > 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)