Parts (jar files) that are not included in the standard system library are called "external libraries". The JDBC driver is one of the external libraries. In order to use an external library in addition to the standard system library, it is necessary to make settings to tell the compiler and JVM (JavaVirtualMachine: Java virtual environment) the location of this external library. This setting is called "CLASSPATH setting".
There are several ways to set the CLASSPATH, In this Qiita personal memo,
Here, we will describe the creation of ChkLoadJdbc, which will be created later, as an example.
Start Eclipse (Pleiades).
The operation will be performed from the Java perspective. (If it is not a Java perspective, switch to that perspective)
Right-click on a blank area in Package Explorer -> New-> Select Java Project
The "New Java Project" screen is displayed
Project name: ChkLoadJdbc will do Using the execution environment JRE: JavaSE-1.8 will do
Press the "Next" button
Select the "Library" tab here (You can also set it later in the << Confirmation method >> part)
Press the "Add External JAR" button
Open C: \ Program Files \ Java \ jdk x.x.x_xxx \ lib
Select mysql-connector-java-x.x.xx-bin.jar and press the "Open" button
Click the "Finish" button.
<< How to check >> Right click on Java project folder (ChkLoadJdbc) Select property Select "Java Build Path" Select "Library Tab" Make sure that mysql-connector-java-x.x.xx-bin.jar and the JRE system library are registered. If it is registered, the setting is complete.
If it is not registered, make the following settings.
Press the "Add External JAR" button Open C: \ Program Files \ Java \ jdk x.x.x_xxx \ lib
Or later,
Load the JDBC driver (check if you can connect to the database (MySQL) using the JDBC driver)
Create two programs (applications) in the order of connection to MySQL (connect to database (MySQL) to search table information and display search results).
Java-database connection / Java-MySQL connection ① Overview of JDBC and JDBC driver (2) JDBC driver acquisition method (for MySQL) and data connection preparation ③-1 How to set CLASSPATH in environment variable ③-2 How to set CLASSPATH to Eclipse build bus ④ Load JDBC driver ⑤ Connect to database (MySQL) to search table information and display search results
Recommended Posts