Fix oracle datatype error

This commit is contained in:
SwallowGG
2023-11-15 18:32:04 +08:00
parent fc6f7aa547
commit 5b126a38f0
5 changed files with 64 additions and 30 deletions

View File

@ -0,0 +1,30 @@
//package ai.chat2db.server.start.config;
//
//import jakarta.annotation.PostConstruct;
//import org.springframework.boot.context.event.ApplicationReadyEvent;
//import org.springframework.context.ApplicationListener;
//import org.springframework.stereotype.Component;
//
//import java.util.Scanner;
//
//@Component
//public class StdinReader implements ApplicationListener<ApplicationReadyEvent> {
//
//
// @Override
// public void onApplicationEvent(ApplicationReadyEvent event) {
// // 启动读取 stdin 的线程
// new Thread(() -> readStdin()).start();
// }
//
// private void readStdin() {
// Scanner scanner = new Scanner(System.in);
// while (scanner.hasNextLine()) {
// String line = scanner.nextLine();
// // 处理接收到的数据
// System.out.println("接收到数据: " + line);
// // 在这里调用其他服务或逻辑
// }
// }
//
//}

View File

@ -1,7 +1,7 @@
spring:
datasource:
# 配置自带数据库的相对路径
url: jdbc:h2:~/.chat2db/db/chat2db_dev;MODE=MYSQL
url: jdbc:h2:~/.chat2db/db/chat2db_dev;MODE=MYSQL;FILE_LOCK=NO
driver-class-name: org.h2.Driver
h2:
console:

View File

@ -73,19 +73,19 @@ public class RdbDdlController extends EmbeddingController {
PageResult<Table> tableDTOPageResult = tableService.pageQuery(queryParam, tableSelector);
List<TableVO> tableVOS = rdbWebConverter.tableDto2vo(tableDTOPageResult.getData());
ConnectInfo connectInfo = Chat2DBContext.getConnectInfo();
singleThreadExecutor.submit(() -> {
try {
Chat2DBContext.putContext(connectInfo);
syncTableVector(request);
// syncTableEs(request);
} catch (Exception e) {
log.error("sync table vector error", e);
} finally {
Chat2DBContext.removeContext();
}
log.info("sync table vector finish");
});
// ConnectInfo connectInfo = Chat2DBContext.getConnectInfo();
// singleThreadExecutor.submit(() -> {
// try {
// Chat2DBContext.putContext(connectInfo);
// syncTableVector(request);
//// syncTableEs(request);
// } catch (Exception e) {
// log.error("sync table vector error", e);
// } finally {
// Chat2DBContext.removeContext();
// }
// log.info("sync table vector finish");
// });
return WebPageResult.of(tableVOS, tableDTOPageResult.getTotal(), request.getPageNo(),
request.getPageSize());
}

View File

@ -64,19 +64,19 @@ public class TableController extends EmbeddingController {
tableSelector.setIndexList(false);
PageResult<Table> tableDTOPageResult = tableService.pageQuery(queryParam, tableSelector);
List<TableVO> tableVOS = rdbWebConverter.tableDto2vo(tableDTOPageResult.getData());
ConnectInfo connectInfo = Chat2DBContext.getConnectInfo();
singleThreadExecutor.submit(() -> {
try {
Chat2DBContext.putContext(connectInfo);
syncTableVector(request);
// syncTableEs(request);
} catch (Exception e) {
log.error("sync table vector error", e);
} finally {
Chat2DBContext.removeContext();
}
log.info("sync table vector finish");
});
// ConnectInfo connectInfo = Chat2DBContext.getConnectInfo();
// singleThreadExecutor.submit(() -> {
// try {
// Chat2DBContext.putContext(connectInfo);
// syncTableVector(request);
//// syncTableEs(request);
// } catch (Exception e) {
// log.error("sync table vector error", e);
// } finally {
// Chat2DBContext.removeContext();
// }
// log.info("sync table vector finish");
// });
return WebPageResult.of(tableVOS, tableDTOPageResult.getTotal(), request.getPageNo(),
request.getPageSize());
}

View File

@ -81,11 +81,15 @@ public class Chat2DBContext {
if (connection == null) {
synchronized (connectInfo) {
connection = connectInfo.getConnection();
if (connection != null) {
try {
if (connection != null && !connection.isClosed()) {
return connection;
} else {
connection = getDBManage().getConnection(connectInfo);
}
} catch (SQLException e) {
connection = getDBManage().getConnection(connectInfo);
}
}
}
return connection;