1 Reply Latest reply on Nov 27, 2011 9:09 PM by DrClap

    Error: Connection refused: connect



      I am trying to establish a connection to JWNL (Java WordNet Library). However I get the following error message when trying to open a database connection:

      java.net.ConnectException: Connection refused: connect         at java.net.PlainSocketImpl.socketConnect(Native Method)         at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)         at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)         at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)         at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)         at java.net.Socket.connect(Socket.java:525)         at java.net.Socket.connect(Socket.java:475)         at java.net.Socket.<init>(Socket.java:372)         at java.net.Socket.<init>(Socket.java:215)         at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:256)         at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:271)         at com.mysql.jdbc.Connection.createNewIO(Connection.java:2771)         at com.mysql.jdbc.Connection.<init>(Connection.java:1555)         at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:285)         at java.sql.DriverManager.getConnection(DriverManager.java:582)         at java.sql.DriverManager.getConnection(DriverManager.java:207)         at net.didion.jwnl.dictionary.database.ConnectionManager.getConnection(ConnectionManager.java:31)         at net.didion.jwnl.utilities.DictionaryToDatabase.main(DictionaryToDatabase.java:89)         at jwnltest.Main.main(Main.java:33)

      I have tried several URL's with combinations of localhost and, as well as with specific and default ports, but the problem persits.

      The code I have for establishing the connection is as follows:

       String sProjectPath = System.getProperty("user.dir");         String sPropertyFile= sProjectPath + "\\config\\file_properties.xml";         String sCreateTableScript = sProjectPath + "\\sql\\create.sql";         String sDriverClass="com.mysql.jdbc.Driver";         String sConnectionURL="jdbc:mysql://localhost:3306/jwnl?user='root'";         String[] mainargs = new String[4];         mainargs[0] = sPropertyFile;         mainargs[1] = sCreateTableScript;         mainargs[2] = sDriverClass;         mainargs[3] = sConnectionURL;         DictionaryToDatabase.main(mainargs) ;

      The config file has params for the driver and URL, which have to match those given as arguments.

      Has anyone else experienced this problem? I have searched online and seen similar problems, however the fixes for those don't seem to solve my particular issue. The JWNL forum is also not that active, so not a lot of help there.

      Thanks in advance :)

        • 1. Re: Error: Connection refused: connect
          899217 wrote:
          Has anyone else experienced this problem?
          There was a prize for the one-millionth person to report this problem on a forum, but it was given away years ago.

          Anyway the problem is (as it was for all those other people) that you aren't running a server on localhost (the computer where that code was running) which was listening on port 3306. You'll want to make sure your MySQL server is started before you run that code.