So, I've created a game. I want it to connect to a database to get some information.
This is the problem I'm getting the console.

com.mysql.jdbc.CommunicationsException: Communications link failure due to under
lying exception:

** BEGIN NESTED EXCEPTION **

java.net.ConnectException
MESSAGE: Connection refused: connect

STACKTRACE:

java.net.ConnectException: Connection refused: connect
        at java.net.PlainSocketImpl.socketConnect(Native Method)
        at java.net.PlainSocketImpl.doConnect(Unknown Source)
        at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
        at java.net.PlainSocketImpl.connect(Unknown Source)
        at java.net.SocksSocketImpl.connect(Unknown Source)
        at java.net.Socket.connect(Unknown Source)
        at java.net.Socket.connect(Unknown Source)
        at java.net.Socket.<init>(Unknown Source)
        at java.net.Socket.<init>(Unknown Source)
        at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.ja
va:173)
        at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:267)
        at com.mysql.jdbc.Connection.createNewIO(Connection.java:2739)
        at com.mysql.jdbc.Connection.<init>(Connection.java:1553)
        at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java
:266)
        at java.sql.DriverManager.getConnection(Unknown Source)
        at java.sql.DriverManager.getConnection(Unknown Source)
        at net.com.hydroPK.MYSQL.createConnection(MYSQL.java:21)
        at net.com.hydroPK.model.Player.VoteCheck(Player.java:38)
        at net.com.hydroPK.net.packethandler.Commands.handlePacket(Commands.java
:105)
        at net.com.hydroPK.io.PacketManager.parsePacket(PacketManager.java:213)
        at net.com.hydroPK.io.Packets.parseIncomingPackets(Packets.java:92)
        at net.com.hydroPK.Engine.run(Engine.java:223)
        at java.lang.Thread.run(Unknown Source)


** END NESTED EXCEPTION **



Last packet sent to the server was 22 ms ago.
        at com.mysql.jdbc.Connection.createNewIO(Connection.java:2814)
        at com.mysql.jdbc.Connection.<init>(Connection.java:1553)
        at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java
:266)
        at java.sql.DriverManager.getConnection(Unknown Source)
        at java.sql.DriverManager.getConnection(Unknown Source)
        at net.com.hydroPK.MYSQL.createConnection(MYSQL.java:21)
        at net.com.hydroPK.model.Player.VoteCheck(Player.java:38)
        at net.com.hydroPK.net.packethandler.Commands.handlePacket(Commands.java
:105)
        at net.com.hydroPK.io.PacketManager.parsePacket(PacketManager.java:213)
        at net.com.hydroPK.io.Packets.parseIncomingPackets(Packets.java:92)
        at net.com.hydroPK.Engine.run(Engine.java:223)
        at java.lang.Thread.run(Unknown Source)

It's saying that the connection to the database was refused for some reason.. I've been trying to find my way around this for awhile, but for some reason, it's not working.

Seems like firewall issue, please open port on which you want to communicate.

hm.. alright. I'll try it.

It still gives the error.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.