Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to connect MySql

 
Dorj Galaa
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Robert Brunner
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic