简体   繁体   中英

Scala JDBC connection:java.sql.SQLException: Access denied for user

I have imported

scala> import java.sql._
scala> Class.forName("com.mysql.jdbc.Driver")

Next step is to connect to database server

scala> val connection = DriverManager.getConnection(
"jdbc:mysql://127.0.0.1:3306/test",
"milenko", // username when connecting
"papai" // password)

But problems occured with

java.sql.SQLException: Access denied for user 'milenko'@'localhost'
  at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:998)
  at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3835)
  at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3771)
  at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:870)
  at com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(MysqlIO.java:1659)
  at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1206)

My connections

netstat -tln
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN     
tcp        0      0 127.0.1.1:53            0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:31416           0.0.0.0:*               LISTEN     
tcp6       0      0 :::22                   :::*                    LISTEN  

Any ideas?

using localhost the coonection works. msebaapc:bin sebaacomtx$ ./mysql -u root -p mysql-admin -h localhost -P 3306 Enter password: Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor. Commands end with ; or \\g. Your MySQL connection id is 97 Server version: 5.6.15 MySQL Community Server (GPL)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM