Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 899163
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T15:10:21+00:00 2026-05-15T15:10:21+00:00

I am trying to connect my Java Applet to a MySQL Database. I know

  • 0

I am trying to connect my Java Applet to a MySQL Database. I know that it works, because I can connect to it on localhost and it retreives a list of records just fine. But when I put it on the internet, it doesn’t work.

Here is my applet: http://mystikrpg.com/play

It’s signed, but I keep getting the following exception:

SQLException Get Cause: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.

How can this happen and what can I do to fix this problem?

Here’s the applet source code: http://sodan.pastebin.com/jWKTgBSU

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T15:10:21+00:00Added an answer on May 15, 2026 at 3:10 pm

    To start, the following exception

    com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: 
      Communications link failure

    can have the following causes:

    1. IP address or hostname in JDBC URL is wrong.
    2. Hostname in JDBC URL is not recognized by local DNS server.
    3. Port number is missing or wrong in JDBC URL.
    4. DB server is down.
    5. DB server doesn’t accept TCP/IP connections.
    6. DB server has run out of connections.
    7. Something in between Java and DB is blocking connections, e.g. a firewall or proxy.

    Further, do you realize that an Java Applet physically runs at the client machine? I.e. the machine where the webbrowser runs. The client basically downloads the applet from the webserver and it get executed at client (local) machine. The JDBC connection string jdbc:mysql://localhost:3306 would try to connect to a MySQL database running at the very same machine as where the applet runs. You can’t reasonably expect that every client on the world will run a MySQL DB, let alone with your database/table.

    If all you want is to access the MySQL server hosted at the server machine (there where the webserver runs) and you want to let the applet communicate with it, then you really have to create and run a webservice at the webserver. Since you tagged this question with [PHP] as well, I guess that you’re using PHP at the server side, in that case, just create a PHP script which executes the MySQL action accordingly based on the request parameters or pathinfo and returns the MySQL results as for example a JSON or XML string. In the Applet, you can use the Java SE builtin java.net.URLConnection or the more convenienced Apache HttpComponents Client to communicate with the webserver. E.g.

    URLconnection connection = new URL(getCodeBase(), "script.php?action=getdetails&productid=1").openConnection();
    InputStream response = connection.getInputStream();
    // ...
    

    In Java, you could process any JSON response using Google Gson any XML response using JAXP.


    That said (and unrelated to the current problem), the JDBC driver name you’re using is the deprecated org.gjt.mm.mysql.Driver. I strongly recommend to use the correct driver name which was introduced over a decade ago to replace the old driver name: com.mysql.jdbc.Driver. Further, the Class#newInstance() call after Class#forName() is also not needed. It was to workaround a bug in the old driver. Also see this explanation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 468k
  • Answers 468k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer If typeof returned undefined for your functions, chances are there… May 16, 2026 at 2:26 am
  • Editorial Team
    Editorial Team added an answer It seems what you're looking for are XML::Twig's finish_print and… May 16, 2026 at 2:26 am
  • Editorial Team
    Editorial Team added an answer nth-child selectors are set on the child element, not the… May 16, 2026 at 2:26 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.