1

I am attempting to create a MySQL and Java client app for my home network.On the server machine I successfully connected to the MySQL as root

Now I want to connect to MySQL from my client PC using the Java client program, How to do this?? Do i need to install Tomcat Server to run on server for this.

I am using Windows 7 on all my clients and server machines.

3 Answers3

0

Tomcat server is used for web applications.You just need to create a JDBC code and in the URL string just give the ip address of the system where mysql is installed.For example

connection = DriverManager
        .getConnection("jdbc:mysql://192.168.1.205:3306/database_name","root", "password");

Also if you have not granted the permission in mysql then grant it .See this for granting permission for access to mysql on remote system

Community
  • 1
  • 1
SpringLearner
  • 13,738
  • 20
  • 78
  • 116
0

Depending on what you want to achieve, you need to establish a JDBC connection to the server. Take a look at the JDBC trail for more details.

This will allow you to connect directly from you client machine to your database server. This would be done using the required JDBC connection URL for the MySQL connection, for example jdbc:mysql://[host][,failoverhost...][:port]/[database] ยป [?propertyName1][=propertyValue1][&propertyName2][=propertyValue2]..., check out Driver/Datasource Class Names, URL Syntax and Configuration Properties for Connector/J for more details.

You may also need to configure your MySQL server to allow remote access before you can connect

MadProgrammer
  • 343,457
  • 22
  • 230
  • 366
0

You just need to do two things:

  1. Make sure the server hosting MySQL allows incoming connections
  2. Write JDBC code and use your MySQL server hostname/ipaddress in the jdbc string to connect and use it.
Juned Ahsan
  • 67,789
  • 12
  • 98
  • 136