在java里,用ResultSetMetaData类的getColumnName(int i)可以得到列名desc area_table ?你要把这个表倒序排?
解决方案 »
- 求教,用AWT写了一个抽奖的程序,导出成jar 在别的机器运行的时候,界面响应变慢。
- ArrayList里居然可以放float[],大赞:)
- List如何进行元素相加
- MyEclipse连接上Oracle后查看Oracle里表的问题
- pageContext.findAttribute(name);为空
- 小菜请教窗口切换问题,高手指点~~如何让弹出对话框像"打开","保存"一样始终浮于顶端
- about jar
- 明天到北京国创科技有限公司笔试应聘java软件工程师,给点建议高分回报!!!!在线等待!!
- 多线程怎么传递参数并得出返回值?
- 寻找对象定义所在对象
- 能不能仅用jdk做企业级的corba应用?为什么?
- 使用java时间的调查,谢谢大家
desc area_table 是显示table的结构。
ResultSet rs = stmt.exeQuery("select * from area_talbe");//stmt 是statement对象。
ResultSetMetaData rsmd = rs.getMetaData();
int numCols = rsmd.getColumnCount(); //get the number of columns
for ( int i =1;i<=numCols;i++){
if (i>1) System.out.print(",");
System.out.print(rsmd.getColumnLabel(i));//显示每个列的标题
}
System.out.println(""); }
public String getColumnName(int column) throws SQLException**Get the designated column's name.方法:getColumnLabel
public String getColumnLabel(int column) throws SQLException**Gets the designated column's suggested title for use in printouts and displays.如果是要显示你的中文列名,用getColumnLabel;
如果要根据列名来取数据,用getColumnName。另:to pang:
desc area_table 是哪里的用法?
desc命令在oracle和sqlserver都可。是标准的sql文。
后接表名。用来显示表的结构。
其他的数据库,我就不知道了!
SQL_SEL_FIELDS = "SELECT * FROM DBA_TAB_COLUMNS WHERE TABLE_NAME = '" + DbName.toUpperCase() +"' ORDER BY COLUMN_ID";
原来如此,我只晓得有describe,不晓得还可以缩写的,还以为是descending呢,呵呵
不知道sysbase里有没有这种表?
用上面的语句可以读出某一个表的所有列名
public int getColumnType(int column)
throws SQLException
Retrieves the designated column's SQL type.
Parameters:
column - the first column is 1, the second is 2, ...
Returns:
SQL type from java.sql.Types
Throws:
SQLException - if a database access error occurs
See Also:
Types--------------------------------------------------------------------------------getColumnTypeName
public String getColumnTypeName(int column)
throws SQLException
Retrieves the designated column's database-specific type name.
Parameters:
column - the first column is 1, the second is 2, ...
Returns:
type name used by the database. If the column type is a user-defined type, then a fully-qualified type name is returned.
Throws:
SQLException - if a database access error occurs