mirror of
https://github.com/CodePhiliaX/Chat2DB.git
synced 2025-07-29 18:53:12 +08:00
remove e.printStackTrace();
This commit is contained in:
@ -6,6 +6,7 @@ import ai.chat2db.spi.jdbc.DefaultDBManage;
|
|||||||
import ai.chat2db.spi.sql.Chat2DBContext;
|
import ai.chat2db.spi.sql.Chat2DBContext;
|
||||||
import ai.chat2db.spi.sql.ConnectInfo;
|
import ai.chat2db.spi.sql.ConnectInfo;
|
||||||
import ai.chat2db.spi.sql.SQLExecutor;
|
import ai.chat2db.spi.sql.SQLExecutor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.ObjectUtils;
|
import org.apache.commons.lang3.ObjectUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
@ -13,6 +14,7 @@ import java.sql.Connection;
|
|||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
public class DB2DBManage extends DefaultDBManage implements DBManage {
|
public class DB2DBManage extends DefaultDBManage implements DBManage {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -93,7 +95,7 @@ public class DB2DBManage extends DefaultDBManage implements DBManage {
|
|||||||
try {
|
try {
|
||||||
SQLExecutor.getInstance().execute(connection, "SET SCHEMA \"" + schemaName + "\"");
|
SQLExecutor.getInstance().execute(connection, "SET SCHEMA \"" + schemaName + "\"");
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,9 +8,11 @@ import ai.chat2db.spi.jdbc.DefaultDBManage;
|
|||||||
import ai.chat2db.spi.sql.Chat2DBContext;
|
import ai.chat2db.spi.sql.Chat2DBContext;
|
||||||
import ai.chat2db.spi.sql.ConnectInfo;
|
import ai.chat2db.spi.sql.ConnectInfo;
|
||||||
import ai.chat2db.spi.sql.SQLExecutor;
|
import ai.chat2db.spi.sql.SQLExecutor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.ObjectUtils;
|
import org.apache.commons.lang3.ObjectUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
public class DMDBManage extends DefaultDBManage implements DBManage {
|
public class DMDBManage extends DefaultDBManage implements DBManage {
|
||||||
private String format(String tableName) {
|
private String format(String tableName) {
|
||||||
return "\"" + tableName + "\"";
|
return "\"" + tableName + "\"";
|
||||||
@ -149,7 +151,7 @@ public class DMDBManage extends DefaultDBManage implements DBManage {
|
|||||||
try {
|
try {
|
||||||
SQLExecutor.getInstance().execute(connection, "SET SCHEMA \"" + schemaName + "\"");
|
SQLExecutor.getInstance().execute(connection, "SET SCHEMA \"" + schemaName + "\"");
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
log.error("connectDatabase error", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,8 +15,10 @@ import ai.chat2db.spi.model.*;
|
|||||||
import ai.chat2db.spi.sql.SQLExecutor;
|
import ai.chat2db.spi.sql.SQLExecutor;
|
||||||
import ai.chat2db.spi.util.SortUtils;
|
import ai.chat2db.spi.util.SortUtils;
|
||||||
import jakarta.validation.constraints.NotEmpty;
|
import jakarta.validation.constraints.NotEmpty;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
public class H2Meta extends DefaultMetaService implements MetaData {
|
public class H2Meta extends DefaultMetaService implements MetaData {
|
||||||
|
|
||||||
|
|
||||||
@ -89,7 +91,7 @@ public class H2Meta extends DefaultMetaService implements MetaData {
|
|||||||
return createTableDDL.toString();
|
return createTableDDL.toString();
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
log.error("Failed to get table DDL", e);
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
@ -7,8 +7,10 @@ import ai.chat2db.spi.jdbc.DefaultDBManage;
|
|||||||
import ai.chat2db.spi.sql.Chat2DBContext;
|
import ai.chat2db.spi.sql.Chat2DBContext;
|
||||||
import ai.chat2db.spi.sql.ConnectInfo;
|
import ai.chat2db.spi.sql.ConnectInfo;
|
||||||
import ai.chat2db.spi.sql.SQLExecutor;
|
import ai.chat2db.spi.sql.SQLExecutor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
public class KingBaseDBManage extends DefaultDBManage implements DBManage {
|
public class KingBaseDBManage extends DefaultDBManage implements DBManage {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -19,7 +21,7 @@ public class KingBaseDBManage extends DefaultDBManage implements DBManage {
|
|||||||
SQLExecutor.getInstance().execute(connection, "SET search_path TO \"" + connectInfo.getSchemaName() + "\"");
|
SQLExecutor.getInstance().execute(connection, "SET search_path TO \"" + connectInfo.getSchemaName() + "\"");
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
log.error("connectDatabase error", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ import ai.chat2db.spi.jdbc.DefaultDBManage;
|
|||||||
import ai.chat2db.spi.sql.Chat2DBContext;
|
import ai.chat2db.spi.sql.Chat2DBContext;
|
||||||
import ai.chat2db.spi.sql.ConnectInfo;
|
import ai.chat2db.spi.sql.ConnectInfo;
|
||||||
import ai.chat2db.spi.sql.SQLExecutor;
|
import ai.chat2db.spi.sql.SQLExecutor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.ObjectUtils;
|
import org.apache.commons.lang3.ObjectUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
@ -14,6 +15,7 @@ import java.sql.ResultSetMetaData;
|
|||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
public class OracleDBManage extends DefaultDBManage implements DBManage {
|
public class OracleDBManage extends DefaultDBManage implements DBManage {
|
||||||
private static String TABLE_DDL_SQL = "SELECT DBMS_METADATA.GET_DDL('TABLE', table_name) as ddl FROM all_tables WHERE owner = '%s' AND table_name = '%s'";
|
private static String TABLE_DDL_SQL = "SELECT DBMS_METADATA.GET_DDL('TABLE', table_name) as ddl FROM all_tables WHERE owner = '%s' AND table_name = '%s'";
|
||||||
private static String TABLE_COMMENT_SQL = "SELECT 'COMMENT ON TABLE ' || table_name || ' IS ''' || comments || ''';' AS table_comment_ddl FROM user_tab_comments WHERE table_name = '%s'";
|
private static String TABLE_COMMENT_SQL = "SELECT 'COMMENT ON TABLE ' || table_name || ' IS ''' || comments || ''';' AS table_comment_ddl FROM user_tab_comments WHERE table_name = '%s'";
|
||||||
@ -201,7 +203,7 @@ public class OracleDBManage extends DefaultDBManage implements DBManage {
|
|||||||
try {
|
try {
|
||||||
SQLExecutor.getInstance().execute(connection, "ALTER SESSION SET CURRENT_SCHEMA = \"" + schemaName + "\"");
|
SQLExecutor.getInstance().execute(connection, "ALTER SESSION SET CURRENT_SCHEMA = \"" + schemaName + "\"");
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
log.error("connectDatabase error", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,8 +19,10 @@ import ai.chat2db.spi.sql.SQLExecutor;
|
|||||||
import ai.chat2db.spi.util.SortUtils;
|
import ai.chat2db.spi.util.SortUtils;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import jakarta.validation.constraints.NotEmpty;
|
import jakarta.validation.constraints.NotEmpty;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
public class OracleMetaData extends DefaultMetaService implements MetaData {
|
public class OracleMetaData extends DefaultMetaService implements MetaData {
|
||||||
|
|
||||||
private static final String TABLE_DDL_SQL = "select dbms_metadata.get_ddl('TABLE','%s','%s') as sql from dual";
|
private static final String TABLE_DDL_SQL = "select dbms_metadata.get_ddl('TABLE','%s','%s') as sql from dual";
|
||||||
@ -113,7 +115,7 @@ public class OracleMetaData extends DefaultMetaService implements MetaData {
|
|||||||
tableColumn.setDefaultValue(sb.toString());
|
tableColumn.setDefaultValue(sb.toString());
|
||||||
}
|
}
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
e.printStackTrace();
|
log.error("getDefaultValue error",e);
|
||||||
}
|
}
|
||||||
tableColumn.setName(resultSet.getString("COLUMN_NAME"));
|
tableColumn.setName(resultSet.getString("COLUMN_NAME"));
|
||||||
tableColumn.setColumnType(resultSet.getString("DATA_TYPE"));
|
tableColumn.setColumnType(resultSet.getString("DATA_TYPE"));
|
||||||
|
@ -476,7 +476,7 @@ public class TableServiceImpl implements TableService {
|
|||||||
getVersionMapper().insert(versionDO);
|
getVersionMapper().insert(versionDO);
|
||||||
return 0L;
|
return 0L;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
log.error("getLock error", e);
|
||||||
return -1L;
|
return -1L;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -230,7 +230,7 @@ public class DesUtil {
|
|||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
result = 5;
|
result = 5;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -263,7 +263,7 @@ public class DesUtil {
|
|||||||
}catch (FileNotFoundException e) {
|
}catch (FileNotFoundException e) {
|
||||||
result = 5;
|
result = 5;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -190,7 +190,7 @@ public class SqlUtilsTest {
|
|||||||
DbType.h2, SQLParserFeature.PrintSQLWhileParsingFailed);
|
DbType.h2, SQLParserFeature.PrintSQLWhileParsingFailed);
|
||||||
log.info("Parse sql:{}", sqlStatement);
|
log.info("Parse sql:{}", sqlStatement);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
log.error("error", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -539,7 +539,7 @@ public class ChatController {
|
|||||||
sseEmitter.send(SseEmitter.event().id("765431").name("An exception occurs!").data(throwable.getMessage())
|
sseEmitter.send(SseEmitter.event().id("765431").name("An exception occurs!").data(throwable.getMessage())
|
||||||
.reconnectTime(3000));
|
.reconnectTime(3000));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
log.error("An exception occurs!{}", e.getMessage(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -209,7 +209,6 @@ public class WsServer {
|
|||||||
@OnError
|
@OnError
|
||||||
public void onError(Session session, Throwable error) {
|
public void onError(Session session, Throwable error) {
|
||||||
log.error("An error occurred:{},Session ID: {}", error.getMessage(), session.getId(), error);
|
log.error("An error occurred:{},Session ID: {}", error.getMessage(), session.getId(), error);
|
||||||
error.printStackTrace();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -244,7 +243,6 @@ public class WsServer {
|
|||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.error("Error sending message:{}", e.getMessage());
|
log.error("Error sending message:{}", e.getMessage());
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package ai.chat2db.spi.model;
|
package ai.chat2db.spi.model;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.annotation.JSONField;
|
||||||
import com.fasterxml.jackson.annotation.JsonAlias;
|
import com.fasterxml.jackson.annotation.JsonAlias;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@ -169,7 +170,8 @@ public class TableColumn implements Serializable {
|
|||||||
* ISO rules are used to determine the nullability for a column.
|
* ISO rules are used to determine the nullability for a column.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@JsonAlias({"NULLABLE","nullable"})
|
@JsonAlias({"nullable","NULLABLE"})
|
||||||
|
@JSONField(name = "nullable")
|
||||||
private Integer nullable;
|
private Integer nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -708,7 +708,7 @@ public class SQLExecutor implements CommandExecutor {
|
|||||||
executeResult = SQLExecutor.getInstance().execute(sql, Chat2DBContext.getConnection(), true, offset, count,
|
executeResult = SQLExecutor.getInstance().execute(sql, Chat2DBContext.getConnection(), true, offset, count,
|
||||||
valueHandler);
|
valueHandler);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
log.warn("Execute sql: {} exception", sql, e);
|
log.error("Execute sql: {} exception", sql, e);
|
||||||
executeResult = ExecuteResult.builder()
|
executeResult = ExecuteResult.builder()
|
||||||
.sql(sql)
|
.sql(sql)
|
||||||
.success(Boolean.FALSE)
|
.success(Boolean.FALSE)
|
||||||
|
@ -12,6 +12,7 @@ import com.alibaba.druid.sql.ast.statement.SQLJoinTableSource;
|
|||||||
import com.alibaba.druid.sql.ast.statement.SQLSelectStatement;
|
import com.alibaba.druid.sql.ast.statement.SQLSelectStatement;
|
||||||
import com.alibaba.druid.sql.ast.statement.SQLTableSource;
|
import com.alibaba.druid.sql.ast.statement.SQLTableSource;
|
||||||
import com.alibaba.druid.sql.parser.SQLParserUtils;
|
import com.alibaba.druid.sql.parser.SQLParserUtils;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.sf.jsqlparser.expression.Function;
|
import net.sf.jsqlparser.expression.Function;
|
||||||
import net.sf.jsqlparser.parser.CCJSqlParserUtil;
|
import net.sf.jsqlparser.parser.CCJSqlParserUtil;
|
||||||
import net.sf.jsqlparser.statement.Statement;
|
import net.sf.jsqlparser.statement.Statement;
|
||||||
@ -30,6 +31,7 @@ import java.util.stream.Collectors;
|
|||||||
* @author jipengfei
|
* @author jipengfei
|
||||||
* @version : SqlUtils.java
|
* @version : SqlUtils.java
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
public class SqlUtils {
|
public class SqlUtils {
|
||||||
|
|
||||||
public static final String DEFAULT_TABLE_NAME = "table1";
|
public static final String DEFAULT_TABLE_NAME = "table1";
|
||||||
@ -80,7 +82,7 @@ public class SqlUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
log.error("buildCanEditResult error", e);
|
||||||
executeResult.setCanEdit(false);
|
executeResult.setCanEdit(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user