-4

我想从 Street 列中的表中获取值..

我有:

Street = "SELECT strStreet FROM tblLocations WHERE" +
            " strLocations='" + Location + "';";

当我后来尝试打印街道时,我刚刚发现它不起作用,只是打印为上面的字符串而不是值

这就是我所拥有的,它不断返回 street 的值为 null

    Street = "SELECT strStreet FROM tblLocations WHERE" +
            " strLocations='" + Location + "';";

    try {
        //create, execute and close the stmt
        Statement stmt = c.createStatement();
        ResultSet rs = stmt.executeQuery(Street);
        while(rs.next()){
            street = rs.getString("strAddress1");
        }
        System.out.println(street);
        rs.close();
        stmt.close();
    } catch (SQLException ex) {
        System.out.println("there was an issue updating");
        System.out.println("SQLException: " + ex.getMessage());
        System.out.println("SQLState: " + ex.getSQLState());
        System.out.println("VendorError: " + ex.getErrorCode());
    }
4

1 回答 1

0

假设其余的工作,您只选择strStreet查询中的列,但您正在尝试strAddress1从结果集中提取一列。

于 2013-06-19T13:57:06.880 回答