无法使用Java访问第二个MYSQL数据库

问题描述

| 连接到Java中的第二个MYSQL数据库时,要注意一些特定的事情吗? 我查询一个数据库
db1
就好了,但是当我切换到重复的数据库
db2
并运行相同的查询时 在eclipse中运行时,该程序仅显示“已终止”,没有输出。
Class.forName(\"com.mysql.jdbc.Driver\").newInstance();
                    Connection con = DriverManager.getConnection
    (\"jdbc:mysql://localhost/db2\",\"root\",\"password\");
                    con.setReadOnly(true);
                    Statement stmt = con.createStatement();

                    ResultSet res = stmt.executeQuery(\"query that worked for db1\");

    //then do stuff with res that printed out the grabbed 
//results successfully for db1`
    

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)