Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Need Help in a database program

GegoTheWizardGegoTheWizard Posts: 20Member
Hi all how is everyone hope good
i wanna to make a program with Java which able me to connect on a Micrsoft Access Database and modify records in it or insert new record
i am using a JDeveloper 10G in my work i have a make the connection by using JDBC-ODBC and it success and i have read the database objects but i dont know how to use it and how to link a textfield with a field in a table
i hope anyone could help me plz
thanks in advance
byebye for now and begood all

Comments

  • datavirtuedatavirtue Posts: 12Member
    : Hi all how is everyone hope good
    : i wanna to make a program with Java which able me to connect on a Micrsoft Access Database and modify records in it or insert new record
    : i am using a JDeveloper 10G in my work i have a make the connection by using JDBC-ODBC and it success and i have read the database objects but i dont know how to use it and how to link a textfield with a field in a table

    import java.sql.*;

    /*************************************************************************************************************
    * This method performs the provided SQL statement and returns the number of rows updated.
    *
    **************************************************************************************************************/
    Url = "jdbc:odbc:DSN" DSN = name you provide when setting up ODBC

    static int sqlUpdate (String Url, String Id, String Pw, String sql) {


    int rowsUpdated=0;

    try {

    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");


    Connection con = DriverManager.getConnection (Url, Id, Pw);

    Statement stmt = con.createStatement ();

    rowsUpdated= stmt.executeUpdate (sql);

    stmt.close ();
    con.close ();

    }
    catch(Exception e) {

    //e.printStackTrace ();
    //JOptionPane.showMessageDialog(null, "*SqlUpdate* DB Problem!");
    return -1;
    //System.exit (0);
    }


    return rowsUpdated;

    }
    You also need to setup a DSN in your machine's ODBC setup, when you do this you have to point to the .mdb file you would like to access from Java through ODBC

    If this looks terribly foreign then you need some books.


    Sean
Sign In or Register to comment.