All Downloads are FREE. Search and download functionalities are using the official Maven repository.

me.icymint.libra.jdbc.query.multi.QueryTokens Maven / Gradle / Ivy

package me.icymint.libra.jdbc.query.multi;

import java.sql.Connection;

import me.icymint.libra.jdbc.JdbcAccessException;
import me.icymint.libra.jdbc.query.SqlQuery;

/**
 * 一组相关JDBC执行序列。其用于定义一组有序的JDBC查询序列。规定了初始参数和最后返回参数的形式。
 * 
 * @author Daniel Yu
 * @since 2013-3-14
 * 
 * @param 
 *            最后返回结果。
 * @param 

* 查询初始参数。 */ public class QueryTokens implements SqlQuery { private static class Q { private Object p = null; private Q(Object p) { this.p = p; } @SuppressWarnings("unchecked") private

P getResult() { return (P) p; } @SuppressWarnings("unchecked") private Q query(Connection conn, QueryToken token) throws JdbcAccessException { this.p = token.query().query(conn, token.sql(), token.p() == null ? (P) this.getResult() : token.p()); return this; } } private QueryToken x; private QueryToken[] ys; private QueryToken z; public QueryTokens(QueryToken x, QueryToken[] ys, QueryToken z) { this.x = x; this.ys = ys; this.z = z; } @Override public T query(Connection conn, String sql, P p) throws JdbcAccessException { Q q = new Q(p).query(conn, z); for (QueryToken y : ys) { q = q.query(conn, y); } q = q.query(conn, x); return q.getResult(); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy