Hi,
As a part of project i wrote the code to connect to mysql using java.In my system it is working fine.but when i tried on the server(even as root also) i am getting an error message.I am not able to sort out the what the problem could be..?
mycode is
{
...................................
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
}catch (Exception E) {
System.err.println("CONCEPT: Unable to Load Driver ");
E.printStackTrace();
}
try {
System.out.println("Connecting...");
Connection c = DriverManager.getConnection(
"jdbc:mysql://localhost/mysql?user=samurai&password=helloworld");
System.out.println("Connection ok: " + c);
System.out.println("Creating BankID table:");
Statement stmt=c.createStatement();
stmt.executeUpdate("use SST");
stmt.executeUpdate("CREATE TABLE BANKID (EID VARCHAR(20) UNIQUE)");
System.out.println("Table with following Attributes is created:");
ResultSet res=stmt.executeQuery("DESCRIBE BANKID");
while(res.next()){
String s=res.getString("Field");
System.out.println("-->"+s);
s=res.getString("Type");
System.out.println("-->"+s);
}
}catch (SQLException E) {
System.out.println ("SQLException: " + E.getMessage());
System.out.println ("SQLState: " + E.getSQLState());
System.out.println ("VendorError: " + E.getErrorCode());
}
}
public void addGID(String name){
String Query;
Query="INSERT INTO TABLE BANKID VALUES ( "+name +" )";
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
}catch (Exception E) {
System.err.println("CONCEPT: Unable to Load Driver ");
E.printStackTrace();
}..................
..............................
The above code is working fine in mysystem.but it's giving the following error when i try to run it on other system.
Error Message:
SQL Error: Data Source rejected for the establishment of the connection.user 'Host'@localhost is not allowed to connect to MySql Server.
Vendor Error Code: 1130
please help me
Thanks,
karan