?
Solved

Java MySQL connection

Posted on 2004-08-14
3
Medium Priority
?
234 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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
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…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Suggested Courses
Course of the Month13 days, 21 hours left to enroll

801 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