Results 1 to 3 of 3
  1. #1
    sayan751 is offline Member
    Join Date
    Feb 2009
    Posts
    29
    Rep Power
    0

    Exclamation DSN less connectivity to Ms ACCESS

    hi,
    i am doing a small project in Netbeans that add 2 numbers and display the result in a third textbox. all the three values(num1,num2,result) are also get stored in a database. i used dsn less connectivity to connect the database(in Ms Access),but every time i am getting a runtime error.

    the image of my UI is attached.
    DSN less connectivity to Ms ACCESS-ui.jpg
    i am using the following code.

    Java Code:
    float num1,num2,result;
            num1=Float.parseFloat(jTextField1.getText());
            num2=Float.parseFloat(jTextField2.getText());
            result=num1+num2;
            jTextField3.setText(String.valueOf(result));
            try {
                Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                String myDB ="jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=numdb.mdb";
                Connection con = DriverManager.getConnection(myDB,"","");
                Statement stmnt=con.createStatement();
                stmnt.executeUpdate("insert into \"add\" values("+num1+","+num2+","+result+")");
            } catch (SQLException ex) {
                ex.printStackTrace();
            } catch (ClassNotFoundException ex) {
                ex.printStackTrace();
            }
    here numdb.mdb resides in the same folder as the source code.
    DSN less connectivity to Ms ACCESS-project.jpg

    every time i am executing my program it is giving following errors:-
    Java Code:
    java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Could not find file '(unknown)'.
            at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6957)
            at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7114)
            at sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(JdbcOdbc.java:3073)
            at sun.jdbc.odbc.JdbcOdbcConnection.initialize(JdbcOdbcConnection.java:323)
            at sun.jdbc.odbc.JdbcOdbcDriver.connect(JdbcOdbcDriver.java:174)
            at java.sql.DriverManager.getConnection(DriverManager.java:582)
            at java.sql.DriverManager.getConnection(DriverManager.java:185)
            at my.numberaddition.NumberAdditionUI.jButton2ActionPerformed(NumberAdditionUI.java:143)
            at my.numberaddition.NumberAdditionUI.access$100(NumberAdditionUI.java:14)
            at my.numberaddition.NumberAdditionUI$2.actionPerformed(NumberAdditionUI.java:57)
            at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
            at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
            at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
            at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
            at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
            at java.awt.Component.processMouseEvent(Component.java:6134)
            at javax.swing.JComponent.processMouseEvent(JComponent.java:3265)
            at java.awt.Component.processEvent(Component.java:5899)
            at java.awt.Container.processEvent(Container.java:2023)
            at java.awt.Component.dispatchEventImpl(Component.java:4501)
            at java.awt.Container.dispatchEventImpl(Container.java:2081)
            at java.awt.Component.dispatchEvent(Component.java:4331)
            at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4301)
            at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3965)
            at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3895)
            at java.awt.Container.dispatchEventImpl(Container.java:2067)
            at java.awt.Window.dispatchEventImpl(Window.java:2458)
            at java.awt.Component.dispatchEvent(Component.java:4331)
            at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
            at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
            at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
            at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
            at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
    Please help me.
    Last edited by sayan751; 03-27-2009 at 09:08 PM.

  2. #2
    sayan751 is offline Member
    Join Date
    Feb 2009
    Posts
    29
    Rep Power
    0

    Default

    i have also tried to put the database inside the classes folder where my .class files are residing. but it also giving the same error.

    plz help.

  3. #3
    sayan751 is offline Member
    Join Date
    Feb 2009
    Posts
    29
    Rep Power
    0

    Default

    someone plz give me any solution.

    is it always necessary to give the full path where the database resides(for dsn less connectivity)?

    is there no way to make it platform independent?

Similar Threads

  1. Frame connectivity
    By Shivraj in forum NetBeans
    Replies: 1
    Last Post: 03-17-2009, 02:30 PM
  2. database connectivity
    By rilwanfit in forum Networking
    Replies: 1
    Last Post: 03-13-2009, 08:54 PM
  3. sql connectivity
    By prashant in forum JDBC
    Replies: 2
    Last Post: 12-27-2008, 05:05 AM
  4. database connectivity
    By vani in forum Eclipse
    Replies: 0
    Last Post: 11-21-2008, 11:03 AM
  5. Connectivity Test
    By jimhaddon in forum Java Applets
    Replies: 9
    Last Post: 08-16-2008, 05:40 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •