Hi I'm installed MySql server and client on Win98 and program is working Ok; code is import java.sql.*; //import org.gjt.mm.mysql.*; public class MySQL { public static void main(String args[]) { try { Class.forName("org.gjt.mm.mysql.Driver").newInstance(); Connection mysql=DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/mysql?user=root&password="); Statement st=mysql.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY); String Query="select host,user,password from user"; ResultSet Result=st.executeQuery(Query); while (Result.next()) { System.out.println(Result.getString(1)+" "+Result.getString(1)+" "+Result.getString(1)); } Result.close(); st.close(); mysql.close(); } catch(Exception e) { System.out.println(e.getMessage()); } } } If i access to remote machine (e.g IP=192.168.0.58) connection is Connection mysql=DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/mysql?user=username&password=password"); but have Access denied for username. How to connect remote server?
Senior software engineer
Robert Brunner
Ranch Hand
Joined: Jul 18, 2001
Posts: 49
posted
0
Originally posted by Dorj Galaa: Connection mysql=DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/mysql?user=root&password="); If i access to remote machine (e.g IP=192.168.0.58) connection is Connection mysql=DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/mysql?user=username&password=password");
Well, you have different username/password combinations in your connect statements. If that is not the problem, the first thing you should check is that your username/password actually does work on the remote database