protected void createIndex(Statement sth, boolean unique, boolean btree, String iName, String table, String columns) { String sql = "CREATE " + (unique ? "UNIQUE" : "" ) + " INDEX " + iName + (btree ? " USING BTREE" : "") + " ON "+table+ "("+columns+")"; log().t(sql); try { sth.execute(sql.toString()); } catch (Exception e) { log().i(sql,e); } }
protected void alterColumnAdd(Statement sth, String tn, IConfig cfield) { // String sql = "ALTER TABLE " + tn + " ADD COLUMN (" + getFieldConfig(cfield) + ")"; String sql = "ALTER TABLE " + tn + " ADD COLUMN " + getFieldConfig(cfield); log().d("alter table",sql); try { sth.execute(sql); } catch (Exception e) { log().i(sql,e); } }
protected void recreateIndex(Statement sth, boolean unique, boolean btree, String iName, String table, String columns) { String sql = "DROP INDEX " + iName + " ON " + table; log().t(sql); try { sth.execute(sql.toString()); } catch (Exception e) { log().i(sql,e); } sql = "CREATE " + (unique ? "UNIQUE" : "" ) + " INDEX " + iName + (btree ? " USING BTREE" : "") + " ON "+table+ "("+columns+")"; log().t(sql); try { sth.execute(sql.toString()); } catch (Exception e) { log().i(sql,e); } }
protected void alterColumnSetDefault(Statement sth, String tn, String fName, IConfig cfield) { String sql = null; try { sql = "ALTER TABLE " + tn + " ALTER COLUMN " + fName + " SET DEFAULT " + getDbDef(cfield.getString("default",null)); log().d("alter table",sql); sth.execute(sql); } catch (Exception e) { log().i(sql,e); } }
protected void createTable(Statement sth, String tn, IConfig ctable) { StringBuilder sql = new StringBuilder(); sql.append("create table " + tn + " ( "); boolean first = true; for (IConfig f:ctable.getNodes("field")) { if (!first) sql.append(","); sql.append(getFieldConfig(f)); first = false; } sql.append(" )"); createTableLastCheck(ctable, tn, sql); log().d(sql); try { sth.execute(sql.toString()); } catch (Exception e) { log().i(sql,e); } }
boolean foundError = false; if (select != null) { log().t("select",select); try { ResultSet res = sth.executeQuery(select); log().i(select,e); foundError = true; String sql = cexecute.getExtracted("sql"); if(sql != null) { log().t("execute",sql); try { sth.execute(sql.toString()); } catch (Exception e) { log().i(sql,e);
log().t("table",tnOrg); String tn = normalizeTableName(tnOrg); log().t("--- found table",tName); log().t("field",tName,fNameOrg); if (fRes.next()) { String fName2 = fRes.getString("COLUMN_NAME"); int fNull = fRes.getInt("NULLABLE"); String fDef = fRes.getString("COLUMN_DEF"); log().t("found field",tName,fName2,fType,fSize,fNull,fDef); log().t("*** found more then one table",tName); String fName2 = fRes.getString("COLUMN_NAME"); if (!fieldsInTable.contains(fName2)) { log().t("remove column", fName2); alterColumnDrop(sth,tn,fName2); log().t("--- table not found",tName); log().t("found primary key",keys2); if (keys==null) { alterTableDropPrimaryKey(sth,tn);
String name = "db." + manager.getMappingName(c) + "." + ((ADbAttribute)p).getAttribute(); if (manager.getNameMapping().get(name) == null) log().w("mapping not exist",name); buffer.append("$").append(name).append('$'); } else