本文整理了Java中org.skife.jdbi.v2.Query.bind
方法的一些代码示例,展示了Query.bind
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.bind
方法的具体详情如下:
包路径:org.skife.jdbi.v2.Query
类名称:Query
方法名:bind
暂无
代码示例来源:origin: apache/incubator-druid
@Override
public boolean tableExists(Handle handle, String tableName)
{
return !handle.createQuery("select * from SYS.SYSTABLES where tablename = :tableName")
.bind("tableName", StringUtils.toUpperCase(tableName))
.list()
.isEmpty();
}
代码示例来源:origin: apache/incubator-druid
sql += " FETCH FIRST :n ROWS ONLY";
Query<Map<String, Object>> query = handle.createQuery(sql).bind("start", timestamp.toString());
query = query.bind("n", maxNumStatuses);
query = query.bind("ds", dataSource);
代码示例来源:origin: apache/incubator-druid
@Override
public boolean tableExists(final Handle handle, final String tableName)
{
return !handle.createQuery(
"SELECT tablename FROM pg_catalog.pg_tables WHERE schemaname = 'public' AND tablename ILIKE :tableName"
)
.bind("tableName", tableName)
.map(StringMapper.FIRST)
.list()
.isEmpty();
}
代码示例来源:origin: apache/incubator-druid
@Override
public boolean tableExists(final Handle handle, final String tableName)
{
return !handle.createQuery("SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = :tableName")
.bind("tableName", tableName)
.map(StringMapper.FIRST)
.list()
.isEmpty();
}
代码示例来源:origin: apache/incubator-druid
getAuditTable()
).bind("audit_key", key)
.bind("type", type)
.bind("start_date", theInterval.getStart().toString())
.bind("end_date", theInterval.getEnd().toString())
.map(
new ResultSetMapper<AuditEntry>()
代码示例来源:origin: apache/incubator-druid
@Override
public Optional<StatusType> withHandle(Handle handle) throws Exception
{
byte[] res = handle.createQuery(
StringUtils.format("SELECT status_payload FROM %s WHERE id = :id", entryTable)
)
.bind("id", entryId)
.map(ByteArrayMapper.FIRST)
.first();
return Optional.fromNullable(
res == null ? null : jsonMapper.readValue(res, statusType)
);
}
}
代码示例来源:origin: apache/incubator-druid
@Override
public Optional<EntryType> withHandle(Handle handle) throws Exception
{
byte[] res = handle.createQuery(
StringUtils.format("SELECT payload FROM %s WHERE id = :id", entryTable)
)
.bind("id", entryId)
.map(ByteArrayMapper.FIRST)
.first();
return Optional.fromNullable(
res == null ? null : jsonMapper.readValue(res, entryType)
);
}
}
代码示例来源:origin: apache/incubator-druid
@Override
public List<String> inTransaction(Handle handle, TransactionStatus status)
{
return handle.createQuery(reverseFetchQuery)
.bind("val", value)
.map(StringMapper.FIRST)
.list();
}
});
代码示例来源:origin: apache/incubator-druid
@Override
public List<String> inTransaction(Handle handle, TransactionStatus status)
{
return handle.createQuery(fetchQuery)
.bind("val", key)
.map(StringMapper.FIRST)
.list();
}
}
代码示例来源:origin: apache/incubator-druid
@Override
public List<AuditEntry> withHandle(Handle handle)
{
Query<Map<String, Object>> query = handle.createQuery(theQueryString);
if (key != null) {
query.bind("audit_key", key);
}
return query.bind("type", type)
.setMaxRows(theLimit)
.map(
new ResultSetMapper<AuditEntry>()
{
@Override
public AuditEntry map(int index, ResultSet r, StatementContext ctx)
throws SQLException
{
try {
return jsonMapper.readValue(r.getBytes("payload"), AuditEntry.class);
}
catch (IOException e) {
throw new SQLException(e);
}
}
}
)
.list();
}
}
代码示例来源:origin: apache/incubator-druid
.bind("type", type)
.bind("start_date", theInterval.getStart().toString())
.bind("end_date", theInterval.getEnd().toString())
.map(
new ResultSetMapper<AuditEntry>()
代码示例来源:origin: apache/incubator-druid
private Query<Map<String, Object>> createActiveTaskInfoQuery(Handle handle, @Nullable String dataSource)
{
String sql = StringUtils.format(
"SELECT "
+ " id, "
+ " status_payload, "
+ " payload, "
+ " datasource, "
+ " created_date "
+ "FROM "
+ " %s "
+ "WHERE "
+ getWhereClauseForActiveStatusesQuery(dataSource)
+ "ORDER BY created_date",
entryTable
);
Query<Map<String, Object>> query = handle.createQuery(sql);
if (dataSource != null) {
query = query.bind("ds", dataSource);
}
return query;
}
代码示例来源:origin: apache/incubator-druid
public byte[] lookupWithHandle(
final Handle handle,
final String tableName,
final String keyColumn,
final String valueColumn,
final String key
)
{
final String selectStatement = StringUtils.format(
"SELECT %s FROM %s WHERE %s = :key", valueColumn,
tableName, keyColumn
);
List<byte[]> matched = handle.createQuery(selectStatement)
.bind("key", key)
.map(ByteArrayMapper.FIRST)
.list();
if (matched.isEmpty()) {
return null;
}
if (matched.size() > 1) {
throw new ISE("Error! More than one matching entry[%d] found for [%s]?!", matched.size(), key);
}
return matched.get(0);
}
代码示例来源:origin: apache/incubator-druid
.bind("dataSource", dataSource)
.bind("start", interval.getStart().toString())
.bind("end", interval.getEnd().toString())
.map(new ResultSetMapper<Pair<DataSegment, String>>()
代码示例来源:origin: apache/incubator-druid
@Override
public List<Map<String, Object>> withHandle(Handle handle)
{
return handle.createQuery(
StringUtils.format("SELECT id FROM %s WHERE id=:id", config.getSegmentsTable())
)
.bind("id", segmentId)
.list();
}
}
代码示例来源:origin: apache/incubator-druid
@Override
@Nullable
public TaskInfo<EntryType, StatusType> getTaskInfo(String entryId)
{
return connector.retryWithHandle(handle -> {
final String query = StringUtils.format(
"SELECT id, status_payload, payload, datasource, created_date FROM %s WHERE id = :id",
entryTable
);
return handle.createQuery(query)
.bind("id", entryId)
.map(taskInfoMapper)
.first();
});
}
代码示例来源:origin: apache/incubator-druid
private List<SegmentIdWithShardSpec> getPendingSegmentsForIntervalWithHandle(
final Handle handle,
final String dataSource,
final Interval interval
) throws IOException
{
final List<SegmentIdWithShardSpec> identifiers = new ArrayList<>();
final ResultIterator<byte[]> dbSegments =
handle.createQuery(
StringUtils.format(
"SELECT payload FROM %1$s WHERE dataSource = :dataSource AND start <= :end and %2$send%2$s >= :start",
dbTables.getPendingSegmentsTable(), connector.getQuoteString()
)
)
.bind("dataSource", dataSource)
.bind("start", interval.getStart().toString())
.bind("end", interval.getEnd().toString())
.map(ByteArrayMapper.FIRST)
.iterator();
while (dbSegments.hasNext()) {
final byte[] payload = dbSegments.next();
final SegmentIdWithShardSpec identifier = jsonMapper.readValue(payload, SegmentIdWithShardSpec.class);
if (interval.overlaps(identifier.getInterval())) {
identifiers.add(identifier);
}
}
dbSegments.close();
return identifiers;
}
代码示例来源:origin: apache/incubator-druid
@Override
public boolean tableExists(Handle handle, String tableName)
{
String databaseCharset = handle
.createQuery("SELECT @@character_set_database")
.map(StringMapper.FIRST)
.first();
if (!databaseCharset.startsWith("utf8")) {
throw new ISE(
"Druid requires its MySQL database to be created with an UTF8 charset, found `%1$s`. "
+ "The recommended charset is `utf8mb4`.",
databaseCharset
);
} else if (!"utf8mb4".equals(databaseCharset)) {
log.warn("The current database charset `%1$s` does not match the recommended charset `utf8mb4`", databaseCharset);
}
return !handle.createQuery("SHOW tables LIKE :tableName")
.bind("tableName", tableName)
.list()
.isEmpty();
}
代码示例来源:origin: apache/incubator-druid
private boolean segmentExists(final Handle handle, final DataSegment segment)
{
return !handle
.createQuery(StringUtils.format("SELECT id FROM %s WHERE id = :identifier", dbTables.getSegmentsTable()))
.bind("identifier", segment.getId().toString())
.map(StringMapper.FIRST)
.list()
.isEmpty();
}
代码示例来源:origin: apache/incubator-druid
@Override
public List<LogType> withHandle(Handle handle)
{
return handle
.createQuery(
StringUtils.format(
"SELECT log_payload FROM %1$s WHERE %2$s_id = :entryId",
logTable, entryTypeName
)
)
.bind("entryId", entryId)
.map(ByteArrayMapper.FIRST)
.fold(
new ArrayList<>(),
(List<LogType> list, byte[] bytes, FoldController control, StatementContext ctx) -> {
try {
list.add(jsonMapper.readValue(bytes, logType));
return list;
}
catch (IOException e) {
log.makeAlert(e, "Failed to deserialize log")
.addData("entryId", entryId)
.addData("payload", StringUtils.fromUtf8(bytes))
.emit();
throw new SQLException(e);
}
}
);
}
}
内容来源于网络,如有侵权,请联系作者删除!