提交 a01c023e authored 作者: Thomas Mueller's avatar Thomas Mueller

The H2 Console tool now works with the JDBC-ODBC bridge.

上级 8d88e36a
......@@ -28,19 +28,12 @@ class DbColumn {
String dataType;
DbColumn(ResultSet rs) throws SQLException {
int indexColumnSize = 7;
try {
indexColumnSize = rs.findColumn("COLUMN_NAME");
} catch (SQLException e) {
// ignore
// workaround for a JDBC-ODBC bridge problem
}
name = rs.getString("COLUMN_NAME");
String type = rs.getString("TYPE_NAME");
int size = rs.getInt(indexColumnSize);
int size = rs.getInt(DbContents.findColumn(rs, "COLUMN_SIZE", 7));
if (size > 0) {
type += "(" + size;
int prec = rs.getInt("DECIMAL_DIGITS");
int prec = rs.getInt(DbContents.findColumn(rs, "DECIMAL_DIGITS", 9));
if (prec > 0) {
type += ", " + prec;
}
......
......@@ -64,6 +64,24 @@ public class DbContents {
* True if this is an SQLite database.
*/
boolean isSQLite;
/**
* Get the column index of a column in a result set. If the column is not
* found, the default column index is returned.
* This is a workaround for a JDBC-ODBC bridge problem.
*
* @param rs the result set
* @param columnName the column name
* @param defaultColumnIndex the default column index
* @return the column index
*/
static int findColumn(ResultSet rs, String columnName, int defaultColumnIndex) {
try {
return rs.findColumn(columnName);
} catch (SQLException e) {
return defaultColumnIndex;
}
}
/**
* Read the contents of this database from the database meta data.
......@@ -122,15 +140,8 @@ public class DbContents {
}
ResultSet rs = meta.getSchemas();
ArrayList schemas = new ArrayList();
int index = 1;
try {
index = rs.findColumn("TABLE_SCHEM");
} catch (SQLException e) {
// ignore
// workaround for a JDBC-ODBC bridge problem
}
while (rs.next()) {
String schema = rs.getString(index);
String schema = rs.getString(findColumn(rs, "TABLE_SCHEM", 1));
if (schema == null) {
continue;
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论