Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
I
ihooyah-flume
Overview
Overview
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
黄杰
ihooyah-flume
Commits
4ae90071
Commit
4ae90071
authored
Jun 25, 2021
by
陈科朋
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
flume同步增加操作字段
parent
6ae89134
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
17 deletions
+11
-17
DAOClass.java
src/main/java/com/ihooyah/flume/sink/DAOClass.java
+11
-17
No files found.
src/main/java/com/ihooyah/flume/sink/DAOClass.java
View file @
4ae90071
package
com
.
ihooyah
.
flume
.
sink
;
import
java.io.IOException
;
import
java.io.UnsupportedEncodingException
;
import
java.sql.Connection
;
import
java.sql.DriverManager
;
import
java.sql.PreparedStatement
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
org.apache.flume.Event
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
javax.swing.plaf.synth.SynthScrollBarUI
;
import
java.io.IOException
;
import
java.sql.*
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.*
;
/**
* 描述
...
...
@@ -45,7 +37,8 @@ public class DAOClass {
String
tableName
=
(
String
)
params
.
get
(
"tableName"
);
String
iscustom
=
(
String
)
params
.
get
(
"iscustom"
);
JSONObject
initObject
=
JSONObject
.
parseObject
(
body
);
JSONObject
dataObject
=
initObject
.
getJSONObject
(
"data"
);
String
dataObject
=
initObject
.
getString
(
"data"
);
String
operation
=
initObject
.
getString
(
"operation"
);
if
(!
"false"
.
equals
(
iscustom
))
{
if
(
"true"
.
equals
(
iscustom
))
{
;
...
...
@@ -70,16 +63,17 @@ public class DAOClass {
DELETE_QUERY
=
"DELETE FROM flume_json where create_time<'"
+
mon
+
"';"
;
st
.
execute
(
DELETE_QUERY
);
String
values
=
""
;
columns
=
"type,data,file_name,create_time,status"
;
values
=
"'"
+
initObject
.
get
(
"type"
).
toString
()+
"','"
+
dataObject
+
"','"
+
fileName
+
"','"
+
sdf
.
format
(
new
Date
())+
"','0'"
;
columns
=
"type,
operation,
data,file_name,create_time,status"
;
values
=
"'"
+
initObject
.
get
String
(
"type"
)+
"','"
+
operation
+
"','"
+
dataObject
+
"','"
+
fileName
+
"','"
+
sdf
.
format
(
new
Date
())+
"','0'"
;
INSERT_QUERY
=
"INSERT INTO flume_json ("
+
columns
+
") values ("
+
values
+
")"
;
System
.
out
.
println
(
"数据新增语句:"
+
INSERT_QUERY
);
PreparedStatement
insertStmnt
=
this
.
connection
.
prepareStatement
(
INSERT_QUERY
);
insertStmnt
.
execute
();
}
}
catch
(
SQLException
var20
)
{
var20
.
printStackTrace
();
}
finally
{
}
}
...
...
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