|
|
@ -10,6 +10,8 @@ import java.sql.SQLException;
|
|
|
|
import java.sql.SQLWarning;
|
|
|
|
import java.sql.SQLWarning;
|
|
|
|
import java.sql.Statement;
|
|
|
|
import java.sql.Statement;
|
|
|
|
import java.sql.Types;
|
|
|
|
import java.sql.Types;
|
|
|
|
|
|
|
|
import java.text.DateFormat;
|
|
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Vector;
|
|
|
|
import java.util.Vector;
|
|
|
|
|
|
|
|
|
|
|
@ -66,7 +68,9 @@ public class SqlExecutor {
|
|
|
|
Statement stmt = conn.createStatement();
|
|
|
|
Statement stmt = conn.createStatement();
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
stmt.execute(sql.trim());
|
|
|
|
String cleanedSql = sql.trim();
|
|
|
|
|
|
|
|
cleanedSql = cleanedSql.replaceAll("/$", "");
|
|
|
|
|
|
|
|
stmt.execute(cleanedSql);
|
|
|
|
log.info("Executed");
|
|
|
|
log.info("Executed");
|
|
|
|
} catch (SQLException e) {
|
|
|
|
} catch (SQLException e) {
|
|
|
|
return Result.builder() //
|
|
|
|
return Result.builder() //
|
|
|
@ -175,7 +179,9 @@ public class SqlExecutor {
|
|
|
|
ColumnBuilder columnBuilder = Column.builder();
|
|
|
|
ColumnBuilder columnBuilder = Column.builder();
|
|
|
|
|
|
|
|
|
|
|
|
int columnType = metaData.getColumnType(columnIndex);
|
|
|
|
int columnType = metaData.getColumnType(columnIndex);
|
|
|
|
if (columnType == Types.VARCHAR) {
|
|
|
|
if (rs.getString(columnIndex) == null) {
|
|
|
|
|
|
|
|
columnBuilder.value(null);
|
|
|
|
|
|
|
|
} else if (columnType == Types.VARCHAR) {
|
|
|
|
columnBuilder.value(rs.getString(columnIndex));
|
|
|
|
columnBuilder.value(rs.getString(columnIndex));
|
|
|
|
} else if (columnType == Types.NUMERIC) {
|
|
|
|
} else if (columnType == Types.NUMERIC) {
|
|
|
|
columnBuilder.value(rs.getLong(columnIndex));
|
|
|
|
columnBuilder.value(rs.getLong(columnIndex));
|
|
|
@ -184,19 +190,17 @@ public class SqlExecutor {
|
|
|
|
} else if (columnType == Types.TIME) {
|
|
|
|
} else if (columnType == Types.TIME) {
|
|
|
|
columnBuilder.value(rs.getTime(columnIndex));
|
|
|
|
columnBuilder.value(rs.getTime(columnIndex));
|
|
|
|
} else if (columnType == Types.TIMESTAMP) {
|
|
|
|
} else if (columnType == Types.TIMESTAMP) {
|
|
|
|
columnBuilder.value(rs.getTimestamp(columnIndex));
|
|
|
|
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
|
|
|
columnBuilder.value(df.format(rs.getTimestamp(columnIndex)));
|
|
|
|
} else if (columnType == Types.CLOB) {
|
|
|
|
} else if (columnType == Types.CLOB) {
|
|
|
|
Clob clob = rs.getClob(columnIndex);
|
|
|
|
Clob clob = rs.getClob(columnIndex);
|
|
|
|
if (clob != null) {
|
|
|
|
|
|
|
|
columnBuilder.value(clob.getSubString(1, 100));
|
|
|
|
columnBuilder.value(clob.getSubString(1, 100));
|
|
|
|
} else {
|
|
|
|
|
|
|
|
columnBuilder.value(null);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if (columnType == Types.BLOB) {
|
|
|
|
} else if (columnType == Types.BLOB) {
|
|
|
|
columnBuilder.value("[BLOB]");
|
|
|
|
columnBuilder.value("[BLOB]");
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
String message = String.format("Unhandled column type <%s>. Defaulting to String", rs.getMetaData().getColumnTypeName(columnIndex));
|
|
|
|
String message = String.format("Unhandled column type <%s>. Defaulting to String", rs.getMetaData().getColumnTypeName(columnIndex));
|
|
|
|
log.warn(message);
|
|
|
|
log.warn(message);
|
|
|
|
|
|
|
|
columnBuilder.value(rs.getString(columnIndex));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
columns.add(columnBuilder.build());
|
|
|
|
columns.add(columnBuilder.build());
|
|
|
|