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
Solved

Java MySQL connection

Posted on 2004-08-14
3
230 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
3 Comments
 
LVL 92

Accepted Solution

by:
objects earned 250 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 250 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
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…
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 about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

765 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