求教:sql包中用什么方法可显示一个数据库中的所有表的名称? DatabaseMetaData肯定可以,java doc中有详细介绍,自己看一下,不断的测试,肯定可以的。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 agree with yipsilon(J3EE研究者), should be ResultSetMetaData,for example (http://groups.google.com/groups?q=ResultSetMetaData+java+example&hl=en&lr=&ie=UTF8&oe=UTF8&selm=000006ed.069efd8d%40usw-ex0108-190.remarq.com&rnum=8)static void dumpResultSet (ResultSet cursor) throws SQLException { ResultSetMetaData cursorDesc = cursor.getMetaData(); int colCount = cursorDesc.getColumnCount(); String [][] tagPairs = getTags (cursorDesc); while (cursor.next ()) { System.out.println ("<Row>"); for (int i = 0; i < colCount; ++i) { System.out.print (" "); // indent is really optional System.out.print (tagPairs [i] [0]); String value = cursor.getString (i + 1);// should really translate (& => &) and (< => <) System.out.print (value); System.out.println (tagPairs [i] [1]); } System.out.println ("</Row>"); } } static String [][] getTags ( ResultSetMetaData cursorDesc) throws SQLException { int colCount = cursorDesc.getColumnCount(); String [][] result = new String [colCount][]; for (int i = 0; i < colCount; ++i) { String [] tagPair = new String [2]; // warning: not every col label is a valid XML identifier String colName = cursorDesc.getColumnName(i + 1); if (true) { // similar to Oracle's XSQL: <COLNAME> tagPair [0] = "<" + colName + ">"; tagPair [1] = "</" + colName + ">"; } else { // choose this one if you want a stable DTD: <Valuename="COLNAME"> tagPair [0] = "<Value name=\"" + colName + "\">"; tagPair [1] = "</Value>"; } result [i] = tagPair; } return result; } 请教 JTable 里的单元格如何使得双击进入单元格后,单元格的内容处于全选中状态 Socket数据的显示,在线等!!! File 和FileReader有什么区别 关于数据库中的数据类型转换的问题 请问如何在界面上设置按钮,并且定义按钮的位置以及做出响应? revalidate()、validate()、repaint()三个方法各有什么用啊? java初学者关于java的概念问题! 请问高手~~~~谢谢来者! 春节好 如何自定义一个对话框,然后在Applet中弹出该对话框(模式) 数据库操作只一次? 有没有关于如何发布Entity Bean的例子?
{
ResultSetMetaData cursorDesc = cursor.getMetaData();
int colCount = cursorDesc.getColumnCount();
String [][] tagPairs = getTags (cursorDesc); while (cursor.next ()) {
System.out.println ("<Row>");
for (int i = 0; i < colCount; ++i) {
System.out.print (" "); // indent is really optional
System.out.print (tagPairs [i] [0]);
String value = cursor.getString (i + 1);
// should really translate (& => &) and (< => <)
System.out.print (value);
System.out.println (tagPairs [i] [1]);
}
System.out.println ("</Row>");
}
} static String [][] getTags (
ResultSetMetaData cursorDesc)
throws SQLException
{
int colCount = cursorDesc.getColumnCount();
String [][] result = new String [colCount][];
for (int i = 0; i < colCount; ++i) {
String [] tagPair = new String [2];
// warning: not every col label is a valid XML identifier
String colName = cursorDesc.getColumnName(i + 1);
if (true) {
// similar to Oracle's XSQL: <COLNAME>
tagPair [0] = "<" + colName + ">";
tagPair [1] = "</" + colName + ">";
}
else {
// choose this one if you want a stable DTD: <Value
name="COLNAME">
tagPair [0] = "<Value name=\"" + colName + "\">";
tagPair [1] = "</Value>";
}
result [i] = tagPair;
}
return result;
}