3

jdbc で mysql サーバーの特定のスキーマに接続しようとしています。スキーマ名はマイニングです

接続しようとすると、すべてのDBにアクセスできるため、実行中のステートメントは、「マイニング」だけではなく、DB内のすべてのスキームに適用されます

これは私が接続を確立する方法です:

    public class Mining {
        Connection conn;

        void createConnection() {
            try {
                Class.forName("com.mysql.jdbc.Driver"); 
                this.conn = DriverManager.getConnection(
                "jdbc:mysql://localhost/?currentSchema=mining","admin","admin" );
//I ALSO TRIED THIS:    "jdbc:mysql://localhost/mining","admin","admin"


            } catch (SQLException e) {
                e.printStackTrace();
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            }
        }

何かご意見は?

ありがとう!

4

2 に答える 2

5

試す、

private Connection connect = DriverManager
              .getConnection("jdbc:mysql://localhost/mining?"
            + "user=admin&password=admin");
于 2012-12-15T11:47:52.797 に答える