Sample statement – Select

Attached is a sample program to Select data from MySQL using the Muchach's DB.

Here is the sample code: JDBCselect.java (1.16 kb)

The Prerequisite are:

Expected results should be something like:

1, John Smith , jsmith@gmail.com

3, Joel Murach , joelmurach@yahoo.com

done.

This is the code we use in JDBCselect.java above:

System.out.println(
users.getString(1) + ", " +
users.getString(2) + " " +
users.getString(3) + "\t, " +
users.getString(4));

But this is more clear:

System.out.println(
users.getString("UserID") + ", " +
users.getString("FirstName") + " " +
users.getString("LastName") + "\t, " +
users.getString("EMAILADDRESS"));