mysql-jdbc-connectivity-error
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Mandar_Pohnerkar
Posted On:   Thursday, June 13, 2002 05:27 AM

Hello, i just installed mysql and wrote java program to connect to the mysql database.But i m getting some error as follows. 1)Logged in as root and i started the mysql server, shell>bin/safe_mysqld & 2)i ran the java program and got error as "Access denied to the root@localhost (with passowrd "YES")" Why i m getting this error ? My java prg, is like this. import java.sql.*; public class Connect{ Connection con; Statement st; ResultSet rs; String qry; public Connect(){ Class.forName("org.gjt.mm.mysql.Driver").newInstance(); con=DriverManager.getConnection    More>>

			
Hello,

i just installed mysql and wrote java program to connect to the mysql database.But i m getting some error as follows.


1)Logged in as root and i started the mysql server,

shell>bin/safe_mysqld &

2)i ran the java program and got error as "Access denied to the root@localhost (with passowrd "YES")"

Why i m getting this error ?

My java prg, is like this.

import java.sql.*;
public class Connect{
Connection con;
Statement st;
ResultSet rs;
String qry;
public Connect(){
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
con=DriverManager.getConnection
("jdbc:mysql://abc/xyz","root","password");
st=con.createStatement();
qry="select * from table_name";
rs=con.executeQuery(qry);
while(rs.next()){
System.out.println(rs.getString(0));
}
}
}

where,
abc=my system name
xyz=database name

so when i run the prg. i get access violetion error.
Can any1 plz spot the error?Plz guide me step by step as your earliest.

Thanking you,

Mandar


   <<Less

Re: mysql-jdbc-connectivity-error

Posted By:   yangontha_Maung  
Posted On:   Tuesday, June 18, 2002 05:19 AM

Check what user (root?) and password you are using in this line in java code.

("jdbc:mysql://abc/xyz","root","password");

Check whether this user has the authority to access the xyz mysql database. If not change it to the user that has access.
Don't assume that by using "root", you have access to mysql.
About | Sitemap | Contact