本文整理汇总了Java中net.sf.jsqlparser.statement.create.table.CreateTable类的典型用法代码示例。如果您正苦于以下问题:Java CreateTable类的具体用法?Java CreateTable怎么用?Java CreateTable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CreateTable类属于net.sf.jsqlparser.statement.create.table包,在下文中一共展示了CreateTable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testCreateTableStatement
import net.sf.jsqlparser.statement.create.table.CreateTable; //导入依赖的package包/类
private static void testCreateTableStatement(String sql) throws SQLException
{
boolean isDDL = isDDLStatement(sql);
Assert.assertTrue(isDDL);
Statement statement = null;
try
{
statement = CCJSqlParserUtil.parse(sql);
}
catch (JSQLParserException e)
{
throw new CloudSpannerSQLException("Could not parse SQL statement", Code.INVALID_ARGUMENT, e);
}
Assert.assertNotNull(statement);
Assert.assertEquals(CreateTable.class, statement.getClass());
}
示例2: configurationData
import net.sf.jsqlparser.statement.create.table.CreateTable; //导入依赖的package包/类
/**
* configurationData函数,辅助填充Database的hashmap函数
* @param statement 对应的文件中的一条创建数据库请求
* @throws JSQLParserException
*/
public void configurationData(String statement) throws JSQLParserException {
CreateTable createTable = (CreateTable) parserManager.parse(new StringReader(statement));
MTable mtable = new MTable();
ArrayList<MField> mFields = new ArrayList<MField>(); // field信息用ArrayList进行构造
for(int i = 0;i < createTable.getColumnDefinitions().size();i++){ // 填充该mtable的field信息
MField mField = new MField();
mField.setField(((ColumnDefinition) createTable.getColumnDefinitions().get(i)).getColumnName().split("`")[1], ((ColumnDefinition) createTable.getColumnDefinitions().get(i)).getColumnSpecStrings().get(1),((ColumnDefinition)createTable.getColumnDefinitions().get(i)).getColDataType().toString().split(" ")[0]);
mFields.add(mField);
}
// 填充mtable
mtable.set_mTable(createTable.getTable().getName().split("`")[1],"JData", createTable.getColumnDefinitions().size(),mFields);
// 填充hashmap
this.DataBase.put(createTable.getTable().getName().split("`")[1], mtable);
}
示例3: tableGenerator
import net.sf.jsqlparser.statement.create.table.CreateTable; //导入依赖的package包/类
private Generator tableGenerator(String sql, DataSource ds) {
try {
CreateTable stmt = (CreateTable) CCJSqlParserUtil.parse("CREATE TABLE " + sql);
return new Generator()
.writing("migration", g -> g.task(
new FlywayTask("src/main/java", stmt.getTable().getName(), "CREATE TABLE " + sql)));
} catch (JSQLParserException e) {
throw new IllegalArgumentException("Statement generating a table is wrong syntax.", e);
}
}
示例4: processSQL
import net.sf.jsqlparser.statement.create.table.CreateTable; //导入依赖的package包/类
public Result processSQL(String SQL) throws Exception {
Statement s = CCJSqlParserUtil.parse(SQL);
if(s instanceof Select){
return processSelect(SQL);
}
else if(s instanceof Insert){
return processInsert(SQL)? new AggregateResults() : null;
}
else if(s instanceof CreateTable) {
return processCreateTable(SQL) ? new AggregateResults() : null;
}
return new AggregateResults();
}
示例5: visit
import net.sf.jsqlparser.statement.create.table.CreateTable; //导入依赖的package包/类
@Override
public void visit(CreateTable create) {
tables.add(create.getTable().getFullyQualifiedName());
if (create.getSelect() != null) {
create.getSelect().accept(this);
}
}
示例6: visit
import net.sf.jsqlparser.statement.create.table.CreateTable; //导入依赖的package包/类
@Override
public void visit(CreateTable create) {
tables.add(create.getTable(), table -> table.getFullyQualifiedName());
if (create.getSelect() != null) {
create.getSelect().accept(this);
}
}
示例7: plan
import net.sf.jsqlparser.statement.create.table.CreateTable; //导入依赖的package包/类
@Override
public ExecutionPlan plan(String defaultTableSpace, net.sf.jsqlparser.statement.Statement stmt,
boolean scan, boolean returnValues, int maxRows) {
verifyJdbcParametersIndexes(stmt);
ExecutionPlan result;
if (stmt instanceof CreateTable) {
result = ExecutionPlan.simple(buildCreateTableStatement(defaultTableSpace, (CreateTable) stmt));
} else if (stmt instanceof CreateIndex) {
result = ExecutionPlan.simple(buildCreateIndexStatement(defaultTableSpace, (CreateIndex) stmt));
} else if (stmt instanceof Insert) {
result = buildInsertStatement(defaultTableSpace, (Insert) stmt, returnValues);
} else if (stmt instanceof Delete) {
result = buildDeleteStatement(defaultTableSpace, (Delete) stmt, returnValues);
} else if (stmt instanceof Update) {
result = buildUpdateStatement(defaultTableSpace, (Update) stmt, returnValues);
} else if (stmt instanceof Select) {
result = buildSelectStatement(defaultTableSpace, (Select) stmt, scan, maxRows);
} else if (stmt instanceof Execute) {
result = ExecutionPlan.simple(buildExecuteStatement(defaultTableSpace, (Execute) stmt));
} else if (stmt instanceof Alter) {
result = ExecutionPlan.simple(buildAlterStatement(defaultTableSpace, (Alter) stmt));
} else if (stmt instanceof Drop) {
result = ExecutionPlan.simple(buildDropStatement(defaultTableSpace, (Drop) stmt));
} else if (stmt instanceof Truncate) {
result = ExecutionPlan.simple(buildTruncateStatement(defaultTableSpace, (Truncate) stmt));
} else {
return null;
}
return result;
}
示例8: visit
import net.sf.jsqlparser.statement.create.table.CreateTable; //导入依赖的package包/类
@Override
public void visit(CreateTable s) {
visit(s.getTable());
for (ColumnDefinition def : s.getColumnDefinitions()) {
def.setColumnName(CompatibilityUtils.fixMySqlName(def.getColumnName()));
}
if (s.getIndexes() != null) {
for (Index index : s.getIndexes()) {
visit(index);
}
}
}
示例9: visit
import net.sf.jsqlparser.statement.create.table.CreateTable; //导入依赖的package包/类
@Override
public synchronized void visit(CreateTable arg0) {
controlEventMap.put(sql, null);
targetMap.put(sql, null);
insUpdColumnsMap.put(sql, new ArrayList<SqlParameter>());
parameterMap.put(sql, new LinkedList<SqlParameter>());
emptyPrimaryKey(SqlParameterType.WHERE_PARAMETER);
}
示例10: parseToTuple
import net.sf.jsqlparser.statement.create.table.CreateTable; //导入依赖的package包/类
private Tuple<JavaClass, Table> parseToTuple(String createSQL) {
try {
Statement statement = CCJSqlParserUtil.parse(createSQL);
if (statement instanceof CreateTable) {
JavaClass javaClass= buildJavaClass((CreateTable) statement);
Table table = buildTable((CreateTable) statement);
return new Tuple<>(javaClass,table);
} else {
throw new MaliangException("only accept create statement");
}
} catch (JSQLParserException e) {
throw new MaliangException(e);
}
}
示例11: extractColumns
import net.sf.jsqlparser.statement.create.table.CreateTable; //导入依赖的package包/类
private LinkedList<Column> extractColumns(CreateTable createStatement) {
LinkedList<Column> columns = Lists.newLinkedList();
List<ColumnDefinition> columnDefinitions = createStatement.getColumnDefinitions();
for (ColumnDefinition c:columnDefinitions){
Column.ColumnBuilder cBuilder = new Column.ColumnBuilder();
cBuilder.withName(c.getColumnName().toUpperCase());
cBuilder.withType(c.getColDataType().getDataType());
columns.add(cBuilder.build());
}
return columns;
}
示例12: buildJavaClass
import net.sf.jsqlparser.statement.create.table.CreateTable; //导入依赖的package包/类
private JavaClass buildJavaClass(CreateTable createStatement) {
JavaClassBuilder jBuilder = new JavaClassBuilder();
String tableName = createStatement.getTable().getName();
String javaClassName = transformName(tableName,tablePrefix,separator);
jBuilder.withName(javaClassName);
jBuilder.withFields(extractFields(createStatement));
return jBuilder.build();
}
示例13: extractFields
import net.sf.jsqlparser.statement.create.table.CreateTable; //导入依赖的package包/类
private LinkedList<JavaField> extractFields(CreateTable createStatement) {
LinkedList<JavaField> javaFields = Lists.newLinkedList();
List<ColumnDefinition> columnDefinitions = createStatement.getColumnDefinitions();
for (ColumnDefinition c:columnDefinitions){
javaFields.add(convertColumnToField(c));
}
return javaFields;
}
示例14: visit
import net.sf.jsqlparser.statement.create.table.CreateTable; //导入依赖的package包/类
@Override
public void visit(CreateTable create)
{
create.getTable().accept(this);
if (create.getSelect() != null)
{
create.getSelect().accept(this);
}
}
示例15: testCreateTable
import net.sf.jsqlparser.statement.create.table.CreateTable; //导入依赖的package包/类
public void testCreateTable() throws JSQLParserException {
String statement =
"CREATE TABLE mytab (mycol a (10, 20) c nm g, mycol2 mypar1 mypar2 (23,323,3) asdf ('23','123') dasd, "
+ "PRIMARY KEY (mycol2, mycol)) type = myisam";
CreateTable createTable = (CreateTable) parserManager.parse(new StringReader(statement));
assertEquals(2, createTable.getColumnDefinitions().size());
assertEquals("mycol", ((ColumnDefinition) createTable.getColumnDefinitions().get(0)).getColumnName());
assertEquals("mycol2", ((ColumnDefinition) createTable.getColumnDefinitions().get(1)).getColumnName());
assertEquals("PRIMARY KEY", ((Index) createTable.getIndexes().get(0)).getType());
assertEquals("mycol", ((Index) createTable.getIndexes().get(0)).getColumnsNames().get(1));
assertEquals(statement, ""+createTable);
}