提交 7b6e894f authored 作者: Thomas Mueller's avatar Thomas Mueller

H2 Console: the tables and columns are now listed for SQLite as well.

上级 1bcaf237
...@@ -27,11 +27,11 @@ class DbColumn { ...@@ -27,11 +27,11 @@ class DbColumn {
*/ */
String dataType; String dataType;
DbColumn(ResultSet rs) throws SQLException { DbColumn(ResultSet rs, boolean isSQLite) throws SQLException {
name = rs.getString("COLUMN_NAME"); name = rs.getString("COLUMN_NAME");
String type = rs.getString("TYPE_NAME"); String type = rs.getString("TYPE_NAME");
int size = rs.getInt(DbContents.findColumn(rs, "COLUMN_SIZE", 7)); int size = rs.getInt(DbContents.findColumn(rs, "COLUMN_SIZE", 7));
if (size > 0) { if (size > 0 && !isSQLite) {
type += "(" + size; type += "(" + size;
int prec = rs.getInt(DbContents.findColumn(rs, "DECIMAL_DIGITS", 9)); int prec = rs.getInt(DbContents.findColumn(rs, "DECIMAL_DIGITS", 9));
if (prec > 0) { if (prec > 0) {
......
...@@ -158,7 +158,7 @@ public class DbContents { ...@@ -158,7 +158,7 @@ public class DbContents {
} }
private String[] getSchemaNames(DatabaseMetaData meta) throws SQLException { private String[] getSchemaNames(DatabaseMetaData meta) throws SQLException {
if (isMySQL) { if (isMySQL || isSQLite) {
return new String[] { "" }; return new String[] { "" };
} else if (isFirebird) { } else if (isFirebird) {
return new String[] { null }; return new String[] { null };
......
...@@ -60,7 +60,7 @@ public class DbTableOrView { ...@@ -60,7 +60,7 @@ public class DbTableOrView {
ResultSet rs = meta.getColumns(null, schema.name, name, null); ResultSet rs = meta.getColumns(null, schema.name, name, null);
ArrayList<DbColumn> list = New.arrayList(); ArrayList<DbColumn> list = New.arrayList();
while (rs.next()) { while (rs.next()) {
DbColumn column = new DbColumn(rs); DbColumn column = new DbColumn(rs, schema.contents.isSQLite);
list.add(column); list.add(column);
} }
rs.close(); rs.close();
......
...@@ -511,7 +511,13 @@ public class WebApp { ...@@ -511,7 +511,13 @@ public class WebApp {
private int addIndexes(boolean mainSchema, DatabaseMetaData meta, String table, String schema, StringBuilder buff, int treeIndex) private int addIndexes(boolean mainSchema, DatabaseMetaData meta, String table, String schema, StringBuilder buff, int treeIndex)
throws SQLException { throws SQLException {
ResultSet rs = meta.getIndexInfo(null, schema, table, false, true); ResultSet rs;
try {
rs = meta.getIndexInfo(null, schema, table, false, true);
} catch (SQLException e) {
// SQLite
return treeIndex;
}
HashMap<String, IndexInfo> indexMap = New.hashMap(); HashMap<String, IndexInfo> indexMap = New.hashMap();
while (rs.next()) { while (rs.next()) {
String name = rs.getString("INDEX_NAME"); String name = rs.getString("INDEX_NAME");
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论