日期:2014-05-20 浏览次数:20840 次
String[] columns = [NAME,CLASS_ID]; String[] columnsType=[VARCHAR2,INT]; sqlEndbBuffer.append("create or replace table "+tableN+"( "); labela: for(int i=0;i<columns.length;i++){ sqlEndbBuffer.append(columns[i]+" "); for(int j=0;j<columnsType.length;j++){ sqlEndbBuffer.append(columnsType[j]); break labela; } if (i == columnsType.length - 1) { sqlEndbBuffer.append(""); } else { sqlEndbBuffer.append(","); } } sqlEndbBuffer.append(" )"); System.out.println("New SQL==="+sqlEndbBuffer.toString());
String[] columns = [NAME,CLASS_ID]; String[] columnsType=[VARCHAR2,INT]; sqlEndbBuffer.append("create or replace table "+tableN+"( "); labela: for(int i=0;i<columns.length;i++){ sqlEndbBuffer.append(columns[i]+" "+columnsType[i]); if (i == columns.length - 1) { sqlEndbBuffer.append(""); } else { sqlEndbBuffer.append(","); } } sqlEndbBuffer.append(" )"); System.out.println("New SQL==="+sqlEndbBuffer.toString());
------解决方案--------------------
int j=0;
labela:
for(int i=0;i<columns.length;i++){
sqlEndbBuffer.append(columns[i]+" ");
labelb:
for(int a=j;a<columnsType.length;a++){
sqlEndbBuffer.append(columnsType[a]);
j++;
break labelb;
}
if (i == columnsType.length - 1) {
sqlEndbBuffer.append("");
} else {
sqlEndbBuffer.append(",");
}
}
------解决方案--------------------
String[] columns = [NAME,CLASS_ID]; String[] columnsType=[VARCHAR2,INT]; sqlEndbBuffer.append("create or replace table "+tableN+"( "); for(int i=0;i<columns.length;i++){ sqlEndbBuffer.append(columns[i]+" "); for(int j=0;j<columnsType.length;j++){ sqlEndbBuffer.append(columnsType[j]); break; } break; if (i == columnsType.length - 1) { sqlEndbBuffer.append(""); } else { sqlEndbBuffer.append(","); } } sqlEndbBuffer.append(" )"); System.out.println("New SQL==="+sqlEndbBuffer.toString());
------解决方案--------------------
break 只能跳出最近一个代码循环块
彻底退出 只能用return
所以 楼主可以用一些标志
------解决方案--------------------