• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
  • paul wheaton
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Rob Spoor
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:

how to connect MySql

 
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Message for you sir! I think it is a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic