views:

103

answers:

1

Has anyone successfully connected to their MS Access db using Jasper Reports iReport?

I am running windows XP and have downloaded the North Wind .mdb example file.

Can someone provide the steps/config file pastes or links to tutorials on how to connect to that file and start building queries and reports?

Info I am using in JDBC Database Connection wizard:

<?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>

Here is the error I keep getting:

    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)
+2  A: 

Possible solution thanks to guy on Jasper Forum at http://jasperforge.org/plugins/espforum/view.php?group_id=83&amp;forumid=101&amp;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 okay

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
watr
Does JDBC require a DSN? Or are you just not providing the correct DSN-less connect string?
David-W-Fenton
I'm not familiar enough with Jasper to know how to not use a DSN, but the above instructions did end up working for me.
watr