Section 13.11. Configuring MySQL Database Server

   

13.11 Configuring MySQL Database Server

In this section, we will walk through the few simple steps required to set up MySQL on your machine. We will create a database to use in conjunction with this database server. You do not need to set up MySQL. You can use any database you like. Just make the necessary adjustments in the application code we will write. You can use Microsoft Access using the JDBC/ODBC bridge for development, but you'll need to download a driver and install it if you want to use another production-quality RDBMC. Skip this section if you already have MySQL or want to use another database server.

The following instructions are for Windows XP Professional and shouldn't be wildly different for other platforms. Here are the steps:

  1. Download the dataserver from www.mysql.com. Get the most recent production-quality release. The current one is 3.23, but 4.0 is in alpha and may be ready by the time you read this.

  2. Extract the file to C:\MySQL .

  3. Run setup.exe and move through the wizard. Once you have installed it, you need to set up a database.

  4. To work with your databases in a GUI environment, go into MySQL\bin and click MySqlManager.exe. Otherwise, you can run MySQL from the command line. Navigate into the MySQL\bin directory and run mysql .

  5. You may need to register your MySQL server so you can connect to it. This process is similar to the MS SQL Server registration. I will use these settings:

    Server: eben

    Host: localhost

    Port: 3306

    LoginID: admin

    Password: admin

If you want to install it as a service, which is a good idea on Windows NT or 2000, then open a shell and type this:

 C:\MySQL\bin>mysqld-nt --install 

You should see this message:

 Service successfully installed. 

Now MySQL should be up and running on your system. You can use standard SQL commands to create and modify your database. To see syntax specific to MySQL, look up the comprehensive online documentation at www.mysql.com.

13.11.1 Installing a JDBC Driver

In order to use MySQL with Tomcat, you need to get a JDBC driver that works with this database system. I will use a Type IV driver that can be downloaded for free at http://mmmysql. sourceforge .net. You can also use, for example, the Microsoft Type IV driver for SQL Server, which is a free download.

To install the driver, open the .jar using WinZip. Extract it to C:\jdk1.4\jre\lib\ext. This will make sure that it is always accessible to the JDK without having to bother with the class path . The other place you can install it if you want to use it with just this one Web application, is to place it under javaforcf/WEB-INF/lib .

It will create a folder called something like mm.mysql-2.0.14 , depending on your version. You should restart Tomcat so it picks up your new extension, and you should be ready to access a database from the Web.


   
Top


Java for ColdFusion Developers
Java for ColdFusion Developers
ISBN: 0130461806
EAN: 2147483647
Year: 2005
Pages: 206
Authors: Eben Hewitt

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net