// Author: Robert Lie (mobilefish.com)
//
// Note: How to install the MySQL Connector/J JDBC driver can be found at:
// https://www.mobilefish.com/developer/mysql/mysql_quickguide_connector_3.0.11.html
// This code example is based on MySQL 4.0.18
// MySQL Connector/J 3.0.11 is used.
//

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import com.mysql.jdbc.Driver;

public class RetrieveRecordsMySQLTable {

    public static void main (String args []) throws SQLException {
        DriverManager.registerDriver(new Driver());

        //jdbc:mysql://machine:port/database?user=myuser&password=mypass
        Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/mobilefishdb?user=root&password=mysecret");

        Statement stmt = conn.createStatement();
        ResultSet rset = stmt.executeQuery("select street from address");
        while (rset.next()) {
            System.out.println (rset.getString(1));
        }
        stmt.close();
    }
}
