java中请给出一个JDBC的HelloWorld例子

在做以下的实验之前。我们的前提条件是:必须先安装一个mysql数据库在电脑中,(因为这个数据库在所有的数据库当中,相对来讲是最简单的。适合初学者使用和学习,而且这个数据库,现在在很多中小型公司,都还在使用。)而且数据库当中,要有一个表叫login。其中有两个字段,一个叫id,一个叫 name。两个字段都是string类型的。马克- to-win:马克 java社区:防盗版实名手机尾号: 73203。
例:2.1.1
public class TestMark_to_win {
    public static void main(String[] args) throws java.sql.SQLException,
            ClassNotFoundException {
        java.sql.Connection connection = null;
        java.sql.Statement statement = null;
        java.sql.ResultSet resultSet = null;
        Class.forName("com.mysql.jdbc.Driver");
        connection = java.sql.DriverManager.getConnection(
                "jdbc:mysql://localhost:3306/test", "root", "1234");
        statement = connection.createStatement();
        resultSet = statement.executeQuery("select * from login");
        while (resultSet.next()) {
            System.out.println(resultSet.getString("id") + "--"
                    + resultSet.getString("name"));
        }
        resultSet.close();
        statement.close();
        connection.close();
    }
}

输出结果:

1--q
2--qq