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


Java CreateTable类代码示例

本文整理汇总了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());
}
 
开发者ID:olavloite,项目名称:spanner-jdbc,代码行数:17,代码来源:CloudSpannerPreparedStatementTest.java

示例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);

}
 
开发者ID:bigdataFlySQL,项目名称:SQLonStorm,代码行数:22,代码来源:Global.java

示例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);
    }
}
 
开发者ID:kawasima,项目名称:enkan,代码行数:11,代码来源:ScaffoldCommandRegister.java

示例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();
}
 
开发者ID:zbd1023,项目名称:512DB,代码行数:15,代码来源:SQLLayer.java

示例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);
    }
}
 
开发者ID:WeiMei-Tian,项目名称:editor-sql,代码行数:8,代码来源:TablesNamesFinder.java

示例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);
    }
}
 
开发者ID:justice-code,项目名称:QiuQiu,代码行数:8,代码来源:ReplaceTablesNamesFinder.java

示例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;
}
 
开发者ID:diennea,项目名称:herddb,代码行数:31,代码来源:SQLPlanner.java

示例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);
        }
    }
}
 
开发者ID:diennea,项目名称:herddb,代码行数:13,代码来源:JdbcQueryRewriter.java

示例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);
}
 
开发者ID:Wolfgang-Winter,项目名称:cibet,代码行数:9,代码来源:SqlParser.java

示例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);

    }
}
 
开发者ID:jadetang,项目名称:maliang,代码行数:16,代码来源:JavaDataBaseRelationBuilder.java

示例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;
}
 
开发者ID:jadetang,项目名称:maliang,代码行数:12,代码来源:JavaDataBaseRelationBuilder.java

示例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();
}
 
开发者ID:jadetang,项目名称:maliang,代码行数:9,代码来源:JavaDataBaseRelationBuilder.java

示例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;
}
 
开发者ID:jadetang,项目名称:maliang,代码行数:9,代码来源:JavaDataBaseRelationBuilder.java

示例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);
    }
}
 
开发者ID:sogou-biztech,项目名称:compass,代码行数:11,代码来源:TableRenameVisitor.java

示例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);
}
 
开发者ID:UBOdin,项目名称:jsqlparser,代码行数:13,代码来源:CreateTableTest.java


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