Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cant connect to specific schema in mysql

Tags:

java

mysql

jdbc

i'm trying to connect with jdbc to a specific schema in mysql server, the schema name is mining

when i'm trying to connect i get access to all the DB and therefore the executing statements apply to all the schemes in my db instead only to "mining"

this is how i establish a connection:

    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();
            }
        }

any thoughts?

thanks!

like image 743
Guy Avatar asked Oct 14 '25 16:10

Guy


1 Answers

try,

private Connection connect = DriverManager
              .getConnection("jdbc:mysql://localhost/mining?"
            + "user=admin&password=admin");
like image 137
John Woo Avatar answered Oct 17 '25 04:10

John Woo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!