我自己是这样写的但取不到
Connection con = DriverManager.getConnection(d.getUrl(), d
.getDbuser(), d.getDbpwd());
String[] type=new String[1];
type[0]="TABLES";
ResultSet rs = con.getMetaData().getTables(null,null,“%”,null);
11 个解决方案
#1
ResultSet rs = con.getMetaData().getTables(null,null,"",null);
OK!
OK!
#2
ResultSet rs = con.getMetaData().getTables(null,null,"",null);
我试了,这样也不行,其得到的resultSet是空的!
我试了,这样也不行,其得到的resultSet是空的!
#3
我就是这样获得的呀,你的什么数据库呀?
#4
我用的是DERBY
#5
ResultSet rs = con.getMetaData().getTables(null,null,"",null);
while(rs.next())
(rs.getString(0));
while(rs.next())
(rs.getString(0));
#6
ResultSet rs = con.getMetaData().getTables(null,null,"",null);
while(rs.next())
log.debug(rs.getString(0));
会出现out off Index的异常。
while(rs.next())
log.debug(rs.getString(0));
会出现out off Index的异常。
#7
什么数据库
如果是SQL2000,那么每个数据库里面都有一个sysobjects表,然后再判断一个
select就行了,
如果是Oracle这个我不是太清楚
谢谢
如果是SQL2000,那么每个数据库里面都有一个sysobjects表,然后再判断一个
select就行了,
如果是Oracle这个我不是太清楚
谢谢
#8
DatabaseMetaData dmd = conn.getMetaData();
String[] types = {"TABLE"};
ResultSet rs = dmd.getTables(null, null, "%", types);
while(rs.next()){
System.out.println(rs.getString(3));
}
rs.close();
1 TABLE_CAT String => table catalog (may be null)
2 TABLE_SCHEM String => table schema (may be null)
3 TABLE_NAME String => table name
……
注意返回rs的列顺序,具体看帮助!
String[] types = {"TABLE"};
ResultSet rs = dmd.getTables(null, null, "%", types);
while(rs.next()){
System.out.println(rs.getString(3));
}
rs.close();
1 TABLE_CAT String => table catalog (may be null)
2 TABLE_SCHEM String => table schema (may be null)
3 TABLE_NAME String => table name
……
注意返回rs的列顺序,具体看帮助!
#9
while(rs.next())
log.debug(rs.getString(0));//从1开始编号的呀!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
会出现out off Index的异常。
log.debug(rs.getString(0));//从1开始编号的呀!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
会出现out off Index的异常。
#10
回答的很好.
SQL 里面都从 1 开始.
SQL 里面都从 1 开始.
#11
我爱花猫的是正解
#1
ResultSet rs = con.getMetaData().getTables(null,null,"",null);
OK!
OK!
#2
ResultSet rs = con.getMetaData().getTables(null,null,"",null);
我试了,这样也不行,其得到的resultSet是空的!
我试了,这样也不行,其得到的resultSet是空的!
#3
我就是这样获得的呀,你的什么数据库呀?
#4
我用的是DERBY
#5
ResultSet rs = con.getMetaData().getTables(null,null,"",null);
while(rs.next())
(rs.getString(0));
while(rs.next())
(rs.getString(0));
#6
ResultSet rs = con.getMetaData().getTables(null,null,"",null);
while(rs.next())
log.debug(rs.getString(0));
会出现out off Index的异常。
while(rs.next())
log.debug(rs.getString(0));
会出现out off Index的异常。
#7
什么数据库
如果是SQL2000,那么每个数据库里面都有一个sysobjects表,然后再判断一个
select就行了,
如果是Oracle这个我不是太清楚
谢谢
如果是SQL2000,那么每个数据库里面都有一个sysobjects表,然后再判断一个
select就行了,
如果是Oracle这个我不是太清楚
谢谢
#8
DatabaseMetaData dmd = conn.getMetaData();
String[] types = {"TABLE"};
ResultSet rs = dmd.getTables(null, null, "%", types);
while(rs.next()){
System.out.println(rs.getString(3));
}
rs.close();
1 TABLE_CAT String => table catalog (may be null)
2 TABLE_SCHEM String => table schema (may be null)
3 TABLE_NAME String => table name
……
注意返回rs的列顺序,具体看帮助!
String[] types = {"TABLE"};
ResultSet rs = dmd.getTables(null, null, "%", types);
while(rs.next()){
System.out.println(rs.getString(3));
}
rs.close();
1 TABLE_CAT String => table catalog (may be null)
2 TABLE_SCHEM String => table schema (may be null)
3 TABLE_NAME String => table name
……
注意返回rs的列顺序,具体看帮助!
#9
while(rs.next())
log.debug(rs.getString(0));//从1开始编号的呀!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
会出现out off Index的异常。
log.debug(rs.getString(0));//从1开始编号的呀!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
会出现out off Index的异常。
#10
回答的很好.
SQL 里面都从 1 开始.
SQL 里面都从 1 开始.
#11
我爱花猫的是正解