Java - Mysql


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Java - Mysql

Hybrid View

  1. #1
    Join Date
    Apr 2004
    Posts
    8

    Java - Mysql

    I have a problem connecting to MySQL remotely. I believe I have configured JDBC correctly i.e. extracting the mysql*.jar and setting the enviroment variables for the path.

    I can connect to a MySQL database that is on the same machine (Windows XP) as the code I'm executing, however, I wish to conenct to a remote database on a server. I am using the following code to connect to it.

    ...

    Class.forName("com.mysql.jdbc.Driver").newInstance();
    Connection conn = DriverManager.getConnection
    ("jdbc:mysql://12.123.123.123/mysql", "user", "pasword");

    etc ...

    where "12.123.123.123" is the ip address of the server I am trying to connect to. I have tried accessing two different servers running MySQL - a Red Hat Liniux Enterprise 3 Server and a Fedora Core 4 Server and get the same result. I have even tried specifying the port number in the code eg:

    ("jdbc:mysql://12.123.123.123:3306/mysql", "user", "pasword");

    and allowing the port number in SeLinux.

    Can anyone help me with this problem, I'm not really sure where the problem lies. It could be in the code as I'm new to connecting to MySQL with Java, or whether it is a firewall problem on the server.

    Please help, cheers.

  2. #2
    Join Date
    Apr 2004
    Posts
    8
    Never mind, problem solved. If anyone else is having this problem, you must grant access to the IP address in mysql. eg:

    GRANT ALL PRIVILEGES ON *.* TO 'user'@'12.345.678.90' IDENTIFIED BY 'passsword'

Similar Threads

  1. Java vs. .Net. A questionnaire
    By Basil in forum .NET
    Replies: 1
    Last Post: 05-13-2005, 06:46 AM
  2. Connecting Java to MySQL
    By snowstorm in forum Java
    Replies: 3
    Last Post: 05-04-2005, 01:01 PM
  3. DevX does seem one sideded
    By Rob Abbe in forum Talk to the Editors
    Replies: 44
    Last Post: 01-13-2003, 02:57 PM
  4. learning c# very confusing.
    By Mike Tsakiris in forum .NET
    Replies: 11
    Last Post: 10-04-2002, 05:32 PM
  5. Re: VB vs. Visual Age for Java
    By JJ in forum Enterprise
    Replies: 1
    Last Post: 07-06-2000, 04:50 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center