• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JDBC connection works in jar file on my computer but not anyone else's

 
Zachary Bohley
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not sure if this is the right place to post this, so I apologize if it should be somewhere else.

I recently created a program that allows a user to add "customers" into a database. I am using MySQL to manage the database and Netbeans IDE to write the code. I am able to compile the jar file and run it on my computer to add records to this database, but when I move it to another computer, everything seems to work normally. When I look at the database records however, the customer has not been added and it appears as if MySQL has completely ignored my command. I am not sure if this is a MySQL problem or if there is a problem with my JAR file that would cause it to not function properly on other computers.

Thank you for your time.
 
Paul Clapham
Sheriff
Posts: 20983
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It probably isn't a problem with MySQL. And it probably isn't a problem with your JAR file.

However the problem at present is that you can't tell what the problem is. Most likely that's because you have your program written to ignore exceptions. Do you have catch-blocks which look like this?



If so, fix them so they display the exception (and its stack trace) in some place where you can see them. At any rate your first task is to find out what exceptions are being thrown.
 
William P O'Sullivan
Ranch Hand
Posts: 859
Chrome IBM DB2 Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do these other computers have the required mysql jars, correct connection strings,

*AND* are they allowed to. There could be some firewall, networking issues also.

If you are not getting any descriptive errors, then Paul may be correct.

WP
 
Zachary Bohley
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:It probably isn't a problem with MySQL. And it probably isn't a problem with your JAR file.

However the problem at present is that you can't tell what the problem is. Most likely that's because you have your program written to ignore exceptions. Do you have catch-blocks which look like this?



If so, fix them so they display the exception (and its stack trace) in some place where you can see them. At any rate your first task is to find out what exceptions are being thrown.


Paul, I think you are right about my code ignoring exceptions. Here is an example of the code that I am trying to run:



I'm not sure how I can show exceptions on a computer that does not have an IDE. I'm admittedly a bit new at running jar files on computers that I am not programming on. Do you have any ideas?


William P O'Sullivan wrote:
Do these other computers have the required mysql jars, correct connection strings,

*AND* are they allowed to. There could be some firewall, networking issues also.

If you are not getting any descriptive errors, then Paul may be correct.

WP


I disabled the Windows firewall on the server and our workstations, so I think I can rule that out. As far as the mysql jars and connection strings... I think it's correct. I included the MySQL drivers and libraries when I compiled.
 
Paul Clapham
Sheriff
Posts: 20983
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Zachary Bohley wrote:I'm not sure how I can show exceptions on a computer that does not have an IDE. I'm admittedly a bit new at running jar files on computers that I am not programming on. Do you have any ideas?


Sure. Pretend you don't have the IDE and run the program in exactly the same way you plan to run it on those other computers.

I included the MySQL drivers and libraries when I compiled.


But that wasn't the question. The question was whether they were sent to the other computers.

It seems that you're a typical victim of IDEs. New programmers are talked into using an IDE because it makes it easier to write programs, but then they don't learn what it takes to actually run Java code. So like I suggested, put the IDE aside and try to run your program from the command line in your own computer.
 
Zachary Bohley
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looks like the problem was that my MySQL drivers weren't being included in the jar file.. It has been solved now. Thank you for your help.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34225
341
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Great! Thanks for posting the solution!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic