The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

Runnable jar doenst show data from database

Hello,

I am still working on my java course and now we have to create a jar file from a previous project (this is a project where a connection to the database is made and data is shown in a frame).
When I follow the instruction in my course material I don't get it to work.

This is what happens when I dbl click the jarfile (wampserver is running):
1. I get an error: "SQL ERROR: Communications link failure The last packet sent successfully to the server was 0 milliseconds ago. The driver has nog recieved any packets from the server."
2. I click ok on the message and the following message appears: "SQL Error: null"
3. I click ok on this message and the frame with the fields appears without data from the database.

Re: Runnable jar doenst show data from database

I haven't done this recently, but my guess is:

When running your code in Eclipse, the IDE takes care of the SQL-server housekeeping necessary to provide a server and a connection through the plugin. When running outside the IDE, the server needs to be started and waiting for client connections.

There are tutorials for connecting to an SQL Server both inside and outside an IDE. I'm thinking of the Vogella tutorials, but I haven't been there for a while.

Re: Runnable jar doenst show data from database

From what I've read this is a generic error message indicating the JDBC driver's inability to connect to the database. If you search the Internet using the search term "SQL ERROR: Communications link failure The last packet sent successfully to the server was 0 milliseconds ago", you'll find quite a few relevant hits.

One particular hit of note is the post at java - Solving a "communications link failure" with jdbc and mysql - Stack Overflow, where the poster managed to solve the problem, and helpfully posted a consolidated list of solutions that worked for at least 1 other person who had similar problems. There are quite a few solutions to be tried, so ensure that you approach this systematically. Try one by one (don't take the shortcut to try everything simultaneously), and undo each change before trying the next solution.