columns.getString("COLUMN_NAME");
和
columns.getString("REMARKS");不是同一列你是否可以把你SQL写出来
和
columns.getString("REMARKS");不是同一列你是否可以把你SQL写出来
解决方案 »
- 【请教】Struts2交给Spring管理后 出现的问题
- 看看我hql时间比较哪里有问题?
- Struts2.0 + Spring2.0 + Hibernate3.1的整合的例子(急急急)
- JAVA 调用 .NET写的WEB SERVICE的问题(SOAP头验证)
- 请高手看看,这是spring 的什么异常,为什么不能运行
- dom4j中转换xml的简单问题,都有分!
- 谁的英语好啊 求一段英文摘要
- 在java里面向oracle数据库中插入数据类型是date的值,应该如何写?
- 本人有一个安例,但不知道用什么技术可实现!
- 一个文件中有两个类,一个类初始化,我想调用一个类中的方法,他又跳回初始化,怎么可以不经过初始化,就调用类里面的方法
- 请问,有没有基于wfmc标准的java工作流图形化定制工具可以下载的?
- 一个严重的Timer问题!!!
//dbMetaData是由Connection得到的一个DatabaseMetaData,"table"
//是数据库中一张表的名字
ResultSet columns = dbMetaData.getColumns(null,
dbMetaData.getUserName(),
"table",
"%");
while(columns.next()){
//COLUMN_NAME和REMARKS是参考j2sdk文档上给出的列名
System.out.println(columns.getString("COLUMN_NAME")+":"
+columns.getString("REMARKS"));
}运行后,能得到列名,但是没有得到该列的comment。api文档:
getColumns
public ResultSet getColumns(String catalog,
String schemaPattern,
String tableNamePattern,
String columnNamePattern)
throws SQLException
Retrieves a description of table columns available in the specified catalog.
Only column descriptions matching the catalog, schema, table and column name criteria are returned. They are ordered by TABLE_SCHEM, TABLE_NAME, and ORDINAL_POSITION. Each column description has the following columns: 1.TABLE_CAT String => table catalog (may be null)
2.TABLE_SCHEM String => table schema (may be null)
3.TABLE_NAME String => table name
4.COLUMN_NAME String => column name
5.DATA_TYPE int => SQL type from java.sql.Types
6.TYPE_NAME String => Data source dependent type name, for a UDT the type name is
fully qualified
7.COLUMN_SIZE int => column size. For char or date types this is the maximum
number of characters, for numeric or decimal types this is precision.
8.BUFFER_LENGTH is not used.
9.DECIMAL_DIGITS int => the number of fractional digits
10.NUM_PREC_RADIX int => Radix (typically either 10 or 2)
11.NULLABLE int => is NULL allowed.
*columnNoNulls - might not allow NULL values
*columnNullable - definitely allows NULL values
*columnNullableUnknown - nullability unknown
12.REMARKS String => comment describing column (may be null)
13.COLUMN_DEF String => default value (may be null)
...................
public String getString(String columnName)
throws SQLExceptionRetrieves the value of the designated column in the current row of this ResultSet object as a String in the Java programming language. Parameters:
columnName - the SQL name of the column
Returns:
the column value; if the value is SQL NULL, the value returned is null
Throws:
SQLException - if a database access error occurs请问楼主是否将ResultSet.getString(String columnName) 改写了,还是楼主的
ResultSet自己重新写了
String schemaPattern,
String tableNamePattern,
String columnNamePattern)
中的解释呢?
其实楼主的意思是:
public ResultSet getColumns(String catalog,
String schemaPattern,
String tableNamePattern,
String columnNamePattern)
throws SQLException
返回一个ResultSet,该ResultSet有Column_Name,res,TABLE_CAT等字段
所以用columns.getString("COLUMN_NAME")+":"+columns.getString("REMARKS")是可以的啊。
只是columns.getString("REMARKS")的值一直是null