gpt4 book ai didi

ms-access - Jasper报告iReport与MS Access DB的连接

转载 作者:行者123 更新时间:2023-12-04 20:23:41 26 4
gpt4 key购买 nike

是否有人使用Jasper Reports iReport成功连接到其MS Access数据库?

我正在运行Windows XP,并下载了North Wind .mdb示例文件。

有人可以提供步骤/配置文件粘贴或指向有关如何连接到该文件并开始构建查询和报告的教程的链接吗?

信息我正在JDBC数据库连接向导中使用:

<?xml version="1.0"?><!-- iReport connections -->
<iReportConnectionSet>
<iReportConnection name="Empty datasource" connectionClass="com.jaspersoft.ireport.designer.connection.JREmptyDatasourceConnection">
<connectionParameter name="records"><![CDATA[1]]></connectionParameter>
</iReportConnection>
<iReportConnection name="accessdb" connectionClass="com.jaspersoft.ireport.designer.connection.JDBCConnection">
<connectionParameter name="Password"><![CDATA[]]></connectionParameter>
<connectionParameter name="JDBCDriver"><![CDATA[com.ms.jdbc.odbc.JdbcOdbcDriver]]></connectionParameter>
<connectionParameter name="ServerAddress"><![CDATA[C:\nwind\nwind.mdb]]></connectionParameter>
<connectionParameter name="SavePassword"><![CDATA[false]]></connectionParameter>
<connectionParameter name="Database"><![CDATA[nwind]]></connectionParameter>
<connectionParameter name="Url"><![CDATA[jdbc:odbc:nwind]]></connectionParameter>
<connectionParameter name="Username"><![CDATA[]]></connectionParameter>
</iReportConnection>
</iReportConnectionSet>

这是我不断收到的错误:
    Exception


Message:
java.lang.ClassNotFoundException: com.ms.jdbc.odbc.JdbcOdbcDriver
Level:
SEVERE
Stack Trace:
com.ms.jdbc.odbc.JdbcOdbcDriver
com.jaspersoft.ireport.designer.connection.JDBCConnection.loadDriver(JDBCConnection.java:63)
com.jaspersoft.ireport.designer.connection.JDBCConnection.getConnection(JDBCConnection.java:126)
com.jaspersoft.ireport.designer.connection.JDBCConnection.test(JDBCConnection.java:447)
com.jaspersoft.ireport.designer.connection.gui.ConnectionDialog.jButtonTestActionPerformed(ConnectionDialog.java:335)
com.jaspersoft.ireport.designer.connection.gui.ConnectionDialog.access$300(ConnectionDialog.java:43)
com.jaspersoft.ireport.designer.connection.gui.ConnectionDialog$4.actionPerformed(ConnectionDialog.java:290)
javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1849)
javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2169)
javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
java.awt.Component.processMouseEvent(Component.java:5488)
javax.swing.JComponent.processMouseEvent(JComponent.java:3126)
java.awt.Component.processEvent(Component.java:5253)
java.awt.Container.processEvent(Container.java:1966)
java.awt.Component.dispatchEventImpl(Component.java:3955)
java.awt.Container.dispatchEventImpl(Container.java:2024)
java.awt.Component.dispatchEvent(Component.java:3803)
java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212)
java.awt.LightweightDispatcher.processMouseEvent(Container.java:3892)
java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822)
java.awt.Container.dispatchEventImpl(Container.java:2010)
java.awt.Window.dispatchEventImpl(Window.java:1778)
java.awt.Component.dispatchEvent(Component.java:3803)
java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:104)
java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:153)
java.awt.Dialog$1.run(Dialog.java:517)
java.awt.Dialog$2.run(Dialog.java:545)
java.security.AccessController.doPrivileged(Native Method)
java.awt.Dialog.show(Dialog.java:543)
java.awt.Component.show(Component.java:1300)
java.awt.Component.setVisible(Component.java:1253)
com.jaspersoft.ireport.designer.wizards.ConnectionSelectionVisualPanel.jButton1ActionPerformed(ConnectionSelectionVisualPanel.java:310)
com.jaspersoft.ireport.designer.wizards.ConnectionSelectionVisualPanel.access$400(ConnectionSelectionVisualPanel.java:41)
com.jaspersoft.ireport.designer.wizards.ConnectionSelectionVisualPanel$6.actionPerformed(ConnectionSelectionVisualPanel.java:218)
javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1849)
javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2169)
javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
java.awt.Component.processMouseEvent(Component.java:5488)
javax.swing.JComponent.processMouseEvent(JComponent.java:3126)
java.awt.Component.processEvent(Component.java:5253)
java.awt.Container.processEvent(Container.java:1966)
java.awt.Component.dispatchEventImpl(Component.java:3955)
java.awt.Container.dispatchEventImpl(Container.java:2024)
java.awt.Component.dispatchEvent(Component.java:3803)
java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212)
java.awt.LightweightDispatcher.processMouseEvent(Container.java:3892)
java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822)
java.awt.Container.dispatchEventImpl(Container.java:2010)
java.awt.Window.dispatchEventImpl(Window.java:1778)
java.awt.Component.dispatchEvent(Component.java:3803)
java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:104)
java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:153)
java.awt.Dialog$1.run(Dialog.java:517)
java.awt.Dialog$2.run(Dialog.java:545)
java.security.AccessController.doPrivileged(Native Method)
java.awt.Dialog.show(Dialog.java:543)
org.netbeans.core.windows.services.NbPresenter.superShow(NbPresenter.java:867)
org.netbeans.core.windows.services.NbPresenter.doShow(NbPresenter.java:901)
org.netbeans.core.windows.services.NbPresenter.run(NbPresenter.java:889)
org.netbeans.core.windows.services.NbPresenter.run(NbPresenter.java:109)
org.openide.util.Mutex.doEventAccess(Mutex.java:1355)
org.openide.util.Mutex.readAccess(Mutex.java:268)
org.netbeans.core.windows.services.NbPresenter.show(NbPresenter.java:874)
java.awt.Component.show(Component.java:1300)
java.awt.Component.setVisible(Component.java:1253)
com.jaspersoft.ireport.designer.templates.TemplatesFrame.runTemplateWizard(TemplatesFrame.java:470)
com.jaspersoft.ireport.designer.templates.ReportTemplateItemAction.performAction(ReportTemplateItemAction.java:50)
com.jaspersoft.ireport.designer.templates.TemplatesFrame.jButtonLaunchWizardActionPerformed(TemplatesFrame.java:328)
com.jaspersoft.ireport.designer.templates.TemplatesFrame.access$700(TemplatesFrame.java:55)
com.jaspersoft.ireport.designer.templates.TemplatesFrame$10.actionPerformed(TemplatesFrame.java:244)
javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1849)
javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2169)
javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
java.awt.Component.processMouseEvent(Component.java:5488)
javax.swing.JComponent.processMouseEvent(JComponent.java:3126)
java.awt.Component.processEvent(Component.java:5253)
java.awt.Container.processEvent(Container.java:1966)
java.awt.Component.dispatchEventImpl(Component.java:3955)
java.awt.Container.dispatchEventImpl(Container.java:2024)
java.awt.Component.dispatchEvent(Component.java:3803)
java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212)
java.awt.LightweightDispatcher.processMouseEvent(Container.java:3892)
java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822)
java.awt.Container.dispatchEventImpl(Container.java:2010)
java.awt.Window.dispatchEventImpl(Window.java:1778)
java.awt.Component.dispatchEvent(Component.java:3803)
java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:104)
java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:153)
java.awt.Dialog$1.run(Dialog.java:517)
java.awt.Dialog$2.run(Dialog.java:545)
java.security.AccessController.doPrivileged(Native Method)
java.awt.Dialog.show(Dialog.java:543)
java.awt.Component.show(Component.java:1300)
java.awt.Component.setVisible(Component.java:1253)
com.jaspersoft.ireport.designer.templates.TemplatesFrame.setVisible(TemplatesFrame.java:582)
com.jaspersoft.ireport.designer.welcome.QuickStartPanel.jButton2ActionPerformed(QuickStartPanel.java:331)
com.jaspersoft.ireport.designer.welcome.QuickStartPanel.access$500(QuickStartPanel.java:50)
com.jaspersoft.ireport.designer.welcome.QuickStartPanel$4.actionPerformed(QuickStartPanel.java:167)
javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1849)
javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2169)
javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:231)
java.awt.Component.processMouseEvent(Component.java:5488)
javax.swing.JComponent.processMouseEvent(JComponent.java:3126)
java.awt.Component.processEvent(Component.java:5253)
java.awt.Container.processEvent(Container.java:1966)
java.awt.Component.dispatchEventImpl(Component.java:3955)
java.awt.Container.dispatchEventImpl(Container.java:2024)
java.awt.Component.dispatchEvent(Component.java:3803)
java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212)
java.awt.LightweightDispatcher.processMouseEvent(Container.java:3892)
java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822)
java.awt.Container.dispatchEventImpl(Container.java:2010)
java.awt.Window.dispatchEventImpl(Window.java:1778)
java.awt.Component.dispatchEvent(Component.java:3803)
java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:104)
java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
java.awt.EventDispatchThread.run(EventDispatchThread.java:110)

最佳答案

可能的解决方案要感谢Jasper论坛上的家伙
http://jasperforge.org/plugins/espforum/view.php?group_id=83&forumid=101&topicid=73202

I had to setup a a DSN for Access database

To do this I went through these steps



1. Goto start and control panel. Select administrative tools.

2. In that select DataSources (ODBC).

3. Click on the right side pane. click Add button

4. I selected Microsoft Access Driver [*mdb]

5. click finish

6. Goto select and find the databse name on the drive. Select the location. (Here you are finding the database file you want)

7. Once you have found the file ,click on Configure Button . Click on
SELECT and browse to the database you want to connect(generally a *mdb , * accdb.)You can add/change username and password to the database .As it is mandatory at times for iReport .


8. Leave system database has none

9. Put a name in the Datasource call it what ever you want

10. go to right panel and click okay

11. Find the Dsn name added to the list. (Just to make sure its there)





Now we set that up we now setup Ireporting

1. Open it up

2. Click data on the top menu its next to Format

3. click Connections/ Datasources

4. Click New button on the right panel

5. Select Database JDBC connection

6 .Click next

7. Name : Type a name in call it what ever you want

8. JDBC Driver: sun.jdbc.odbc.JdbcOdbcDriver

9. JDBC URL: jdbc:odbc:???????

10. In the question marks you put the name you called the datasource on step 9 on how to setup setup a a DSN for Access database

11. Server address: leave blank

12. Database: leave blank

13. Database: leave blank

14. Username: leave blank

15. Password: leave blank

16. Test it make sure it connects okay

17. Click Save

18. Select the datasource you have just done and click set as default

关于ms-access - Jasper报告iReport与MS Access DB的连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3444721/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com