Skip to content

Commit 5b126a3

Browse files
committed
Fix oracle datatype error
1 parent fc6f7aa commit 5b126a3

5 files changed

Lines changed: 64 additions & 30 deletions

File tree

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
//package ai.chat2db.server.start.config;
2+
//
3+
//import jakarta.annotation.PostConstruct;
4+
//import org.springframework.boot.context.event.ApplicationReadyEvent;
5+
//import org.springframework.context.ApplicationListener;
6+
//import org.springframework.stereotype.Component;
7+
//
8+
//import java.util.Scanner;
9+
//
10+
//@Component
11+
//public class StdinReader implements ApplicationListener<ApplicationReadyEvent> {
12+
//
13+
//
14+
// @Override
15+
// public void onApplicationEvent(ApplicationReadyEvent event) {
16+
// // 启动读取 stdin 的线程
17+
// new Thread(() -> readStdin()).start();
18+
// }
19+
//
20+
// private void readStdin() {
21+
// Scanner scanner = new Scanner(System.in);
22+
// while (scanner.hasNextLine()) {
23+
// String line = scanner.nextLine();
24+
// // 处理接收到的数据
25+
// System.out.println("接收到数据: " + line);
26+
// // 在这里调用其他服务或逻辑
27+
// }
28+
// }
29+
//
30+
//}

chat2db-server/chat2db-server-start/src/main/resources/application-dev.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
spring:
22
datasource:
33
# 配置自带数据库的相对路径
4-
url: jdbc:h2:~/.chat2db/db/chat2db_dev;MODE=MYSQL
4+
url: jdbc:h2:~/.chat2db/db/chat2db_dev;MODE=MYSQL;FILE_LOCK=NO
55
driver-class-name: org.h2.Driver
66
h2:
77
console:

chat2db-server/chat2db-server-web/chat2db-server-web-api/src/main/java/ai/chat2db/server/web/api/controller/rdb/RdbDdlController.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -73,19 +73,19 @@ public WebPageResult<TableVO> list(@Valid TableBriefQueryRequest request) {
7373
PageResult<Table> tableDTOPageResult = tableService.pageQuery(queryParam, tableSelector);
7474
List<TableVO> tableVOS = rdbWebConverter.tableDto2vo(tableDTOPageResult.getData());
7575

76-
ConnectInfo connectInfo = Chat2DBContext.getConnectInfo();
77-
singleThreadExecutor.submit(() -> {
78-
try {
79-
Chat2DBContext.putContext(connectInfo);
80-
syncTableVector(request);
81-
// syncTableEs(request);
82-
} catch (Exception e) {
83-
log.error("sync table vector error", e);
84-
} finally {
85-
Chat2DBContext.removeContext();
86-
}
87-
log.info("sync table vector finish");
88-
});
76+
// ConnectInfo connectInfo = Chat2DBContext.getConnectInfo();
77+
// singleThreadExecutor.submit(() -> {
78+
// try {
79+
// Chat2DBContext.putContext(connectInfo);
80+
// syncTableVector(request);
81+
//// syncTableEs(request);
82+
// } catch (Exception e) {
83+
// log.error("sync table vector error", e);
84+
// } finally {
85+
// Chat2DBContext.removeContext();
86+
// }
87+
// log.info("sync table vector finish");
88+
// });
8989
return WebPageResult.of(tableVOS, tableDTOPageResult.getTotal(), request.getPageNo(),
9090
request.getPageSize());
9191
}

chat2db-server/chat2db-server-web/chat2db-server-web-api/src/main/java/ai/chat2db/server/web/api/controller/rdb/TableController.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -64,19 +64,19 @@ public WebPageResult<TableVO> list(@Valid TableBriefQueryRequest request) {
6464
tableSelector.setIndexList(false);
6565
PageResult<Table> tableDTOPageResult = tableService.pageQuery(queryParam, tableSelector);
6666
List<TableVO> tableVOS = rdbWebConverter.tableDto2vo(tableDTOPageResult.getData());
67-
ConnectInfo connectInfo = Chat2DBContext.getConnectInfo();
68-
singleThreadExecutor.submit(() -> {
69-
try {
70-
Chat2DBContext.putContext(connectInfo);
71-
syncTableVector(request);
72-
// syncTableEs(request);
73-
} catch (Exception e) {
74-
log.error("sync table vector error", e);
75-
} finally {
76-
Chat2DBContext.removeContext();
77-
}
78-
log.info("sync table vector finish");
79-
});
67+
// ConnectInfo connectInfo = Chat2DBContext.getConnectInfo();
68+
// singleThreadExecutor.submit(() -> {
69+
// try {
70+
// Chat2DBContext.putContext(connectInfo);
71+
// syncTableVector(request);
72+
//// syncTableEs(request);
73+
// } catch (Exception e) {
74+
// log.error("sync table vector error", e);
75+
// } finally {
76+
// Chat2DBContext.removeContext();
77+
// }
78+
// log.info("sync table vector finish");
79+
// });
8080
return WebPageResult.of(tableVOS, tableDTOPageResult.getTotal(), request.getPageNo(),
8181
request.getPageSize());
8282
}

chat2db-server/chat2db-spi/src/main/java/ai/chat2db/spi/sql/Chat2DBContext.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,13 @@ public static Connection getConnection() {
8181
if (connection == null) {
8282
synchronized (connectInfo) {
8383
connection = connectInfo.getConnection();
84-
if (connection != null) {
85-
return connection;
86-
} else {
84+
try {
85+
if (connection != null && !connection.isClosed()) {
86+
return connection;
87+
} else {
88+
connection = getDBManage().getConnection(connectInfo);
89+
}
90+
} catch (SQLException e) {
8791
connection = getDBManage().getConnection(connectInfo);
8892
}
8993
}

0 commit comments

Comments
 (0)