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

com.bixuebihui.r2dbc.sql.IDbHelper Maven / Gradle / Ivy

The newest version!
package com.bixuebihui.r2dbc.sql;

import com.bixuebihui.jdbc.ParamsIterator;
import io.r2dbc.spi.Connection;
import io.r2dbc.spi.ConnectionFactory;
import org.reactivestreams.Publisher;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

import jakarta.validation.constraints.NotNull;
import java.util.List;
import java.util.Map;

/**
 * 

IDbHelper interface.

* * @author xingwx * @version $Id: $Id */ public interface IDbHelper { /** * Example: final List names = new LinkedList(); * dbHelper.executeQuery("SELECT user_mc FROM jiao_user", new * RowCallbackHandler() { public void processRow(ResultSet rs) throws * SQLException { names.add(rs.getString(1)); }; * * @param sql * SQL语句 * @param handle * 处理接口 */ Mono executeQuery(String sql, RowCallbackHandler handle); /** *

executeQuery.

* * @param sql a {@link String} object. * @param params an array of {@link Object} objects. * @param handle a {@link RowCallbackHandler} object. */ Mono> executeQuery(String sql, Object[] params, RowCallbackHandler handle); /** * must change the return value to {@code List> } * * @param sql SQL 语句 * @param params SQL 参数 * @return List of Map */ Mono>> executeQuery(String sql, Object[] params); /** *

executeScalar.

* * @param strSql a {@link String} object. * @return a {@link Object} object. */ Mono executeScalar(String strSql); /** *

executeScalar.

* * @param sql a {@link String} object. * @param params an array of {@link Object} objects. * @return a {@link Object} object. */ Mono executeScalar(String sql, Object[] params); /** *

executeScalar.

* * @param sql a {@link String} object. * @param params an array of {@link Object} objects. * @param cn a {@link Connection} object. * @return a {@link Object} object. */ Mono executeScalar(String sql, Object[] params, Mono cn); /** * must change the return value to {@code List> } * * @param strSql SQL 语句 * @return List of Map */ Flux> exeQuery(String strSql); /** *

getConnection.

* * @return a {@link Connection} object. */ Publisher getConnection(); /** *

executeQuery.

* * @param sql a {@link String} object. * @param params an array of {@link Object} objects. * @param handle a {@link RowMapperResultReader} object. * @param a T object. * @return a {@link List} object. */ @NotNull Mono> executeQuery(String sql, Object[] params, RowMapperResultReader handle); @NotNull Mono> executeQuery(String sql, Object[] params, RowMapper handle); /** *

executeNoQuery.

* * @param strSql a {@link String} object. * @param params an array of {@link Object} objects. * @param cn a {@link Connection} object. * @return a int. */ Mono executeNoQuery(String strSql, Object[] params, Connection cn); /** *

executeNoQuery.

* * @param sql a {@link String} object. * @param params an array of {@link Object} objects. * @param targetSqlTypes an array of int. * @return a int. */ Mono executeNoQuery(String sql, Object[] params, Class[] targetSqlTypes); /** *

executeNoQuery.

* * @param sql a {@link String} object. * @param params an array of {@link Object} objects. * @param targetSqlTypes an array of int. * @param conn a {@link Connection} object. * @return a int. */ Mono executeNoQuery(String sql, Object[] params, Class[] targetSqlTypes, Mono conn); /** *

executeNoQuery.

* * @param strSql a {@link String} object. * @return a int. */ Mono executeNoQuery(String strSql); /** * return auto_increment id value * @param sql insert sql * @param params params * @param targetSqlTypes parameter's types * @param conn a {@link Connection } * @return */ Mono insertAndFetchLastId(String sql, Object[] params, Class[] targetSqlTypes, Mono conn); /** *

executeNoQuery.

* * @param sql a {@link String} object. * @param params an array of {@link Object} objects. * @return a int. */ Mono executeNoQuery(String sql, Object[] params); /** *

executeNoQuery.

* * @param strSql an array of {@link String} objects. * @return a int. */ Mono executeNoQuery(String[] strSql); /** *

executeNoQuery.

* * @param strSql an array of {@link String} objects. * @param cn a {@link Connection} object. * @return a int. */ Mono executeNoQuery(String[] strSql, Mono cn); /** * 批处里数组, 用于Insert, delete或update * * @param strSql 参数化SQL语句 * @param params 参数数组列表 * @param cn 数据库连接,如为空,则自动获得 * @return 成功执行数量 */ Mono executeNoQueryBatch(String strSql, Iterable params, Mono cn); /** *

executeNoQueryBatch.

* * @param strSql a {@link String} object. * @param params a {@link Iterable} object. * @return a int. */ Mono executeNoQueryBatch(String strSql, Iterable params); /** *

executeNoQueryBatch.

* * @param strSql a {@link String} object. * @param total a int. * @param cur a {@link ParamsIterator.CurrentParameters} object. * @param cn a {@link Connection} object. * @return a int. */ Mono executeNoQueryBatch(String strSql, int total, ParamsIterator.CurrentParameters cur, Mono cn); /** * 读写分离的连接获取,readOnly=true for select, readOnly=false for * update,insert,delete,create, alter etc. * * @param readOnly * readOnly=true for select, readOnly=false for * update,insert,delete,create, alter etc * @return 返回只读链接 */ Publisher getConnection(boolean readOnly) ; ConnectionFactory getDataSource(); /** *

setDataSource.

* * @param connManager a {@link ConnectionFactory} object. */ void setDataSource(ConnectionFactory connManager); /** *

close.

* */ void close() ; }