Skip to content

Commit

Permalink
fixed issue alibaba#16 , optimizer open cursors
Browse files Browse the repository at this point in the history
  • Loading branch information
agapple committed Jun 22, 2016
1 parent c265918 commit ce5ac2c
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public Object doInConnection(Connection conn) throws SQLException, DataAccessExc
break;
}
}
rs.close();

if (table == null) {
throw new YuGongException("table[" + schemaName + "." + tableName + "] is not found");
Expand All @@ -92,6 +93,7 @@ public Object doInConnection(Connection conn) throws SQLException, DataAccessExc
columnList.add(col);
}
}
rs.close();

// 查询主键信息
List<String> primaryKeys = new ArrayList<String>();
Expand All @@ -105,6 +107,7 @@ public Object doInConnection(Connection conn) throws SQLException, DataAccessExc
primaryKeys.add(StringUtils.upperCase(rs.getString(4)));
}
}
rs.close();

List<String> uniqueKeys = new ArrayList<String>();
if (primaryKeys.isEmpty()) {
Expand All @@ -130,6 +133,7 @@ public Object doInConnection(Connection conn) throws SQLException, DataAccessExc
uniqueKeys.add(StringUtils.upperCase(rs.getString(9)));
}
}
rs.close();

// 如果无主键,使用唯一键
primaryKeys.addAll(uniqueKeys);
Expand Down Expand Up @@ -187,6 +191,7 @@ public Object doInConnection(Connection conn) throws SQLException, DataAccessExc
}
}

rs.close();
stmt.close();
return result;
} else {
Expand All @@ -202,6 +207,8 @@ public Object doInConnection(Connection conn) throws SQLException, DataAccessExc
result.add(table);
}
}

rs.close();
return result;
}
}
Expand Down Expand Up @@ -232,6 +239,8 @@ public Object doInConnection(Connection conn) throws SQLException, DataAccessExc
indexes.put(columnName, indexName);
}
}

rs.close();
return indexes;
}
});
Expand Down Expand Up @@ -268,6 +277,8 @@ public Object doInPreparedStatement(PreparedStatement ps) throws SQLException, D
if (rs.next()) {
log = rs.getString("log_table");
}

rs.close();
return log;
}
});
Expand Down Expand Up @@ -299,6 +310,7 @@ public Object doInConnection(Connection conn) throws SQLException, DataAccessExc
columnList.add(col);
}
}
rs.close();

// 查询主键信息
rs = metaData.getPrimaryKeys(table.getSchema(), table.getSchema(), table.getName());
Expand All @@ -313,6 +325,7 @@ public Object doInConnection(Connection conn) throws SQLException, DataAccessExc
primaryKeys.add(rs.getString(4));
}
}
rs.close();

Set<ColumnMeta> columns = new HashSet<ColumnMeta>();
Set<ColumnMeta> pks = new HashSet<ColumnMeta>();
Expand Down Expand Up @@ -357,6 +370,8 @@ public Object doInPreparedStatement(PreparedStatement ps) throws SQLException, D
if (rs.next()) {
log = rs.getString("KEYS");
}

rs.close();
return log;
}
});
Expand Down

0 comments on commit ce5ac2c

Please sign in to comment.