Skip to content

Commit d73341a

Browse files
committed
完善各种数据库的默认配置
1 parent 6012bb4 commit d73341a

File tree

1 file changed

+186
-9
lines changed

1 file changed

+186
-9
lines changed

src/main/java/apijson/framework/APIJSONSQLConfig.java

Lines changed: 186 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -111,19 +111,74 @@ public String gainDBVersion() {
111111

112112
public String gainDBUri() {
113113
if (isMySQL()) {
114-
return "jdbc:mysql://localhost:3306"; //TODO 改成你自己的,TiDB 可以当成 MySQL 使用,默认端口为 4000
114+
return "jdbc:mysql://localhost:3306";
115115
}
116-
if (isPostgreSQL()) {
117-
return "jdbc:postgresql://localhost:5432/postgres"; //TODO 改成你自己的
116+
if (isTiDB()) {
117+
return "jdbc:mysql://localhost:4000";
118+
}
119+
if (isPostgreSQL()) { // PG JDBC 必须在 URI 传 catalog
120+
return "jdbc:postgresql://localhost:5432/postgres?stringtype=unspecified"; //TODO 改成你自己的
118121
}
122+
//if (isCockroachDB()) { // PG JDBC 必须在 URI 传 catalog
123+
// return "jdbc:postgresql://localhost:26257/movr?sslmode=require"; //TODO 改成你自己的 brew install cockroachdb/tap/cockroach && cockroach demo
124+
// // return "jdbc:postgresql://localhost:26258/postgres?sslmode=disable"; //TODO 改成你自己的 brew install cockroachdb/tap/cockroach # && start 3 nodes and init cluster
125+
//}
119126
if (isSQLServer()) {
120127
return "jdbc:jtds:sqlserver://localhost:1433/pubs;instance=SQLEXPRESS"; //TODO 改成你自己的
121128
}
122129
if (isOracle()) {
123130
return "jdbc:oracle:thin:@localhost:1521:orcl"; //TODO 改成你自己的
124131
}
132+
if (isDb2()) {
133+
return "jdbc:db2://localhost:50000/BLUDB"; //TODO 改成你自己的
134+
}
135+
if (isSQLite()) {
136+
return "jdbc:sqlite:sample.db"; //TODO 改成你自己的
137+
}
138+
if (isDameng()) {
139+
return "jdbc:dm://localhost:5236"; //TODO 改成你自己的
140+
}
141+
if (isTDengine()) {
142+
// return "jdbc:TAOS://localhost:6030"; //TODO 改成你自己的
143+
return "jdbc:TAOS-RS://localhost:6041"; //TODO 改成你自己的
144+
}
145+
if (isTimescaleDB()) { // PG JDBC 必须在 URI 传 catalog
146+
return "jdbc:postgresql://localhost:5432/postgres?stringtype=unspecified"; //TODO 改成你自己的
147+
}
148+
if (isQuestDB()) { // PG JDBC 必须在 URI 传 catalog
149+
return "jdbc:postgresql://localhost:8812/qdb"; //TODO 改成你自己的
150+
}
151+
if (isInfluxDB()) {
152+
return "http://203.189.6.3:8086"; //TODO 改成你自己的
153+
}
154+
if (isMilvus()) {
155+
return "http://localhost:19530"; //TODO 改成你自己的
156+
}
157+
if (isManticore()) {
158+
return "jdbc:mysql://localhost:9306?characterEncoding=utf8&maxAllowedPacket=512000";
159+
}
160+
if (isIoTDB()) {
161+
return "jdbc:iotdb://localhost:6667"; // ?charset=GB18030 加参数会报错 URI 格式错误
162+
}
163+
if (isMongoDB()) {
164+
return "jdbc:mongodb://atlas-sql-6593c65c296c5865121e6ebe-xxskv.a.query.mongodb.net/myVirtualDatabase?ssl=true&authSource=admin";
165+
}
166+
if (isCassandra()) {
167+
return "http://localhost:7001";
168+
}
169+
if (isDuckDB()) {
170+
return "jdbc:duckdb:/Users/root/my_database.duckdb";
171+
}
172+
if (isSurrealDB()) {
173+
// return "memory";
174+
// return "surrealkv://localhost:8000";
175+
return "ws://localhost:8000";
176+
}
177+
if (isOpenGauss()) {
178+
return "jdbc:opengauss://127.0.0.1:5432/postgres?currentSchema=" + DEFAULT_SCHEMA;
179+
}
125180
if (isDoris()) {
126-
return "jdbc:mysql://localhost:9030"; //TODO 改成你自己的,TiDB 可以当成 MySQL 使用,默认端口为 4000
181+
return "jdbc:mysql://localhost:9030";
127182
}
128183
return null;
129184
}
@@ -141,28 +196,150 @@ public String gainDBAccount() {
141196
if (isOracle()) {
142197
return "scott"; //TODO 改成你自己的
143198
}
199+
if (isMySQL()) {
200+
return "root"; // ""apijson"; //TODO 改成你自己的
201+
}
202+
if (isPostgreSQL()) {
203+
return "postgres"; //TODO 改成你自己的
204+
}
205+
//if (isCockroachDB()) { // PG JDBC 必须在 URI 传 catalog
206+
// return "demo"; //TODO 改成你自己的
207+
// //return "postgres"; //TODO 改成你自己的
208+
//}
209+
if (isSQLServer()) {
210+
return "sa"; //TODO 改成你自己的
211+
}
212+
if (isOracle()) {
213+
return "scott"; //TODO 改成你自己的
214+
}
215+
if (isDb2()) {
216+
return "db2admin"; //TODO 改成你自己的
217+
}
218+
// if (isSQLite()) {
219+
// return "root"; //TODO 改成你自己的
220+
// }
221+
if (isDameng()) {
222+
return "SYSDBA";
223+
}
224+
if (isTDengine()) {
225+
return "root"; //TODO 改成你自己的
226+
}
227+
//if (isTimescaleDB()) {
228+
// return "postgres"; //TODO 改成你自己的
229+
//}
230+
if (isQuestDB()) {
231+
return "admin"; //TODO 改成你自己的
232+
}
233+
if (isInfluxDB()) {
234+
return "iotos";
235+
}
236+
if (isMilvus()) {
237+
return "root";
238+
}
239+
if (isManticore()) {
240+
return null; // "root";
241+
}
242+
if (isIoTDB()) {
243+
return "root";
244+
}
245+
if (isMongoDB()) {
246+
return "root"; //TODO 改成你自己的
247+
}
248+
if (isCassandra()) {
249+
return "root"; //TODO 改成你自己的
250+
}
251+
if (isDuckDB()) {
252+
return "root"; //TODO 改成你自己的
253+
}
254+
if (isSurrealDB()) {
255+
return "root"; //TODO 改成你自己的
256+
}
257+
if (isOpenGauss()) {
258+
return "postgres"; //TODO 改成你自己的
259+
// 不允许用初始账号,需要 CREATE USER 创建新账号并 GRANT 授权 return "opengauss"; //TODO 改成你自己的
260+
}
144261
if (isDoris()) {
145262
return "root"; //TODO 改成你自己的
146263
}
264+
147265
return null;
148266
}
149267

150268
public String gainDBPassword() {
151269
if (isMySQL()) {
152-
return "apijson"; //TODO 改成你自己的,TiDB 可以当成 MySQL 使用, 默认密码为空字符串 ""
270+
return "your@Password123";
271+
}
272+
if (isTiDB()) {
273+
return "";
153274
}
154275
if (isPostgreSQL()) {
155-
return null; //TODO 改成你自己的
276+
return null;
277+
}
278+
if (isSQLServer()) {
279+
return "your@Password123";
280+
}
281+
if (isOracle()) {
282+
return "tiger";
156283
}
284+
//if (isCockroachDB()) { // PG JDBC 必须在 URI 传 catalog
285+
// return "demo39865";
286+
// // return null
287+
//}
157288
if (isSQLServer()) {
158-
return "apijson@123"; //TODO 改成你自己的
289+
return "your@Password123";
159290
}
160291
if (isOracle()) {
161-
return "tiger"; //TODO 改成你自己的
292+
return "tiger";
293+
}
294+
if (isDb2()) {
295+
return "123";
296+
}
297+
if (isSQLite()) {
298+
return "your@Password123";
299+
}
300+
if (isDameng()) {
301+
return "SYSDBA";
302+
}
303+
if (isTDengine()) {
304+
return "taosdata";
305+
}
306+
if (isTimescaleDB()) {
307+
return "password";
308+
}
309+
if (isQuestDB()) {
310+
return "quest";
311+
}
312+
if (isInfluxDB()) {
313+
return "your@Password123";
314+
}
315+
if (isMilvus()) {
316+
return "your@Password123";
317+
}
318+
//if (isManticore()) {
319+
// return null;
320+
//}
321+
//if (isIoTDB()) {
322+
// return "root";
323+
//}
324+
if (isMongoDB()) {
325+
return "your@Password123";
326+
}
327+
if (isCassandra()) {
328+
return "your@Password123";
329+
}
330+
if (isDuckDB()) {
331+
return "";
332+
}
333+
if (isSurrealDB()) {
334+
return "root";
335+
}
336+
if (isOpenGauss()) {
337+
return "your@Password123";
162338
}
163339
if (isDoris()) {
164-
return ""; //TODO 改成你自己的
340+
return "";
165341
}
342+
166343
return null;
167344
}
168345

0 commit comments

Comments
 (0)