0
다른 클래스에서 검색하려고하는 결과 집합은 쿼리가 작동하더라도 null을 반환합니다. 데이터베이스에 보관 된 레코드를 기반으로 개체를 초기화하려고합니다. 거기에 처음에 sqlite에 레코드가, 나는 최신 date.Else와 하나를 검색, 나는 mysql 데이터베이스에서 가장 빠른 것을 검색하려고합니다. MySQL 데이터베이스에서 설정 결과를 검색하도록되어 코드는 다음과 같다 :다른 클래스의 null 결과 문
public ResultSet lowestDate() throws SQLException {
ResultSet rs1 = null;
String resultQuery = "SELECT * FROM alarm ORDER BY `timestamp` ASC LIMIT 1";
rs1 = stmt.executeQuery(resultQuery);
return rs1;
}
문이 초기화 globally.And이 같은 다른 클래스에서이 호출된다
public void setLastAlarm() throws SQLException, ParseException {
String liteQuery = "SELECT * FROM alarm_entries ORDER BY date(`timestamp`) DESC LIMIT 1";
conn.connectLite();
Connection getCon = conn.getLiteConnection();
try {
stmt = getCon.createStatement();
} catch (SQLException e) {
e.printStackTrace();
}
try {
rs = stmt.executeQuery(liteQuery);
if (rs.next()) {
//while (rs.next()) {
nuDate = rs.getString("timestamp");
newDate = format.parse(nuDate);
lastAlarm.setBacklogId(rs.getBytes("backlog_id"));
lastAlarm.setTimestamp(newDate);
//}
}
else{
rsq=mysqlConnection.lowestDate();
lastAlarm.setTimestamp(format.parse(rsq.getString("timestamp")));
lastAlarm.setBacklogId(rsq.getBytes("backlog_id"));
}
}catch (Exception e){
e.printStackTrace();
}
}
public void run() {
try {
setLastAlarm();
그것은 작동하지 않았다, 그냥 모든 일 위에 점프이야, 왜 이런 일이 내가 같은 쿼리를 조회 할 때 데이터가 – Morbidity
아마도 첫 번째 쿼리가 반환 절대로 비어 있지 않습니다. 테이블에서 실제 데이터를 확인 했습니까? –
그래, 내가 무슨 뜻인지 테이블에있는 데이터를 확인하고 쿼리가 거기에서 작동하고있다 – Morbidity