forked from DTStack/chunjun
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2251bcf
commit d403b3c
Showing
8 changed files
with
125 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,6 +44,7 @@ | |
import org.apache.commons.lang3.StringUtils; | ||
import org.apache.commons.lang3.tuple.Pair; | ||
|
||
import java.lang.invoke.MethodHandles; | ||
import java.math.BigDecimal; | ||
import java.math.BigInteger; | ||
import java.sql.Connection; | ||
|
@@ -64,6 +65,9 @@ | |
|
||
import static com.dtstack.chunjun.enums.ColumnType.TIMESTAMPTZ; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* InputFormat for reading data from a database and generate Rows. | ||
* | ||
|
@@ -72,7 +76,7 @@ | |
* @author [email protected] | ||
*/ | ||
public class JdbcInputFormat extends BaseRichInputFormat { | ||
|
||
private static final Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); | ||
public static final long serialVersionUID = 1L; | ||
protected static final int resultSetConcurrency = ResultSet.CONCUR_READ_ONLY; | ||
protected static int resultSetType = ResultSet.TYPE_FORWARD_ONLY; | ||
|
@@ -454,7 +458,7 @@ private String getMaxValueFromDb() { | |
LOG.info(String.format("Query max value sql is '%s'", queryMaxValueSql)); | ||
|
||
conn = getConnection(); | ||
st = conn.createStatement(resultSetType, resultSetConcurrency); | ||
st = conn.createStatement(getResultSetType(), resultSetConcurrency); | ||
st.setQueryTimeout(jdbcConf.getQueryTimeOut()); | ||
rs = st.executeQuery(queryMaxValueSql); | ||
if (rs.next()) { | ||
|
@@ -502,7 +506,7 @@ private Pair<String, String> getSplitRangeFromDb() { | |
LOG.info(String.format("Query SplitRange sql is '%s'", querySplitRangeSql)); | ||
|
||
conn = getConnection(); | ||
st = conn.createStatement(resultSetType, resultSetConcurrency); | ||
st = conn.createStatement(getResultSetType(), resultSetConcurrency); | ||
st.setQueryTimeout(jdbcConf.getQueryTimeOut()); | ||
rs = st.executeQuery(querySplitRangeSql); | ||
if (rs.next()) { | ||
|
@@ -887,10 +891,19 @@ protected Pair<List<String>, List<String>> getTableMetaData() { | |
} | ||
/** init prepareStatement */ | ||
public void initPrepareStatement(String querySql) throws SQLException { | ||
ps = dbConn.prepareStatement(querySql, resultSetType, resultSetConcurrency); | ||
ps = dbConn.prepareStatement(querySql, getResultSetType(), resultSetConcurrency); | ||
ps.setFetchSize(jdbcConf.getFetchSize()); | ||
ps.setQueryTimeout(jdbcConf.getQueryTimeOut()); | ||
} | ||
|
||
/** | ||
* The constant indicating the type for a <code>ResultSet</code> object | ||
* @return | ||
*/ | ||
protected int getResultSetType() { | ||
return resultSetType; | ||
} | ||
|
||
/** | ||
* 间隔轮询查询起始位置 | ||
* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters