Examples of CCJSqlParserManager


Examples of net.sf.jsqlparser.parser.CCJSqlParserManager

  }

  public static SQLVisitor parseQuery(Map map) {
    final String sqlString = readSQL(map);

    final CCJSqlParserManager pm = new CCJSqlParserManager();
    Statement statement = null;
    try {
      statement = pm.parse(new StringReader(sqlString));
    } catch (final JSQLParserException ex) {
      LOG.info("JSQLParserException");
    }

    if (statement instanceof Select) {
View Full Code Here

Examples of net.sf.jsqlparser.parser.CCJSqlParserManager

    String[] split=whereReg.split(this.tablename +" "+otherSql.trim());

    if(split.length>1)
    {
      String where=split[1].trim();
      CCJSqlParserManager pm = new CCJSqlParserManager();
      PlainSelect plainSelect =  (PlainSelect)((Select) pm.parse(new StringReader("select * from abc where "+where))).getSelectBody();
      Expression e  = getExpressionWithoutParenthesis(plainSelect.getWhere());
      JSONArray jsonObj = new JSONArray();//{colname:{operate:1,value:xxxx}}

      JSONObject subQuery=new JSONObject();
      subQuery.put("subQuery", "1");
View Full Code Here

Examples of net.sf.jsqlparser.parser.CCJSqlParserManager

 
  public void parse(String sql) throws JSQLParserException, JSONException
  {
    this.sql=sql;

        CCJSqlParserManager parserManager = new CCJSqlParserManager();
     Insert insert = (Insert) parserManager.parse(new StringReader(sql));
         this.tablename=insert.getTable().getName();
        
         fl=new String[insert.getColumns().size()];
         for(int i=0;i<fl.length;i++)
         {
View Full Code Here

Examples of net.sf.jsqlparser.parser.CCJSqlParserManager

    FileSystem fs=FileSystem.get(conf);
    FileSystem lfs=FileSystem.getLocal(conf);
    String topschema=getFileContent(lfs,new Path(stormhome,"solr/conf/schema.top.txt"));
    String downschema=getFileContent(lfs,new Path(stormhome,"solr/conf/schema.down.txt"));
    String fieldschema=getFileContent(lfs,new Path(tableConfig));
    CCJSqlParserManager parserManager = new CCJSqlParserManager();
    CreateTable createTable = (CreateTable) parserManager.parse(new StringReader(fieldschema));
    StringBuffer buffer=new StringBuffer();
    String tableName=createTable.getTable().getName();
    buffer.append("\r\n");

    for(int i=0;i<createTable.getColumnDefinitions().size();i++)
View Full Code Here

Examples of net.sf.jsqlparser.parser.CCJSqlParserManager

public class MemoryTest {

  public static void main(String[] args) throws Exception {
    System.gc();
    System.out.println(Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory());
    CCJSqlParserManager parserManager = new CCJSqlParserManager();

    /*
     * String longQuery = new String(
     * "select  *  from  (  SELECT  intermediate.id  as  id  ,  intermediate.date  as          " +
     * "date  FROM  (  SELECT  DISTINCT   (  id  )   FROM  (  SELECT                           " +
     * "wct_workflows.workflow_id  as  id  ,  wct_transaction.date  as  date  FROM             " +
     * "wct_audit_entry  ,  wct_transaction  ,  wct_workflows  WHERE                           " +
     * "(  wct_audit_entry.privilege  =  'W'  or  wct_audit_entry.privilege  =                 " +
     * "'C'  )  and  wct_audit_entry.outcome  =  't'  and                                      " +
     * "wct_audit_entry.transaction_id  =  wct_transaction.transaction_id  and                 " +
     * "wct_transaction.user_id  = 164 and  wct_audit_entry.object_id  =                       " +
     * "wct_workflows.active_version_id ))) UNION  SELECT  wct_workflows.workflow_id  as       " +
     * "id  ,  wct_transaction.date  as  date  FROM  wct_audit_entry  ,                        " +
     * "wct_transaction  ,  wct_workflows  WHERE  (  wct_audit_entry.privilege  =              " +
     * "'W'  or  wct_audit_entry.privilege  =  'C'  )  and  wct_audit_entry.outcome            " +
     * "=  't'  and  wct_audit_entry.transaction_id  =                                         " +
     * "wct_transaction.transaction_id  and  wct_transaction.user_id  = 164 and                " +
     * "afdf=  (  select  wct_audit_entry.object_id  from  wct_audit_entry  ,                  " +
     * "wct_workflow_archive  where  wct_audit_entry.object_id  =                              " +
     * "wct_workflow_archive.archive_id  and  wct_workflows.workflow_id  =                     " +
     * "wct_workflow_archive.workflow_id  )                                                    " +
     * "UNION  SELECT  wct_workflows.workflow_id                                               " +
     * "as  id  ,  wct_transaction.date  as  date  FROM  wct_audit_entry  ,                    " +
     * "wct_transaction  ,  wct_workflows  WHERE  (  wct_audit_entry.privilege  =              " +
     * "'W'  OR  wct_audit_entry.privilege  =  'E'  OR  wct_audit_entry.privilege  =           " +
     * "'A'  )  and  wct_audit_entry.outcome  =  't'  and                                      " +
     * "wct_audit_entry.transaction_id  =  wct_transaction.transaction_id  and                 " +
     * "wct_transaction.user_id  = 164 and  wct_audit_entry.object_id  =                       " +
     * "wct_workflows.workflow_id    UNION SELECT * FROM interm2  ,  wct_workflow_docs  WHERE  " +
     * "interm2.id  =  wct_workflow_docs.document_id  ORDER BY  id  ,  date  DESC              ");
     */
    String longQuery = new String("select * from k where ID > 4");

    /*
     * String longQuery = "select  *  from  (  SELECT  intermediate.id  as  id  ,  intermediate.date  as          "
     * + "date  FROM  (  SELECT  DISTINCT   (  id  )   FROM  (  SELECT                           " +
     * "wct_workflows.workflow_id  as  id  ,  wct_transaction.date  as  date  FROM             " +
     * "wct_audit_entry  ,  wct_transaction  ,  wct_workflows  WHERE                           " +
     * "(  wct_audit_entry.privilege  =  'W'  or  wct_audit_entry.privilege  =                 " + "'C'  ))))";
     */
    /*
     * String longQuery = "select  *  from  d WHERE                           " +
     * "(  wct_audit_entry.privilege  =  'W'  or  wct_audit_entry.privilege  =                 " +
     * "'C'  )  and  wct_audit_entry.outcome  =  't'  and                                      " +
     * "wct_audit_entry.transaction_id  =  wct_transaction.transaction_id  and                 " +
     * "wct_transaction.user_id  = 164 and  wct_audit_entry.object_id  =                       " +
     * "wct_workflows.active_version_id ";
     */
    StringReader stringReader = new StringReader(longQuery);
    Statement statement = parserManager.parse(stringReader);
    // stringReader = new StringReader(longQuery);
    // Statement statement2 = parserManager.parse(stringReader);
    // stringReader = null;
    // statement2 = null;
    statement = null;
View Full Code Here

Examples of net.sf.jsqlparser.parser.CCJSqlParserManager

  public CCJSqlParserManagerTest(String arg0) {
    super(arg0);
  }

  public void testParse() throws Exception {
    CCJSqlParserManager parserManager = new CCJSqlParserManager();
    BufferedReader in = new BufferedReader(new InputStreamReader(CreateTableTest.class.getResourceAsStream("/simple_parsing.txt")));

    String statement = "";
    while (true) {
      try {
        statement = CCJSqlParserManagerTest.getStatement(in);
        if (statement == null) {
          break;
        }

        parserManager.parse(new StringReader(statement));
      } catch (JSQLParserException e) {
        throw new TestException("impossible to parse statement: " + statement, e);
      }
    }
  }
View Full Code Here

Examples of net.sf.jsqlparser.parser.CCJSqlParserManager

        }
        return cleanedUpViews;
    }

    public static PlainSelect parseSqlQuery(String selectStatement) throws IOException {
        CCJSqlParserManager pm = new CCJSqlParserManager();
        Reader reader = new StringReader(selectStatement);
        Statement statement;
        try {
            statement = pm.parse(reader);
        } catch (Exception e) {
            throw new DataSourceException("parsing select statement: " + e.getCause().getMessage(),
                    e);
        }
        if (!(statement instanceof Select)) { // either PlainSelect or Union
View Full Code Here

Examples of net.sf.jsqlparser.parser.CCJSqlParserManager

    private ResultSet resultSet;
    private int updateCnt = -1;

    protected SimpleDBStatement(Connection conn) {
        this.connection = (SimpleDBConnection) conn;
        this.parserManager = new CCJSqlParserManager();
    }
View Full Code Here

Examples of net.sf.jsqlparser.parser.CCJSqlParserManager

    private ResultSet resultSet;
   
    protected SimpleDBPreparedStatement(String sql, SimpleDBConnection conn) {
        this.sql = sql.trim();
        this.connection = conn;
        this.parserManager = new CCJSqlParserManager();
        this.args = new LinkedList<String>();
    }
View Full Code Here

Examples of net.sf.jsqlparser.parser.CCJSqlParserManager

  public List<ZNRecord> execute(String sql, ZNRecordTupleReader tupleReader) throws Exception
  {
    sql = replaceExplodeFields(sql, "explodeList");
    sql = replaceExplodeFields(sql, "explodeMap");
   
    CCJSqlParserManager pm = new CCJSqlParserManager();
    Statement statement = pm.parse(new StringReader(sql));
    if (statement instanceof Select)
    {
      Select selectStatement = (Select) statement;
      SelectVisitorImpl v = new SelectVisitorImpl();
      selectStatement.getSelectBody().accept(v);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.