1 Replies - 12953 Views - Last Post: 12 April 2009 - 03:30 AM

#1 kmangala77  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 11-April 09

How to connect to database on my university server from my pc

Posted 11 April 2009 - 06:10 PM

Hi,
I am a grad student and having problem with connecting to database Mysql in our University's server. I have used the following code to connect. When I run this application I am getting communication failed error.Any help will be greatly appreciated.
 
import java.sql.*;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.net.*;

public class test {

	static public final String driver = "com.mysql.jdbc.Driver";
	static public final String connection =
		"jdbc:mysql://cs.metrostate.edu:3306/test" + "?autoReconnect=true" +
		"?user=ics625s916&password=4442&database=test";

	public static void main(String args[]) {

		try {
			Class.forName(driver).newInstance();
			Connection con = DriverManager.getConnection(connection);
			
			System.out.println("Jdbc Mysql Connection Url :");
			System.out.println(connection);

			if (!con.isClosed()) {
				con.close();
			}

		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}




Is This A Good Question/Topic? 0
  • +

Replies To: How to connect to database on my university server from my pc

#2 Hary  Icon User is offline

  • D.I.C Regular

Reputation: 44
  • View blog
  • Posts: 427
  • Joined: 23-September 08

Re: How to connect to database on my university server from my pc

Posted 12 April 2009 - 03:30 AM

The URI is correct, so I guesst uni is blocking traffic from outside the building to the database server. Ay my university, I have to use a VPN connection to access those machines.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1