?
Solved

Java jdbc connection

Posted on 2011-09-25
12
Medium Priority
?
291 Views
Last Modified: 2012-05-12
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.

0
Comment
Question by:sargent240
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 5
12 Comments
 
LVL 47

Expert Comment

by:for_yan
ID: 36596525
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/
0
 
LVL 47

Expert Comment

by:for_yan
ID: 36596532
0
 

Author Comment

by:sargent240
ID: 36596697
Are you saying I need the mysql.connection.java jar file?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 47

Expert Comment

by:for_yan
ID: 36596710
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
0
 

Author Comment

by:sargent240
ID: 36596987
That file is installed.  I think the problem is telling netbeans where to find it and that is what I am not sure of.  
0
 
LVL 47

Expert Comment

by:for_yan
ID: 36597219
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
0
 

Author Comment

by:sargent240
ID: 36602606
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
0
 
LVL 47

Accepted Solution

by:
for_yan earned 2000 total points
ID: 36602614
I don't have Netbeans 7.0, I have 6.9

But the main class you set if you right-click the project and go to Properties - then go to Run (in the left column), then on the right side
you can type the main class or browse to it

0
 
LVL 47

Expert Comment

by:for_yan
ID: 36602616
I doubt if they changed in 7.0 that way I suggested above.
0
 
LVL 47

Expert Comment

by:for_yan
ID: 36602855
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

0
 

Author Comment

by:sargent240
ID: 36616425
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.
0
 

Author Closing Comment

by:sargent240
ID: 36672977
Top notch.  Great to work with
0

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Suggested Courses
Course of the Month11 days, 17 hours left to enroll

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question