This week's book giveaway is in the Spring forum.
We're giving away four copies of Spring in Action (5th edition) and have Craig Walls on-line!
See this thread for details.
Win a copy of Spring in Action (5th edition) this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

My software won't connect with the database after clean and build in netbeans  RSS feed

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After clean and build in netbeans.The jar file won't connect with the database(MySQL) .My project works perfectly well while still in the IDE . how do I solve this problem so I can install my software into another machine.
 
Saloon Keeper
Posts: 5035
134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What does "won't connect" mean? Are there any error messages or exceptions? If so, post the full stack trace (assuming that the code hopefully does not ignore exceptions). Are all required libraries in the classpath, expecially the JDBC driver?
 
Dan Samarasinghe
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for replying.It means when I run my project in Netbeans , it communicates with the MySQL database.For example, a list of names in the database can be loaded into a combo box. But when I run my project using the executable jar file which  Netbeans prepares,this process does not happen.It's like there's no connection between my software and the database..
I have attached an image file of my connection class.You can notice in that image that I have also added the MySQL connector jar file into the library
Screenshot-(6).png
[Thumbnail for Screenshot-(6).png]
 
Tim Moores
Saloon Keeper
Posts: 5035
134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the future, please do not post screenshots of code and other text - post the text instead, so it can be quoted and copied/pasted.

I have also added the MySQL connector jar file into the library


But this is inside of NetBeans, where, as you said, the code runs fine. If you run the code outside of NetBeans -please tell us how you do that-, how are you adding the required libraries to the classpath?

Also, as there is logging in place, post the logging output of the code.
 
Ranch Hand
Posts: 207
3
Java MySQL Database Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, one thing I told you is that according to JDBC 4.1 Version or from Java 7 onwards you won't require to perform the first step of the JDBC i.e, you won't need to Load and Register Driver.
that will be automatically done by the JDBC url through the jar file.

So line 42 of your program is redundant, even you write it or not, the output comes out to be same.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!