Solved

Java MySQL connection

Posted on 2004-08-14
3
223 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

759 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now