Attention: Every now and then a change in the host server's state can cause MySQL to fail starting up, which, if it does happen generally does so on boot. (I don't actually know what caused the last instance of this failure on my development system, but things, such as a change of IP address assignments, did change the machine environment.) I have found that it usually takes the removal and recreation of the my.ini file in the WINNT directory for the starting of MySQL service to happen in this case. It is very important to reuse the original user/password combination (in my case, "admin/admin") to be able toaccess any DBs created under that account. For more detail review section I. below.
I. Installing MySQL into Windows Server 2000
NOTE: If you are on NT and install MySQL in any other folder than C:\MYSQL and you intend to start MySQL as a service, you must or edit a file named C:\MY.INI (the MY.INI file will default to C:\WINNT directory) with the following information:
[mysqld]
basedir=E:/your-installation-path
Special Note: If you are re-installing MySQL delete or rename the existing my.ini file, otherwise you may introduce conflicts by inheriting the prior installations's version of this file. (The MySQL uninstaller does not remove this file.)
[WinMySQLadmin]
Server=C:/mysql/bin/mysqld-nt.exe
user=admin
password=admin
GRANT ALL PRIVILIGES ON *.* TO admin@localhost IDENTIFIED BY 'admin' WITH GRANT OPTION;
(The "IDENTIFIED" clause may be optional if no password, "admin" in this case, was supplied.)
II. Creating and Accessing the ODBC MySQL DB Connection Object
II.1. Installing and Registering the MyODBC Driver for MySQL with the Windows OS:
The steps to do this are as follows, using my actual MySQL DB called, 2000toMySQL:
II.2. Registering the MySQL DB as a Datasource with the Windows OS:
The steps to do this are as follows, using my actual MySQL DB called, 2000toMySQL:
II.3. Creating and Accessing the ODBC MySQL DB Connection Object from VBScript
The following is a working VBSript sample of code I used to create the MySQL connection object:
<%@ LANGUAGE = VBScript %>
<%
' Open/Create MySQL DB to get Access2000 data - these live at mysql\data\2000toMYSQL
Set OBJmysqlDbConnection = Server.CreateObject("ADODB.Connection")
OBJmysqlDbConnection.Open("Driver={mySQL}; Server=localhost; DATABASE=2000toMYSQL; UID=admin; PWD=admin;")
SQLQuery = "CREATE TABLE MASS_COUNTIES (COUNTY_ID INTEGER NOT NULL , COUNTY_NAME CHARACTER(30) NOT NULL ) ;"
connectionStatus = OBJmysqlDbConnection.Execute(SQLQuery)
%>
III. JSP Installation JDBC for MySQL into a J2EE Server
In the setenv.bat file add environement variable values for both CLASSPATH and J2EE_CLASSPATH. Ensure to have the .JAR JDBC j-archive files pointed at in the J2EE_CLASSPATH. In this example we shall use the a 3rd party MySQL JDBC driver in the file. mm.mysql-2.0.4-bin.jar:
set CLASSPATH=.;%JAVA_HOME%\lib set J2EE_CLASSPATH=.;%J2EE_HOME%\lib;%J2EE_HOME%\lib\system;%J2EE_HOME%\lib\system\mm.mysql-2.0.4-bin.jar
** JDBC drivers must reside in %J2EE_HOME%\lib\system as this directory is cleared for the system permissions required for the type of system level activities performed by this class of drivers.Make sure that the the J2EE server is stopped and do the following, again using MySQL as an example:
(For the j2eeadmin tool usage go to http://java.sun.com/j2ee/tutorial/doc/Tools2.html#63229. The following also points to the JDBS section included with the j2ee documentation in the actual j2ee installation: file:///D:/j2sdkee1.3/doc/release/ConfigGuide.html#12442)
For drivers without XA Datasource support:
1. Add the JDBC driver.
Syntax:
j2eeadmin -addJdbcDriver <class name>
My actual MySQL example:
j2eeadmin -addJdbcDriver org.gjt.mm.mysql.Driver
Oracle Example:
j2eeadmin -addJdbcDriver oracle.jdbc.driver.OracleDriver
2. Add the DataSource:
Syntax:
j2eeadmin -addJdbcDatasource <jndi name> <url>
My actual MySQL example:
j2eeadmin -addJdbcDatasource jdbc/MySQL jdbc:mysql:localhost:3306:2000toMySQL
Oracle Example:
j2eeadmin -addJdbcDatasource jdbc/Oracle jdbc:oracle:thin@rtc:1521:acct
NB: This presumes that 1.) an ODBC Driver for MySQL has been installed and registered with the Windows OS and that 2.) the MySQL DB has been registered as a Datasource with the Windows OS. The steps for doing this are listed after item 3, below.
3. Restart the server and browse to the server (localhost:8000 or localhost:9191 on my J2EE setup):
j2ee [-verbose]
We will actually want to use a native MySQL driver so that we do not have to register datasources with Windows, an extra maintenance step we do not want to pursue. However, in my initial investigations in how to access MySQL DBs from ASP led me to using a Windows based ODBC driver. The MM and Caucho drivers that I have downloaded and tinkered with are actually native type 4 dirvers for MySQL. The MyODBC driver is used to register MySQL DBs as a datasource in Windows ODBC so that they may be accessed from ASP. JSP, on the other hand, requires eith the MM or Caucho driver for MySQL access. What is confusing, and I am still working out, is the rquirement for a j2eeadmin datasource registration, perhaps is merely a nomenclature issue. My research on Deja seems to indicate this j2eeadmin datasource requirement reflected by the following JSP code fragment:
String MySQLdriver = "org.gjt.mm.mysql.Driver";
String MySQLurl = "jdbc:mysql://localhost:3306/2000toMySQL/?user=admin?password=admin";
// Make the JDBC connection object.
Class.forName(MySQLdriver);
MySQLconn = DriverManager.getConnection(MySQLurl);
MySQLstatement = MySQLconn.createStatement();