我想从街道列中的表中获取值。
我有:
Street = "SELECT strStreet FROM tblLocations WHERE" +
" strLocations='" + Location + "';";
当我稍后尝试打印出街道时,我刚想通出来的只是打印出上面的字符串而不是值
这就是我所拥有的并且它一直返回,街道的值为空
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());
}
答案 0 :(得分:0)
假设其余部分有效,您只在查询中选择strStreet
列,但是您尝试从结果集中提取strAddress1
列。