pessoal. achei o problema… segue abaixo
Fontes:
http://www.jasperforge.org/sf/go/artf1368;jsessionid=A1AC30201F695A95B3A09CFB99152AD7?nav=1
http://www.mail-archive.com/jasperreports-questions@lists.sourceforge.net/msg00276.html
Artifact artf1368 : Exception in JRResultSetDataSource if ResultSet uses alias
Tracker: Bugs
Title: Exception in JRResultSetDataSource if ResultSet uses alias
Description: Original issue moved from:
https://sourceforge.net/tracker/index.php?func=detail&aid=1504871&group_id=36382&atid=416703
Consult the original issue for any attachments.
[ 1504871 ] Exception in JRResultSetDataSource if ResultSet uses alias
Submitted By: Todd Wohlers - twohlers
Date Submitted: 2006-06-12 09:20
Last Updated By: code_slave - Comment added
Date Last Updated: 2006-06-19 01:54
Number of Comments: 2
Number of Attachments: 0
Assigned To: Nobody/Anonymous
Priority: 5
Summary:
Exception in JRResultSetDataSource if ResultSet uses alias
jasperreports-1.2.3.jar mysql-connector-5.0.0-beta.jar
If the sql query in a .jrxml uses an alias, JRResultSetDataSource throws an exception (see below).
I think it is the same problem as http://sourceforge.net/tracker/index.php?
func=detail&aid=1493302&group_id=36382&atid=416703, but it appears to still be broken in jasperreports- 1.2.3.jar
I created a mysql bug first because this error did not occur with earlier versions of the mysql-connect and this is the
response I got:
This was changed due to clarification by the JDBC experts’ group as to what
really is a column name (it’s the actual name, not the alias or label). Quoting
from the CHANGES file for 5.0.0:
“Return original column name for RSMD.getColumnName()
if the column was aliased,
alias name for .getColumnLabel() (if aliased), and
original table name for
.getTableName(). Note this only works for MySQL-4.1
and newer, as older servers
don’t make this information available to clients.”
Solution:
file:
net/sf/jasperreports/engine/JRResultSetDataSource.java
line: 335
was:
if (fieldName.equalsIgnoreCase
(metadata.getColumnName(i)))
SHOULD BE:
if (fieldName.equalsIgnoreCase
(metadata.getColumnLabel(i)))
String sql = “SELECT COUNT(*) AS EVT_COUNT FROM
event”;
ResultSet rset = db.executeQuery(sql);
JasperPrint jasperPrint = JasperFillManager.fillReport (reportFile, new HashMap(), new JRResultSetDataSource
(rset));
11:40:18,029 ERROR JasperReportEngine:103 - Error
net.sf.jasperreports.engine.JRException: Unknown
column name : EVT_COUNT
at
net.sf.jasperreports.engine.JRResultSetDataSource.getC
olumnIndex(JRResultSetDataSource.java:357)
at
net.sf.jasperreports.engine.JRResultSetDataSource.getF
ieldValue(JRResultSetDataSource.java:113)
at
net.sf.jasperreports.engine.fill.JRFillDataset.next
(JRFillDataset.java:727)
at
net.sf.jasperreports.engine.fill.JRBaseFiller.next
(JRBaseFiller.java:987)
at
net.sf.jasperreports.engine.fill.JRVerticalFiller.fill
Report(JRVerticalFiller.java:126)
at
net.sf.jasperreports.engine.fill.JRBaseFiller.fill
(JRBaseFiller.java:750)
at
net.sf.jasperreports.engine.fill.JRBaseFiller.fill
(JRBaseFiller.java:647)
at
net.sf.jasperreports.engine.fill.JRFiller.fillReport
(JRFiller.java:63)
at
net.sf.jasperreports.engine.JasperFillManager.fillRepo
rt(JasperFillManager.java:402)
Add a Comment:
DO NOT enter passwords or other confidential information!
Followups:
Comments
Date: 2006-06-19 01:54
Sender: code_slaveAccepting Donations
Logged In: YES
user_id=413743
looks like this has been going on for years:
http://archives.postgresql.org/pgsql-jdbc/2004-08/msg00015.php
Date: 2006-06-13 03:23
Sender: teodordProject Admin
Logged In: YES
user_id=332465
Hi,
I’m afraid we cannot make this modification because I’m sure many JDBC driver implementations out there did not took
into account such a “clarification by the JDBC experts’ group” and still rely on getColumnName() only. I guess this is
the case with older MySQL drivers as well.
So the only solution would be to use a configurable property somewhere to turn this ON and OFF.
Thank you,
Teodor