下图显示了对该数据库的简单查询, 将结果填充到常规 Java 类型中:

@Testpublic void retrieveRows() throws SQLException{    Connection connection = DriverManager.getConnection(            "jdbc:mysql://localhost:3306/mytest",            "root",            "root");    Statement stmt = connection.createStatement();    ResultSet rs = stmt.executeQuery("select employee_number,name from employees");    Map employeeMap = new HashMap<>();    while (rs.next()) {        int employeeNumber = rs.getInt("employee_number");        String name = rs.getString("name");        employeeMap.put(employeeNumber,name);    }    Map expectedMap = new HashMap(){{        put(1,"Bob Smith");        put(2,"Alice Smith");    }};    System.out.println(expectedMap.equals(employeeMap));    rs.close();    stmt.close();}