I am using JTable to display the result of a query. Table does not show as XYZ
for all columns but it shows XYZ
as a header for the fields not existing in database(manipulated fields).
我正在使用JTable显示查询的结果。表不显示所有列的XYZ,但是它显示的XYZ是数据库中不存在的字段的头(被操作的字段)。
Don't know much of database internals.Please forgive if it's too basic.
不了解数据库内部。如果太基本,请原谅。
rs1 = st1.executeQuery("SELECT product.`id` as `Product ID`,product.`serialnumber` as `Serial Number`, product.`dop` as `Date Of Purchase` FROM product where product.`dop` between '"+from+"' and '"+to+"'");
reportTable.setModel(buildTableModel(rs1));
same query on query browser Output:
查询浏览器输出相同查询:
Product ID Serial Number Date Of Purchase
1 123244mf43m 08/08/2013
My Output With JDBC is:
我对JDBC的输出是:
id serialnumber dop //table header
1 123244mf43m 08/08/2013
1 个解决方案
#1
3
There is a configuration setting described here:
这里描述了一个配置设置:
http://dev.mysql.com/doc/refman/5.1/en/connector-j-reference-configuration-properties.html
http://dev.mysql.com/doc/refman/5.1/en/connector-j-reference-configuration-properties.html
useOldAliasMetadataBehavior
which, if set to true (the default in 5.0.x) will only return aliases (if any) for ResultSetMetaData.getColumnName() or ResultSetMetaData.getTableName() rather than the original column/table name.
如果将其设置为true (5.0.x中的默认值),则只返回ResultSetMetaData.getColumnName()或ResultSetMetaData.getTableName()的别名(如果有的话),而不是原始的列/表名。
Not sure if this is applicable to you, but could be the cause.
不确定这是否适用于你,但可能是原因。
#1
3
There is a configuration setting described here:
这里描述了一个配置设置:
http://dev.mysql.com/doc/refman/5.1/en/connector-j-reference-configuration-properties.html
http://dev.mysql.com/doc/refman/5.1/en/connector-j-reference-configuration-properties.html
useOldAliasMetadataBehavior
which, if set to true (the default in 5.0.x) will only return aliases (if any) for ResultSetMetaData.getColumnName() or ResultSetMetaData.getTableName() rather than the original column/table name.
如果将其设置为true (5.0.x中的默认值),则只返回ResultSetMetaData.getColumnName()或ResultSetMetaData.getTableName()的别名(如果有的话),而不是原始的列/表名。
Not sure if this is applicable to you, but could be the cause.
不确定这是否适用于你,但可能是原因。