Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Java MySQL connection

Posted on 2004-08-14
3
Medium Priority
?
235 Views
Last Modified: 2010-03-31
I am trying to connect java application with mysql.
Earlier mysql was installed on a remote machine and the connection was working fine. But now i was testing it by installing it on the local machine. So changed the host name from name of server to localhost and specified user name and password for local mysql database.
But now i can't conenct to the local databse.
i am getting the following Error

Access denied to user abc@127.0.0.1 (Using password:YES).

But i can directly run the database from prompt.

Please Help
0
Comment
Question by:thomas908
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 92

Accepted Solution

by:
objects earned 1000 total points
ID: 11799133
Check exactly who you have granted login to and that abc@127.0.0.1 is one of them

http://dev.mysql.com/doc/mysql/en/GRANT.html
0
 
LVL 8

Author Comment

by:thomas908
ID: 11799151
i logged on to mysql database and did

 GRANT ALL ON *.* to abc;

and got the follwoign error
ERROR 1045: Access denied for user: '@127.0.0.1' (Using password: NO)
0
 
LVL 6

Assisted Solution

by:manuel_m
manuel_m earned 1000 total points
ID: 11799278
can you connect as root ?

can you post your code?

look here: http://homepage.mac.com/murraytodd/enterprise/mysql.html
maybe it can help you

i test this and it works fine on my localhost mysql: (using newest mysql driver 3.0.14)

  private static final String DB_URL = "jdbc:mysql://localhost/maq?user=root&password=password";

  private static Connection conn = null;

  public SQLConnectionTest() {

    try {
      Class.forName("com.mysql.jdbc.Driver").newInstance();
      conn = (Connection) DriverManager.getConnection("jdbc:mysql://localhost/dbName?user=root&password=password";);
      if (!conn.isClosed()) {
        System.out.println("closing connection...");
      }
    } catch (Exception ex) {
      System.out.println("Connection failed: "+ ex.getMessage());
      ex.printStackTrace();
    }
  }
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question