JAVA database access

 

  1. Download the JDBC driver (contains the classes for the connection ie driver). (I could get more recent updates and try them out).
    1. MM.MySQL x.x.x Mark Matthews JDBC Driver for MySQL Copyright (c) 1998-2000 Mark Matthews
      1. download version 1.2b (type 4 driver) mm.mysql.jdbc-1.2b (Type IV JDBC driver for MySQL. Small (<120K), high performance, LGPL.) (http://www.worldserver.com/mm.mysql/).
      2. There are newer releases that come in JAR files.(not yet loaded or tried)
      3. There is also a driver on the mysql website: JDBC mm.mysql.jdbc-1.2c.tar.gz . (http://web.mysql.com/Contrib/) The mm JDBC driver for MySQL. This is a production release and is actively developed. By Mark Matthews (mmatthew@ecn.purdue.edu).
  1. Set the CLASSPATH which I do in the xxx.bat files using the classpath argument. (e:\jdk1.2.2\bin\javac -classpath "e:\java from C\javaklg;e:\mm.mysql.jdbc-1.2b" *.java)
  2. builld a java class: ConnectSQL.java
    1. Class.forName(dBDriver).newInstance();
    2. dBConnection = DriverManager.getConnection(dBServer, dBUser, dBPassword);
    3. rs = stmt.executeQuery("SELECT * from tableA");

The class ConnectSQL.java works and returns field in the database.

NOTE: I made sure that the password for the users account had 8 characters. In the process of making this work I discovered that this was a problem with the release that I have.