繁体   English   中英

eclipse的数据库创建问题

[英]database creation issue with eclipse

package practice;

import java.sql.*;
import java.util.Properties;

public class DBTEst
{

  private static final String dbClassName = "com.mysql.jdbc.Driver";

  private static final String CONNECTION =
                          "jdbc:mysql://127.0.0.1/emotherearth";

  public static void main(String[] args) throws
                             ClassNotFoundException,SQLException
  {
    System.out.println(dbClassName);
    Class.forName(dbClassName);

      Properties p = new Properties();
    p.put("user","paulr");
    p.put("password","welcome");

    Connection c = DriverManager.getConnection(CONNECTION,p);

    System.out.println("It works !");
    c.close();
    }
}

我是数据库的新手,所以对于sql ..我只是在ubuntu OS中使用eclipse配置了mysql。 但是当我试图运行程序时,我收到如下错误。

com.mysql.jdbc.Driver
Exception in thread "main" java.sql.SQLException: Access denied for user 'paulr'@'localhost' (using password: YES)
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1086)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4237)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4169)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:928)
    at com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(MysqlIO.java:1750)
    at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1290)
    at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2493)
    at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2526)
    at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2311)
    at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:834)
    at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
    at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:416)
    at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:347)
    at java.sql.DriverManager.getConnection(DriverManager.java:664)
    at java.sql.DriverManager.getConnection(DriverManager.java:208)
    at practice.DBTEst.main(DBTEst.java:32)

我在论坛中发现了同样的问题,但没有解决我的问题......可能是因为操作系统的改变,如果不是请求原谅我的无知,请指导我...谢谢你的帮助... root密码我'安装mySQL时设置是“欢迎”..

您在设置时没有在MySQL中正确设置用户paulr ,或者您可能会忽略MySQL根据客户端的IP地址或主机名进行帐户访问这一事实的常见错误。 许多人忘记在用户设置中包含localhost和/或127.0.0.1

请参阅https://stackoverflow.com/a/26234768/639520

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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