oracle.sql.TIMESTAMP 解析错误处理

Raod 3 years ago
parent 95a137a36a
commit 5c95d34006

@ -33,11 +33,9 @@ import org.springframework.web.client.RestClientException;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.sql.Connection; import java.sql.*;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -243,7 +241,9 @@ public class DataSourceServiceImpl implements DataSourceService {
columns.forEach(t -> { columns.forEach(t -> {
try { try {
Object value = rs.getObject(t); Object value = rs.getObject(t);
jo.put(t, value); //数据类型转换
Object result = dealResult(value);
jo.put(t, result);
} catch (SQLException throwable) { } catch (SQLException throwable) {
log.error("error",throwable); log.error("error",throwable);
throw BusinessExceptionBuilder.build(ResponseCode.EXECUTE_SQL_ERROR, throwable.getMessage()); throw BusinessExceptionBuilder.build(ResponseCode.EXECUTE_SQL_ERROR, throwable.getMessage());
@ -267,6 +267,26 @@ public class DataSourceServiceImpl implements DataSourceService {
} }
} }
/**
* sql
* (through reference chain: java.util.HashMap["pageData"]->java.util.ArrayList[0]->java.util.HashMap["UPDATE_TIME"]->oracle.sql.TIMESTAMP["stream"])
* @param result
* @return
* @throws SQLException
*/
private Object dealResult(Object result) throws SQLException {
if (null == result) {
return result;
}
String type = result.getClass().getName();
if ("oracle.sql.TIMESTAMP".equals(type)) {
//oracle.sql.TIMESTAMP处理逻辑
return new Date((Long) JSONObject.toJSON(result));
}
return result;
}
/** /**
* http * http
* *

Loading…
Cancel
Save