当前位置: 首页>>代码示例>>Java>>正文


Java JSQLParserException.printStackTrace方法代码示例

本文整理汇总了Java中net.sf.jsqlparser.JSQLParserException.printStackTrace方法的典型用法代码示例。如果您正苦于以下问题:Java JSQLParserException.printStackTrace方法的具体用法?Java JSQLParserException.printStackTrace怎么用?Java JSQLParserException.printStackTrace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.sf.jsqlparser.JSQLParserException的用法示例。


在下文中一共展示了JSQLParserException.printStackTrace方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: findBindArgsExpressions

import net.sf.jsqlparser.JSQLParserException; //导入方法依赖的package包/类
/**
 * 找到所有绑定变量
 *
 * @param sql
 * @return
 */
protected static Set<Expression> findBindArgsExpressions(String sql) {
    if (sql == null || sql.startsWith("PRAGMA") || !sql.contains("?")) {
        return new LinkedHashSet<>();
    }

    KbSqlParserManager pm = new KbSqlParserManager();

    try {
        Statement statement = pm.parse(sql);

        Set<Expression> expressionSet = findBindArgsExpressions(statement);

        return expressionSet;
    } catch (JSQLParserException e) {
        e.printStackTrace();
    }
    return new LinkedHashSet<>();
}
 
开发者ID:kkmike999,项目名称:YuiHatano,代码行数:25,代码来源:KbSqlParser.java

示例2: parse

import net.sf.jsqlparser.JSQLParserException; //导入方法依赖的package包/类
private String parse(String query, QueryType queryType) {
    Statement statement = null;

    try {
        // Read and parse the query
        Reader reader = new StringReader(query);
        statement = parserManager.parse(reader);

        // Find the appropriate method to call based on the query and statement types
        if (statement instanceof Select) {
            statement = queryType.parseQuery((Select) statement, this);
        } else if (statement instanceof Insert) {
            statement = queryType.parseQuery((Insert) statement, this);
        } else if (statement instanceof Delete) {
            statement = queryType.parseQuery((Delete) statement, this);
        } else if (statement instanceof Update) {
            requiresUpdate = true;
            statement = queryType.parseQuery((Update) statement, this);
        } else {
            logger.error("SQL statement type not supported.");
        }
    } catch (JSQLParserException e) {
        logger.error("Failed to parse query");
        e.printStackTrace();
    }

    return statement == null ? "" : statement.toString();
}
 
开发者ID:Hyperparticle,项目名称:integrity-coded-database,代码行数:29,代码来源:ICDBQuery.java

示例3: getStatementFinder

import net.sf.jsqlparser.JSQLParserException; //导入方法依赖的package包/类
/**
* 
* @param sql
* @return
* @throws JSQLParserException
*/
  public static StatementFinder getStatementFinder(String sql) {

      CCJSqlParserManager pm = new CCJSqlParserManager();
      net.sf.jsqlparser.statement.Statement statement = null;
      StatementFinder statementFinder = null;
      try {
          statement = pm.parse(new StringReader(sql));
          if (statement instanceof Select) {
              Select selectStatement = (Select) statement;
              statementFinder = new SelectItemFinder(selectStatement);
          } else if (statement instanceof Insert) {
              Insert insertStatement = (Insert) statement;
              statementFinder = new InsertItemFinder(insertStatement);
          }
          else if (statement instanceof Delete) {
              Delete deleteStatement = (Delete) statement;
              statementFinder = new DeleteItemFinder(deleteStatement);
          } else if (statement instanceof Update) {
              Update updateStatement = (Update) statement;
              statementFinder = new UpdateItemFinder(updateStatement);
          }
      } catch (JSQLParserException e) {
          e.printStackTrace();
          throw new RuntimeException(e);
      }
      return statementFinder;
  }
 
开发者ID:qafedev,项目名称:qafe-platform,代码行数:34,代码来源:StatementFinderFactory.java

示例4: testUnion

import net.sf.jsqlparser.JSQLParserException; //导入方法依赖的package包/类
@Test
public void testUnion() {
    TableNameReplacer tableNameReplacer = new TableNameReplacer(manager);
    String sqlcmd = "select * from ddf://adatao/a union select * from " +
            "ddf://adatao/b";
    try {
        Statement statement = parser.parse(new StringReader(sqlcmd));
        // System.out.println(statement.toString());
        int a = 2;
    } catch (JSQLParserException e) {
        e.printStackTrace();
    }
}
 
开发者ID:ddf-project,项目名称:DDF,代码行数:14,代码来源:TableNameReplacerTests.java

示例5: getAutoincrementColumn

import net.sf.jsqlparser.JSQLParserException; //导入方法依赖的package包/类
public List<ColumnField> getAutoincrementColumn(String tableName) {
    List<ColumnField> columnFieldList = new LinkedList<>();

    if (!isDBOk()) {
        return columnFieldList;
    }

    String sql = "SELECT sql FROM sqlite_master WHERE type='table' AND name='" + tableName + "'";
    Cursor cursor = _db.rawQuery(sql, null);
    if (cursor == null) return columnFieldList;

    if (!cursor.moveToFirst()) {
        cursor.close();
        return columnFieldList;
    }

    String sqlStr = cursor.getString(0);
    cursor.close();

    if (TextUtils.isEmpty(sqlStr)) return columnFieldList;

    try {
        CreateTable createTable = (CreateTable) CCJSqlParserUtil.parse(sqlStr);
        List<ColumnDefinition> columnList = createTable.getColumnDefinitions();

        ColumnField field;
        List<String> specList;
        for (ColumnDefinition definition : columnList) {

            field = new ColumnField();
            field.setFieldName(SQLTools.removeColumnMark(definition.getColumnName()));
            field.setFieldType(SQLTools.removeColumnMark(definition.getColDataType().getDataType()));

            specList = definition.getColumnSpecStrings();
            if (specList != null) {
                String tmpStr;
                int next;
                int conditionSize = specList.size();
                for (int i = 0; i < conditionSize; i++) {
                    next = i + 1;
                    tmpStr = specList.get(i).toUpperCase();

                    if (tmpStr.equals(Constant.PRIMARY_VALUE)) {
                        field.setPk(1);
                    }

                    if (tmpStr.equals(Constant.AUTOINCREMENT_VALUE)) {
                        field.setIsAutoIncr(true);
                    }

                    if (tmpStr.equals(Constant.NOT_VALUE) &&
                            specList.get(next).toUpperCase().equals(Constant.NULL_VALUE)) {
                        field.setNotNull(1);
                    }

                    if (tmpStr.equals(Constant.DEFAULT_VALUE)) {
                        if (next < conditionSize && !TextUtils.isEmpty(specList.get(next))) {
                            field.setDef(SQLTools.removeColumnMark(specList.get(next)));
                        }
                    }
                }
            }

            columnFieldList.add(field);
            Logger.d("--------" + field.toString());
        }

    } catch (JSQLParserException e) {
        e.printStackTrace();
    }

    return columnFieldList;
}
 
开发者ID:WeiMei-Tian,项目名称:editor-sql,代码行数:74,代码来源:SQLHelper.java


注:本文中的net.sf.jsqlparser.JSQLParserException.printStackTrace方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。