Today,I tried to run the below standalone application from MyEclipse(trying to connect MYSql database)
import java.sql.Connection;
import java.sql.DriverManager;
public class Testmysql {
public static void main(String[] args)throws Exception {
Class.forName(“com.mysql.jdbc.Driver”);
Connection conn=DriverManager.getConnection(“jdbc:mysql://localhost/test”, “root”, “admin”);
System.out.println(conn);
}
}
I got the below exception:
Exception in thread “main” com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception:
** BEGIN NESTED EXCEPTION **
java.net.SocketException
MESSAGE: java.net.SocketException: Permission denied: connect
STACKTRACE:
java.net.SocketException: java.net.SocketException: Permission denied: connect
at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:150)
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:270)
at com.mysql.jdbc.Connection.createNewIO(Connection.java:2635)
at com.mysql.jdbc.Connection.<init>(Connection.java:1525)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:260)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at tetemy.main(tetemy.java:14)
** END NESTED EXCEPTION **
.
The same proggrame i tried to run from command prompt,then i am able to run the proggram successfully,in this case i am able to print the connection object
I am using Windows vista(Operating System).Please guide me on how to overcome this problem.I am facing this problem from months.
Any help will be greatly appreciated.