首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2SE开发 >

高手!

2012-04-18 
高手!求助!!!我的问题是:下边是我的部分代码:Java codepackage yinshuaimport java.awt.Colorimport jav

高手!求助!!!
我的问题是:
下边是我的部分代码:

Java code
package yinshua;import java.awt.Color;import java.awt.Font;import java.io.File;import java.io.FileInputStream;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Statement;import javax.swing.JTable;import org.xml.sax.SAXParseException;import com.fr.base.Constants;import com.fr.base.FRContext;import com.fr.base.FRFont;import com.fr.base.Style;import com.fr.data.DatasourceManager;import com.fr.report.CellElement;import com.fr.report.Report;import com.fr.report.io.TemplateImporter;import com.fr.view.PreviewFrame;public class CpcAllPrint {    public  CpcAllPrint(String sql0,String table1) throws SQLException{        File cptFile = new File("d:\\report\\cpcall.cpt");//这是你生成的那个模板的存放路径        try {          try{            TemplateImporter templateImporter = new TemplateImporter(cptFile);            Report workSheet = templateImporter.generateReport();                     Statement rst1=Sqlconn.getStatement();                ResultSet ab1=rst1.executeQuery(sql0);                int d = 0;                 while (ab1.next()){                     int a= Integer.parseInt(ab1.getString(1));                      d=a;                 }                 String table="create table #cpkucun1" +                    "(" +                    "id int identity(1,1) not null," +                    "cpc_num int null," +                    "Production_code varchar(50) null," +                    "Production_name varchar(50) null," +                    "Production_city varchar(20) null," +                    "Time char(10) null," +                    "cpc_time char(20) null," +                    "cpc_shuliang int null," +                    "Production_unit varchar(50) null," +                    "Single_prince float null," +                    "cpc_jine float null," +                    "Invoice_code varchar(50) null," +                    "Production_specification char(30) null," +                    "Start varchar(50) null," +                    "End1 varchar(50) null," +                    "Note varchar(50) null" +                    ")";                 Statement rst4=Sqlconn.getStatement();                 rst4.addBatch(table);                 rst4.addBatch(table1);                 rst4.executeBatch();                        for(int i=0;i<16;i++){                            for(int j=0;j<=d;j++){                                String sql1="select * from #cpkucun1 where id='"+j+"'";                                  Statement rst2=Sqlconn.getStatement();                                ResultSet ab2=rst2.executeQuery(sql1);                                  while (ab2.next()){                                     CellElement cellElement= new CellElement(0+i,4+j,ab2.getString(1+i));                                     Style style = cellElement.getStyle();                                        if(style == null) {                                            style = Style.getInstance();                                        }                                      style = style.deriveBorder(Constants.LINE_THIN,Color.black,Constants.LINE_THIN,Color.black,Constants.LINE_THIN,Color.black,Constants.LINE_THIN,Color.black);                                  style = style.deriveHorizontalAlignment(Constants.CENTER);   //边框的颜色和粗细                                    style = style.deriveVerticalAlignment(Constants.BOTTOM);                                    cellElement.setStyle(style);                                    workSheet.addCellElement(cellElement);                                  }                            }                        }                        Sqlconn.getStatement().executeUpdate("drop table #cpkucun1");            String datasourceFilePath = "d:\\report\\datasource.xml";//设置数据源管理器,只需要读取datasource.xml文件即可            FileInputStream datasourceFileInputStream = new FileInputStream(datasourceFilePath);            DatasourceManager datasourceManager = new DatasourceManager();            datasourceManager.readInputStreamXML(datasourceFileInputStream);            FRContext.getFRContext().setDatasourceManager(datasourceManager);            Report excuteReport = workSheet.execute();        PreviewFrame previewFrame1 = new PreviewFrame();        previewFrame1.print(excuteReport);        previewFrame1.setVisible(true);          } catch(SAXParseException e)            {e.printStackTrace();}        } catch(Exception e) {            e.printStackTrace();        }    }} 


错误提示2008-11-20 9:38:26 com.fr.base.core.FRCoreContext log
警告: unexpected char: 0x?8
line 1:6: unexpected char: 0x?8
at com.fr.report.script.core.parser.FRLexer.nextToken(Unknown Source)
at antlr.TokenBuffer.fill(TokenBuffer.java:69)
at antlr.TokenBuffer.LA(TokenBuffer.java:80)
at antlr.LLkParser.LA(LLkParser.java:52)
at com.fr.report.script.core.parser.FRParser.power(Unknown Source)
at com.fr.report.script.core.parser.FRParser.multi(Unknown Source)
at com.fr.report.script.core.parser.FRParser.add(Unknown Source)
at com.fr.report.script.core.parser.FRParser.relation(Unknown Source)
at com.fr.report.script.core.parser.FRParser.conditionAnd(Unknown Source)
at com.fr.report.script.core.parser.FRParser.conditionOr(Unknown Source)
at com.fr.report.script.core.parser.FRParser.condition(Unknown Source)
at com.fr.report.script.core.parser.FRParser.parse(Unknown Source)
at com.fr.report.script.Calculator.eval(Unknown Source)
at com.fr.report.core.ScriptUtils.executeFormula(Unknown Source)
at com.fr.report.core.ScriptUtils.executeFormula(Unknown Source)
at com.fr.report.WorkSheet.easy_execute(Unknown Source)
at com.fr.report.WorkSheet.execute(Unknown Source)
at com.fr.report.WorkBook.execute(Unknown Source)
at yinshua.CpcAllPrint.<init>(CpcAllPrint.java:87)
at yinshua.Cpc_chaxun$MyActionAllListener.getPrint(Cpc_chaxun.java:426)
at yinshua.Cpc_chaxun$TemplateBase$1.actionPerformed(Cpc_chaxun.java:271)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1849)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2169)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:234)
at java.awt.Component.processMouseEvent(Component.java:5488)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3126)
at java.awt.Component.processEvent(Component.java:5253)
at java.awt.Container.processEvent(Container.java:1966)
at java.awt.Component.dispatchEventImpl(Component.java:3955)
at java.awt.Container.dispatchEventImpl(Container.java:2024)
at java.awt.Component.dispatchEvent(Component.java:3803)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3892)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822)
at java.awt.Container.dispatchEventImpl(Container.java:2010)
at java.awt.Window.dispatchEventImpl(Window.java:1774)
at java.awt.Component.dispatchEvent(Component.java:3803)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
请问我要怎么改啊。谢谢!!

[解决办法]
顶 ,没用过
[解决办法]
没有太细看你的源码,注意一下这里:

unexpected char: 0x?8
line 1:6: unexpected char: 0x?8 

个人猜想是否是由于0x?8这个数据提交到FineReport是不被识别引起的。
[解决办法]
是不是不能用中文或者亚洲语言的数据

[解决办法]
警告: unexpected char: 0x?8
line 1:6: unexpected char: 0x?8
at com.fr.report.script.core.parser.FRLexer.nextToken(Unknown Source) 


......

出现了不期望的字符.
[解决办法]
字符有问题,是不是数据库字符集设置的问题?
[解决办法]
字符问题!
[解决办法]
at yinshua.CpcAllPrint. <init>(CpcAllPrint.java:87) 

不知道你的 哪行是87行,应该是这个位置出的问题,你仔细检查检查!

热点排行
Bad Request.