Link to home
Start Free TrialLog in
Avatar of sargent240
sargent240Flag for United States of America

asked on

Java jdbc connection

I had a hard drive fall apart and had to install a new hard drive.  I had a backup of the directories with my projects in them and copied them back to the new hard drive.  I installed the latest version of NetBeans and am trying to compile one of my projects.  It compiled fine on the hard drive that crashed before it crashed.  There is an error in the source code saying it can't

import com.mysql.jdbc.connection

I suppose the new install of the libs and so forth put things where NetBeans can't find them.  I have looked around but can't remember where to go to make sure the library is available.  Need a hand telling NetBeans where things are.
Thanks.

Avatar of for_yan
for_yan
Flag of United States of America image

You need to dowanload MySql
JDBC driver - downlosd this -expand it and put jar in the classpath:
http://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-5.1.17.zip/from/http://mysql.he.net/
Avatar of sargent240

ASKER

Are you saying I need the mysql.connection.java jar file?
You need the jar file which contains the driver for MySQL
This file mysql-connector-java-5.1.9.jar should have this driver and should be placed in
the classpath of your project
That file is installed.  I think the problem is telling netbeans where to find it and that is what I am not sure of.  
In Netbeans right-click on your project - select Properties - then in the winodw in the left column
select libraries, then on th right press button Add jar/folder, brwose to the folder where you have this jar and add the jar
That was the cure Yan! Thanks a lot!

I have one other quick question while you are on the line.  I have updated Netbeans to the latest (I think it's 1.7.0 or something like that) and I lost the place where I set the main project.  I used to right click on the project and there was an option to

set as main project.

I don't see that now.  Has it been moved?
Cheers
ASKER CERTIFIED SOLUTION
Avatar of for_yan
for_yan
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I doubt if they changed in 7.0 that way I suggested above.
Another way - more probable could have changed - is you right-click the projects - and then go not to the very bottom, where you see properties
but halfway - like Edit configurations or Run configurations or something about configurations
Then you sleecte customize from short dropdown - adn you should come to the sasme screen as Properties-Run

I don't think we are in the right place yet.  I have three projects loaded and one of them is highlighted.  If I select Run at the top of the Netbeans screen and then select

Run main project

which is the first item in the drop down it executes the project that is highlighted.  How do I highlight one of the other projects so it is the main project when I select Run and Run main project.
Top notch.  Great to work with