Sunday, November 4, 2012

Adding JDBC lib/Framework into project


17.1. Adding a library (.jar) to your project

The following describes how to add Java libraries to your project. Java libraries are distributed via "jar" files. It assumes that you have a jar file available; if not feel free to skip this step.
Create a new Java project de.vogella.eclipse.ide.jars. Then, create a new folder called lib, by right clicking on your project and selecting New → Folder.
Creating a new folder
From the menu select File → Import → General → File System. Select your jar and select the lib folder as target. Alternatively, just copy and paste your jar file into the lib folder.

Right click on your project and select Properties. Under Java Build Path → Libraries select the Add JARs button.
The following example shows how the result would look like, if the junit-4.4.jar file had been added to the project.

(Or simply add External JARs - one step)
Adding a jar to the current project
Afterwards you can use the classes contained in the jar file in your Java source code.

Adding JDBC lib into project


没有import jdbc lib会出现classNotFoundException

MySQL Command Line Client




Add the lib into your project: EX: Servlet framework; JDBC Driver
  • Right-click the project, click Properties.
  • Choose Java Build Path
  • Click Add JARs...  
  • Find servlet-api.jar in your project and select it.
  • Click OK to update the build path.

No comments:

Post a Comment