⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sqltool.java

📁 企业进销存源码
💻 JAVA
字号:
package com.web.util;

/**
 * @author Administrator
 *
 * To change this generated comment edit the template variable "typecomment":
 * Window>Preferences>Java>Templates.
 * To enable and disable the creation of type comments go to
 * Window>Preferences>Java>Code Generation.
 */
public class SQLTool {
    public final static int NUMBER = 0;
    public final static int STRING = 1;
    public final static int DATE = 2;

    public static String getSelectWhereClause(
            int dataType,
            String srcSqlStr,
            String fieldName,
            String condition,
            String value) {
        StringBuffer buffer = new StringBuffer();

        if (value == null) return srcSqlStr;

        if (value.trim().length() > 0) {

            try {
                if (srcSqlStr == null) {

                    System.out.println("srcSqlStr can't be null!");

                }

            } catch (Exception ex) {
                ex.printStackTrace();
            }

            if (srcSqlStr.trim().length() != 0) {
                //srcSqlStr isn't empty string.
                buffer.append(srcSqlStr + " AND ");
            }

            switch (dataType) {
                case NUMBER:

                    break;
                case STRING:
                    if (condition.toLowerCase().equals("like")) {
                        buffer.append(
                                fieldName + " " + condition + " '%" + value + "%'");
                    } else {
                        buffer.append(
                                fieldName + " " + condition + " '" + value + "'");
                    }
                    break;
                case DATE:
                    break;
            }
            return buffer.toString();
        } else {
            return srcSqlStr;

        }

    }
}

⌨️ 快捷键说明

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