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

com.jeesuite.mybatis.kit.SqlParseUtils Maven / Gradle / Ivy

There is a newer version: 1.4.0
Show newest version
package com.jeesuite.mybatis.kit;

import java.util.List;

import com.alibaba.druid.sql.ast.SQLStatement;
import com.alibaba.druid.sql.dialect.mysql.parser.MySqlStatementParser;
import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlSchemaStatVisitor;

public class SqlParseUtils {

	public static void main(String[] args) {
		String sql = "DELETE a1, a2 FROM t1 AS a1 INNER JOIN t2 AS a2 WHERE a1.id=a2.id;";
		 
		MySqlStatementParser parser = new MySqlStatementParser(sql);
		List statementList = parser.parseStatementList();
		SQLStatement statemen = statementList.get(0);
		 
		MySqlSchemaStatVisitor visitor = new MySqlSchemaStatVisitor();
		statemen.accept(visitor);
		
		System.out.println(visitor.getTables());
		
		System.out.println(visitor.getColumns());
		
		System.out.println(visitor.getConditions());
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy