This is my setup for using a database
with Java.
I have choosen MySQL as the database
for my project. The reason why I chose MySQL is because it is free
to use for non commercial use. It has no expiration period.
Some of the other databases have 60 or 90 day expiration periods.
Also MySQL is widely supported by different operating systems and has
drivers for almost any language. Last, but most importantly, MySQL
has excellent documentation.
mySQL
Setting up MySQL:
-
Make the download selection
"MySQL 3.23 -- Production release (recommended)"
from the MySQL website.
-
Choose version "Windows
95/98/NT/2000/XP" because we are using the Windows
operating system.
-
When installing, I chose a directory of
"C:\MySQL " as the installation directory.
-
I rebooted my machine.I went back to the MySQL website and
made the download selection "MySQL Control Center"
which is a
GUI interfaces to administer MySQL and data .
-
When installing, I chose a direction of
"C:\MySQL\mysqlcc ". I did this just to keep my hard
drive organized. But actually I don't see any reason for not being
able to use the default installation directory.
-
I rebooted my machine.
-
I went into the "C:\MySQL\bin "
directory and executed "winmysqladmin.exe "
-
At first it struck me as odd that a
screen opened and then quickly disappeared. If you look closely at
the Windows tray, you will see a stoplight icon.
-
Right click on the stoplight icon.
-
Browse through the various options.
I don't remember actually setting anything up. An initial "ini "
file was created for me.
-
Also a shortcut has been placed in the
start menu Programs/Start folder so that MySQL starts automatically next
time.
-
I rebooted my machine.
-
I ran the MySQL Control Center.
There is an entry in the start menu.
-
I did a file, new, register server.
I made up a server name of "laptopDB". Screenshot below
-
-
Then I created a database "test1", a
table "employees", created fields, and filled them in.
This is the "employees" example in the book.
-
Installing the Java driver:
-
I went back to the MySQL website and
made the download selection "MySQL Connector/J 2 -- stable release"
which is the driver to connect Java to MySQL.
-
When installing, I chose a direction of
"C:\MySQL\java ". I did this just to keep my hard drive
organized. But actually I don't see any reason for not being able to
use the default installation directory.
-
I rebooted my machine.
-
Pretty much all files are installed in
"C:\MySQL\java\mysqljava ".
-
I read the readme file and tried
setting the classpath to the above directory. This did not seem to
work.
-
So I did plan "B" which was to copy
"mysql-connector-java-2.0.14-bin.jar" to "C:\j2sdk\jre\lib\ext".
The following directions are for Sun
One:
-
Start Sun One.
-
On the "Runtime" tab, expand
"Databases", "Drivers".
-
Right click on "Drivers" and "Add
Driver"
-
-
Fill out the information as shown
above.
-
The driver name is "com.mysql.jdbc.Driver"
-
The Database URL is "jdbc:mysql://localhost:3306/test1"
-
Sun One is now configured.
-
You can now use the "JDBC form wizard"
under the "Tools" menu.
|