将从数据库中获取数据的Java代码

问题描述 投票:-1回答:1

将在给定图像中获取Reminder1的最后日期的Java代码是什么。 enter image description here

这是我写的,但是它是错误的

StringBuffer sql = new StringBuffer("SELECT * FROM TITAN_PORTAL.Scorecard_Reminder whereStatus='Active'");
        resultSet = stmt.executeQuery(sql.toString());
        while (resultSet.next()) {
            String reminder1 = resultSet.getString("Reminder1.Last_Date");
java mysql jdbc nativequery
1个回答
2
投票

使用表alias。以便更轻松地检索列名。

StringBuffer sql = new StringBuffer("SELECT * FROM TITAN_PORTAL.Scorecard_Reminder t1 whereStatus='Active'");
resultSet = stmt.executeQuery(sql.toString());
    while (resultSet.next()) {
        String reminder1 = resultSet.getString("t1.Last_Date");
© www.soinside.com 2019 - 2024. All rights reserved.