Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
C
common
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
曲欣亮
common
Commits
8190468a
Commit
8190468a
authored
Aug 17, 2021
by
Quxl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
x
parent
aad02a1d
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
19 deletions
+21
-19
DBPort.java
src/main/java/com/egolm/common/jdbc/DBPort.java
+21
-19
No files found.
src/main/java/com/egolm/common/jdbc/DBPort.java
View file @
8190468a
...
...
@@ -16,7 +16,9 @@ import java.sql.PreparedStatement;
import
java.sql.ResultSet
;
import
java.sql.ResultSetMetaData
;
import
java.sql.SQLException
;
import
java.sql.Timestamp
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.LinkedHashMap
;
import
java.util.List
;
...
...
@@ -34,10 +36,10 @@ public class DBPort {
this
.
dataSource
=
dataSource
;
}
public
void
doImport
(
File
f
ile
,
String
tableName
)
throws
IOException
,
SQLException
,
ClassNotFoundException
{
public
void
doImport
(
File
exportF
ile
,
String
tableName
)
throws
IOException
,
SQLException
,
ClassNotFoundException
{
FileInputStream
fis
=
null
;
try
{
fis
=
new
FileInputStream
(
f
ile
);
fis
=
new
FileInputStream
(
exportF
ile
);
FileChannel
channel
=
fis
.
getChannel
();
ByteBuffer
byteBuffer
=
ByteBuffer
.
allocate
((
int
)
channel
.
size
());
int
i
=
1
;
...
...
@@ -52,12 +54,12 @@ public class DBPort {
}
}
public
void
doExport
(
File
file
,
String
s
ql
,
Object
[]
args
)
throws
IOException
,
SQLException
{
if
(!
f
ile
.
getParentFile
().
exists
())
{
f
ile
.
getParentFile
().
mkdirs
();
public
void
doExport
(
File
exportFile
,
String
selectS
ql
,
Object
[]
args
)
throws
IOException
,
SQLException
{
if
(!
exportF
ile
.
getParentFile
().
exists
())
{
exportF
ile
.
getParentFile
().
mkdirs
();
}
FileOutputStream
fos
=
new
FileOutputStream
(
f
ile
);
this
.
doExport
(
fos
,
sql
,
args
);
FileOutputStream
fos
=
new
FileOutputStream
(
exportF
ile
);
this
.
doExport
(
fos
,
s
electS
ql
,
args
);
}
public
void
doExport
(
OutputStream
os
,
String
sql
,
Object
[]
args
)
throws
IOException
,
SQLException
{
...
...
@@ -71,20 +73,21 @@ public class DBPort {
}
}
public
byte
[]
doExport
(
String
sql
,
Object
[]
args
)
throws
IOException
,
SQLException
{
public
byte
[]
doExport
(
String
s
electS
ql
,
Object
[]
args
)
throws
IOException
,
SQLException
{
Connection
connection
=
dataSource
.
getConnection
();
PreparedStatement
ps
=
connection
.
prepareStatement
(
sql
);
PreparedStatement
ps
=
connection
.
prepareStatement
(
selectSql
);
if
(
args
!=
null
)
{
for
(
int
i
=
0
;
i
<
args
.
length
;
i
++)
{
Object
argObj
=
args
[
i
];
if
(
argObj
instanceof
java
.
util
.
Date
)
{
java
.
util
.
Date
argDate
=
(
java
.
util
.
Date
)
argObj
;
ps
.
setObject
(
i
+
1
,
new
java
.
sql
.
Timestamp
(
argDate
.
getTime
()));
ps
.
setObject
(
i
+
1
,
new
Timestamp
(((
Date
)
argObj
).
getTime
()));
}
else
if
(
argObj
.
getClass
().
isEnum
())
{
ps
.
setObject
(
i
+
1
,
args
[
i
].
toString
());
}
else
{
ps
.
setObject
(
i
+
1
,
args
[
i
]);
}
}
}
ResultSet
resultSet
=
ps
.
executeQuery
();
ResultSetMetaData
metaData
=
resultSet
.
getMetaData
();
int
columnCount
=
metaData
.
getColumnCount
();
...
...
@@ -104,7 +107,6 @@ public class DBPort {
}
datas
.
add
(
rowData
);
}
ByteArrayOutputStream
bos
=
null
;
GZIPOutputStream
gzip
=
null
;
ObjectOutputStream
out
=
null
;
...
...
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