sqlstatement.java

来自「简单的j2ee轻量级框架」· Java 代码 · 共 58 行

JAVA
58
字号
package com.prinice.jfoot.util.dbo;

/**
 * @author:Leo
 * @version:1.0
 * @description:该类用于构造select,update,delete,insert等sql语句
 * @date:2008-2-19
 */

public class SqlStatement {
	private String cols = ""; //待查询列
	private String table = ""; //待查询表
	private String condition = "";//查询条件
	public String getCols(){
		return this.cols;
	}
	public void setCols(String cols){
		this.cols = cols;
	}
	public String getTable(){
		return this.table;
	}
	public void setTable(String table){
		this.table = table;
	}
	public String getCondition(){
		return this.condition;
	}
	public void setCondition(String condition){
		this.condition = condition;
	}
	/*构造select语句*/
	public String getSelectSql(){
		StringBuffer sql = new StringBuffer();
		return (sql.append("select ")
				   .append(cols)
				   .append(" from ")
				   .append(table)
				   .append(" where ")
				   .append(condition)).toString();
	}
	/*构造select count(1)语句*/
	public String getSelectCountSql(){
		StringBuffer sql = new StringBuffer();
		return (sql.append("select count(1)")				   
				   .append(" from ")
				   .append(table)
				   .append(" where ")
				   .append(condition)).toString();
	}
	
	public String toString(){
		return "[cols = " + cols + "],"
		    + "[table = " + table + "],"
			+ "[condition = " + condition + "]";
	}	
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?