Accessing MySQL on NetBeans using JDBC, Part I: Create a connection
Java, NetBeans December 5th, 2007
This tutorial show you how to use NetBeans to connect MySQL by using MySQLConnector/J, MySQL AB’s JDBC Driver for MySQL.
I’ll divide into 2 parts:
Part I : Create a connection
This part which you’re reading shows about how to establish a connection betweenNetBeans and MySQL.
Part II : Perform SQL Operations
This part show how to perform some basic operations from NetBeans to MySQL. For instance, send querys as SELECT, INSERT, UPDATE to a database.Requirements
MySQL Connector/J, licensed under the GPL or a commercial license
from MySQL AB.
NetBeans with JRE (Java Runtime Environment).
Download MySQL Connector/J, name ‘mysql-connector-java-5.0.6.zip’. (The file name may differs depends on the version if you’ve downloaded from the Official Siteat here.)
Extract the zip file to a folder, you’ll see file ‘mysql-connector-java-5.0.6-bin.jar’ which is the library file that we want. Just copy the file to the library folder, for exampleto “C:\Program Files\Java\jdk1.6.0_02\lib” directory.
the library file
Add JDBC Driver to the project on NetBeans (Add a library).
Next, I create a new Java project on NetBeans named‘TestMySQL’ and add ‘mysql-connector-java-5.0.6-bin.jar’ that I’ve just extracted from previous step to the project’s library.
Create New Project called TestSQL.
Create newNetBeans's project
In Projects window, right click the project name and select Properties.
Open project's properties
Project Properties window appears. The Categories on leftside, select Libraries. And on right side in Compile tab, click Add JAR/Folder.
Add JAR file
New Window appears, browse to the file ‘mysql-connector-java-5.0.6-bin.jar’ and click Open....
Leer documento completo
Regístrate para leer el documento completo.