Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
data-computing-proxy-test
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
李振振
data-computing-proxy-test
Commits
b42edb8a
You need to sign in or sign up before continuing.
Commit
b42edb8a
authored
Aug 23, 2023
by
李振振
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
polardbx的curd测试
parent
cb3b0f8e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
88 additions
and
52 deletions
+88
-52
src/main/java/com/beagle/informix/service/impl/InformixJdbcProxyServiceImpl.java
...e/informix/service/impl/InformixJdbcProxyServiceImpl.java
+52
-31
src/main/java/com/beagle/informix/service/impl/InformixMybatisServiceImpl.java
...gle/informix/service/impl/InformixMybatisServiceImpl.java
+21
-4
src/main/resources/application.yaml
src/main/resources/application.yaml
+15
-17
No files found.
src/main/java/com/beagle/informix/service/impl/InformixJdbcProxyServiceImpl.java
View file @
b42edb8a
...
...
@@ -11,6 +11,10 @@ import java.io.*;
import
java.nio.charset.StandardCharsets
;
import
java.sql.*
;
import
java.util.Properties
;
import
java.util.concurrent.CompletableFuture
;
import
java.util.concurrent.CountDownLatch
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
/**
* @author lzz
...
...
@@ -40,16 +44,44 @@ public class InformixJdbcProxyServiceImpl implements InformixService {
*/
@Override
public
void
doConnectJob
()
throws
Exception
{
// todo 使用jdbc连接proxy,对应的query(clob、blob字段)存在jdbc 类型转换mysql异常的问题
// // todo 使用jdbc连接proxy,对应的query(clob、blob字段)存在jdbc 类型转换mysql异常的问题
// // Unknown exception: Can not find JDBC type `2005` in column type
// Driver driver = getDriver();
// Connection conn = getConnection(driver);
// insert(conn);
//// update(conn);
//// query(conn);
//// delete(conn);
// closeConnection(conn);
// deregisterDriver(driver);
// Unknown exception: Can not find JDBC type `2005` in column type
Driver
driver
=
getDriver
();
Connection
conn
=
getConnection
(
driver
);
insert
(
conn
);
// update(conn);
// query(conn);
// delete(conn);
closeConnection
(
conn
);
deregisterDriver
(
driver
);
CompletableFuture
completableFuture
=
new
CompletableFuture
<>();
ExecutorService
executorService
=
Executors
.
newFixedThreadPool
(
500
);
for
(
int
i
=
0
;
i
<
500
;
i
++)
{
try
{
Driver
driver
=
getDriver
();
Connection
conn
=
getConnection
(
driver
);
completableFuture
.
runAsync
(()->{
try
{
query
(
conn
);
}
catch
(
Exception
ee
)
{
ee
.
printStackTrace
();
}
},
executorService
).
whenComplete
((
v
,
e
)
->
{
if
(
e
!=
null
)
{
e
.
printStackTrace
();
}
try
{
closeConnection
(
conn
);
deregisterDriver
(
driver
);
}
catch
(
Exception
ex
)
{
ex
.
printStackTrace
();
}
});
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
e
);
}
}
}
private
Driver
getDriver
()
throws
Exception
{
// 定义informix的驱动信息
...
...
@@ -94,28 +126,13 @@ public class InformixJdbcProxyServiceImpl implements InformixService {
stat
.
executeUpdate
();
}
private
void
query
(
Connection
conn
)
throws
Exception
{
String
querySQL
=
"
select * from cti_vccinfo_new where vccid = '123456'
"
;
String
querySQL
=
"
SELECT id FROM sc_test
"
;
PreparedStatement
stat
=
conn
.
prepareStatement
(
querySQL
);
ResultSet
resultSet
=
stat
.
executeQuery
();
if
(
resultSet
!=
null
)
{
while
(
resultSet
.
next
())
{
log
.
info
(
"vccid =>"
+
resultSet
.
getString
(
"vccid"
));
Clob
clob
=
resultSet
.
getClob
(
"tclob"
);
BufferedReader
reader
=
new
BufferedReader
(
clob
.
getCharacterStream
());
String
clobStr
=
""
;
String
finalClobStr
=
""
;
while
((
clobStr
=
reader
.
readLine
())!=
null
)
{
finalClobStr
+=
clobStr
;
}
log
.
info
(
"tclob =>"
+
finalClobStr
);
Blob
blob
=
resultSet
.
getBlob
(
"tblob"
);
BufferedInputStream
bins
=
new
BufferedInputStream
(
blob
.
getBinaryStream
());
byte
[]
bytes
=
bins
.
readAllBytes
();
String
blobStr
=
new
String
(
bytes
,
StandardCharsets
.
UTF_8
);
log
.
info
(
"tblob =>"
+
blobStr
);
}
}
}
private
void
delete
(
Connection
conn
)
throws
Exception
{
String
deleteSql
=
"delete from cti_vccinfo_new where vccid = '123456' "
;
conn
.
createStatement
().
executeUpdate
(
deleteSql
);
...
...
@@ -125,9 +142,10 @@ public class InformixJdbcProxyServiceImpl implements InformixService {
Properties
properties
=
new
Properties
();
// 组装连接数据库信息
// jdbc:informix-sqli://<server>:<port1526>/<database>:informixserver=<dbservername>
StringBuilder
jdbcBuilder
=
new
StringBuilder
(
"jdbc:mysql://localhost:3307"
)
.
append
(
"/"
)
.
append
(
"testdb"
).
append
(
"?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=Asia/Shanghai&useServerPrepStmts=true"
);
StringBuilder
jdbcBuilder
=
new
StringBuilder
(
"jdbc:mysql://localhost:3307"
);
// .append("/")
// .append("SYSDBA")
// .append("?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=Asia/Shanghai&useServerPrepStmts=true");
DriverManager
.
setLoginTimeout
(
10
);
properties
.
put
(
"user"
,
"root"
);
properties
.
put
(
"password"
,
"Apurelove9014"
);
...
...
@@ -136,4 +154,7 @@ public class InformixJdbcProxyServiceImpl implements InformixService {
private
void
closeConnection
(
Connection
connection
)
throws
Exception
{
connection
.
close
();
}
}
src/main/java/com/beagle/informix/service/impl/InformixMybatisServiceImpl.java
View file @
b42edb8a
...
...
@@ -17,7 +17,12 @@ import javax.annotation.Resource;
import
javax.transaction.Transactional
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.sql.Connection
;
import
java.sql.Driver
;
import
java.util.List
;
import
java.util.concurrent.CompletableFuture
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
/**
* @author lzz
...
...
@@ -35,10 +40,22 @@ public class InformixMybatisServiceImpl extends ServiceImpl<VccinfoMapper, Vccin
@Override
@Transactional
public
void
doConnectJob
()
throws
Exception
{
insertMethod
();
// updateMethod();
// queryMethod();
// delete();
CompletableFuture
completableFuture
=
new
CompletableFuture
<>();
ExecutorService
executorService
=
Executors
.
newFixedThreadPool
(
500
);
for
(
int
i
=
0
;
i
<
500
;
i
++)
{
try
{
completableFuture
.
runAsync
(()->{
queryMethod
();
},
executorService
).
whenComplete
((
v
,
e
)
->
{
if
(
e
!=
null
)
{
e
.
printStackTrace
();
}
});
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
e
);
}
}
}
private
void
insertMethod
()
throws
Exception
{
Vccinfo
vccinfo
=
new
Vccinfo
();
...
...
src/main/resources/application.yaml
View file @
b42edb8a
spring
:
datasource
:
druid
:
# url: jdbc:informix-sqli://localhost:9088/testdb:INFORMIXSERVER=informix
#&useServerPrepStmts=true
# url: jdbc:mysql://localhost:3307/testdb?useUnicode=true&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=Asia/Shanghai
url
:
jdbc:mysql://localhost:3307/testdb?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=Asia/Shanghai
url
:
jdbc:mysql://localhost:3307
# url: jdbc:mysql://localhost:3307/SYSDBA?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=Asia/Shanghai
# url: jdbc:mysql://localhost:3307/testdb?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=Asia/Shanghai&useServerPrepStmts=true
username
:
root
# username: informix
# password: in4mix
password
:
Apurelove9014
# max-active: 20
# max-wait: 60000
# initial-size: 5
# connect-timeout: 30
# min-idle: 5
# min-evictable-idle-time-millis: 300000
# validation-query: select 1
# test-on-borrow: false
# test-on-return: false
# test-while-idle: false
# time-between-eviction-runs-millis: 60000
type
:
com.alibaba.druid.pool.DruidDataSource
druid
:
max-active
:
500
max-wait
:
60000
initial-size
:
500
connect-timeout
:
30
min-idle
:
500
min-evictable-idle-time-millis
:
300000
validation-query
:
select
1
test-on-borrow
:
false
test-on-return
:
false
test-while-idle
:
false
time-between-eviction-runs-millis
:
60000
# driver-class-name: com.informix.jdbc.IfxDriver
driver-class-name
:
com.mysql.jdbc.Driver
# com.mysql.cj.jdbc.Driver
jpa
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment