本文整理匯總了Java中org.apache.storm.jdbc.mapper.SimpleJdbcMapper類的典型用法代碼示例。如果您正苦於以下問題:Java SimpleJdbcMapper類的具體用法?Java SimpleJdbcMapper怎麽用?Java SimpleJdbcMapper使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
SimpleJdbcMapper類屬於org.apache.storm.jdbc.mapper包,在下文中一共展示了SimpleJdbcMapper類的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: buildBolt
import org.apache.storm.jdbc.mapper.SimpleJdbcMapper; //導入依賴的package包/類
@Bean("wordCountToMySQLBolt")
public JdbcInsertBolt buildBolt() {
super.setId("wordCountToMySQLBolt");
Map hikariConfigMap = Maps.newHashMap();
hikariConfigMap.put("dataSourceClassName", mySQLProps.getDataSourceClassName());
hikariConfigMap.put("dataSource.url", mySQLProps.getDataSourceUrl());
hikariConfigMap.put("dataSource.user", mySQLProps.getDataSourceUser());
hikariConfigMap.put("dataSource.password", mySQLProps.getDataSourcePassword());
ConnectionProvider connectionProvider = new HikariCPConnectionProvider(hikariConfigMap);
List<Column> columnSchema = Lists.newArrayList(
new Column("targetDate", Types.DATE),
new Column("word", java.sql.Types.VARCHAR),
new Column("count", Types.BIGINT),
new Column("count_0", Types.BIGINT)
);
// JdbcMapper simpleJdbcMapper = new SimpleJdbcMapper(tableName, connectionProvider);
JdbcMapper simpleJdbcMapper = new SimpleJdbcMapper(columnSchema);
JdbcInsertBolt insertBolt = new JdbcInsertBolt(connectionProvider, simpleJdbcMapper)
.withInsertQuery(insertQuery)
.withQueryTimeoutSecs(queryTimeoutSecs);
return insertBolt;
}