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

panda.dao.sql.SqlManager Maven / Gradle / Ivy

Go to download

Panda Core is the core module of Panda Framework, it contains commonly used utility classes similar to apache-commons.

There is a newer version: 1.8.0
Show newest version
package panda.dao.sql;

import java.sql.Connection;
import java.sql.ResultSet;

import panda.bean.Beans;
import panda.dao.sql.adapter.TypeAdapters;
import panda.dao.sql.executor.DynamicSqlManager;


/**
 */
public abstract class SqlManager {
	private static SqlManager i = new DynamicSqlManager();

	/**
	 * @return the instance
	 */
	public static SqlManager i() {
		return i;
	}

	/**
	 * @return the instance
	 */
	public static SqlManager getInstance() {
		return i;
	}

	/**
	 * @param instance the instance to set
	 */
	public static void setInstance(SqlManager instance) {
		SqlManager.i = instance;
	}
	
	/**
	 * Beans
	 */
	protected Beans beans = Beans.i();

	/**
	 * typeAdapters
	 */
	protected TypeAdapters typeAdapters = TypeAdapters.i();
	
	/**
	 * @return the beans
	 */
	public Beans getBeans() {
		return beans;
	}

	/**
	 * @param beans the beans to set
	 */
	public void setBeans(Beans beans) {
		this.beans = beans;
	}

	/**
	 * @return the typeAdapters
	 */
	public TypeAdapters getTypeAdapters() {
		return typeAdapters;
	}

	/**
	 * @param typeAdapters the typeAdapters to set
	 */
	public void setTypeAdapters(TypeAdapters typeAdapters) {
		this.typeAdapters = typeAdapters;
	}

	/**
	 * Constructor
	 * @return the SqlExecutor
	 */
	public SqlExecutor getExecutor() {
		return getExecutor(null, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
	}

	/**
	 * Constructor
	 * @param connection connection
	 * @return the SqlExecutor
	 */
	public SqlExecutor getExecutor(Connection connection) {
		return getExecutor(connection, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
	}

	/**
	 * Constructor
	 * 
	 * @param connection connection
	 * @param resultSetType one of the following ResultSet constants: ResultSet.TYPE_FORWARD_ONLY,
	 *            ResultSet.TYPE_SCROLL_INSENSITIVE, or ResultSet.TYPE_SCROLL_SENSITIVE
	 * @return the SqlExecutor
	 */
	public SqlExecutor getExecutor(Connection connection, int resultSetType) {
		return getExecutor(connection, resultSetType, ResultSet.CONCUR_READ_ONLY);
	}

	/**
	 * Constructor
	 * 
	 * @param connection connection
	 * @param resultSetType one of the following ResultSet constants: ResultSet.TYPE_FORWARD_ONLY,
	 *            ResultSet.TYPE_SCROLL_INSENSITIVE, or ResultSet.TYPE_SCROLL_SENSITIVE
	 * @param resultSetConcurrency one of the following ResultSet constants:
	 *            ResultSet.CONCUR_READ_ONLY or ResultSet.CONCUR_UPDATABLE
	 * @return the SqlExecutor
	 */
	public SqlExecutor getExecutor(Connection connection, int resultSetType, int resultSetConcurrency) {
		return getExecutor(connection, resultSetType, resultSetConcurrency, 0);
	}

	/**
	 * Constructor
	 * 
	 * @param connection connection
	 * @param resultSetType one of the following ResultSet constants: ResultSet.TYPE_FORWARD_ONLY,
	 *            ResultSet.TYPE_SCROLL_INSENSITIVE, or ResultSet.TYPE_SCROLL_SENSITIVE
	 * @param resultSetConcurrency one of the following ResultSet constants:
	 *            ResultSet.CONCUR_READ_ONLY or ResultSet.CONCUR_UPDATABLE
	 * @param resultSetHoldability one of the following ResultSet constants:
	 *            ResultSet.HOLD_CURSORS_OVER_COMMIT or ResultSet.CLOSE_CURSORS_AT_COMMIT
	 * @return the SqlExecutor
	 */
	public abstract SqlExecutor getExecutor(Connection connection, int resultSetType, int resultSetConcurrency,
			int resultSetHoldability);
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy