Solve!! JDBC Access denied for user ‘abc ‘@’localhost’ (using password: YES)

Posted: กันยายน 19, 2009 in ไม่มีหมวดหมู่
Write Try..catch for detect error

// ================================================
try {
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
try {
Connection connection = DriverManager.getConnection( "jdbc:mysql://localhost/Team");
try{
Statement statement = connnection.createStatement();
ResultSet resultset = statement.executeQuery("SELECT NAME FROM TEAM");
while ( resultset.next() ) {
out.println( resultset.getString( "NAME" ) + " " );
}
resultset.close();
statement.close();
}catch ( SQLException sqle ) {
out.println( "jdbc error: " + sqle );
}
finally {
connection.close();
}
}catch( SQLException sqle ) {
out.println( "error connecting: " + sqle );
}
} catch( ClassNotFoundException cnfe ) {
out.println( "error loading JDBC driver: " + cnfe );
}

// ================================================

ref: http://bobcat.webappcabaret.net/javachina/scjd/team/mysql.htm

This is a problem.
Access denied for user 'abc '@'localhost' (using password: YES)

Now you can solve its like this,

mysql> CREATE USER 'some_user'@'%' IDENTIFIED BY 'some_pass';
mysql> GRANT ALL PRIVILEGES ON some_db.* TO 'some_user'@'%'
mysql> FLUSH PRIVILEGES;

ref: http://dev.mysql.com/doc/refman/5.1/en/adding-users.html

Advertisements

ใส่ความเห็น

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / เปลี่ยนแปลง )

Twitter picture

You are commenting using your Twitter account. Log Out / เปลี่ยนแปลง )

Facebook photo

You are commenting using your Facebook account. Log Out / เปลี่ยนแปลง )

Google+ photo

You are commenting using your Google+ account. Log Out / เปลี่ยนแปลง )

Connecting to %s