Download mysql from here:
http://dev.mysql.com/downloads/mysql/5.0.html#macosx-dmg
and install the database and the preference pane, which will let you startup and shutdown mysql from the system prefences window.
Open System Preferences and start up MySQL. You can now start Terminal.app and connect to the database. I have put the line
PATH="/usr/local/mysql/bin:${PATH}"
in my ~/.bash_profile
If you do this, open a new Terminal and type
mysql -u root
you are then connected to the database running on your computer.
You can then create a database, tables, etc. all through the command line using all the SQL you know. Lots of good tutorials on the net if you need to refresh your memory and dev.mysql.com has a good reference
http://dev.mysql.com/doc/refman/5.0/en/index.html if you don't.
Here go for
create database testdb;
use testdb;
create table testtbl (digit integer, word varchar(10));
insert into testtbl values (1, 'one'), (2, 'two');
select * from testtbl;
Download the JDBC driver from here
http://dev.mysql.com/downloads/connector/j/5.0.html
and move the .jar file 'somewhere permanent' (I put stuff I use to develop with in ~/Library/Java/JDBC)
Download eclipse (or netbeans)
http://www.eclipse.org/downloads/
Untar it and copy into a folder in Applications
Open up Eclipse, accept the default workspace or set it to your directory of choice, close the tutorial window (you can come back later) and then select File -> New -> Project ...
Then Java Project (top of the list), hit next, then enter a name for your project, hit next, and on the next window, select Libraries, the Add External Jars then navigate to the jar file you downloaded. Then click Finish.
Then select File -> New ->Class
Call it Example (or something like that). Add package org.test or something to hide the warning message. Select the
public static void main(String [] args)
check box.
Enter the code below in Example.java
Code:
package org.test;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
public class Example
{
public static void main(String[] args) throws Exception
{
Class.forName("com.mysql.jdbc.Driver");
String url = "jdbc:mysql://localhost:3306/testdb";
String user = "root";
String pass = "";
Connection mySQLConnection = DriverManager.getConnection(url, user, pass);
Statement statement = mySQLConnection.createStatement();
String query = "SELECT * FROM testtbl";
ResultSet results = statement.executeQuery(query);
System.out.println("Table Contents");
while (results.next())
{
int digit = results.getInt(1);
String word = results.getString(1);
System.out.println("Digit : " + digit + " Word : " + word);
}
System.out.println("Done");
results.close();
statement.close();
mySQLConnection.close();
}
}
Then select on the top menu Run -> Run...
If you double click on Java Application (this might happen automatically, scanning for the
main(...) function) it should create a new entry under Java Application called Example.
Then click Run to run connect to the database and read the contents of the table.
That should be about it ... the rest will come back to you after that.
(Just spent the afternoon getting some guys started with exactly the same thing - good timing!)