Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: executeUpdate Problem

  1. #1
    Junior Member
    Join Date
    Oct 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default executeUpdate Problem

    I am using MS Access 07, I already made the Connection with ODBC. In my code I am having problems with "executeUpdate". I don't know why. Does someone can help me with that? Thanks!!

    import java.sql.*;
    import java.beans.Statement;

    public void Conexao()
    {

    try {
    //1 passo - carregar o driver
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    //2 passo - criar a conexao de banco
    con = DriverManager.getConnection("jdbc: odbc: DNSWiki");

    //3 passo - criar o obejto que manipula a rotina sql
    st = (Statement) con.createStatement();

    } catch (Exception e) {

    }
    }

    //// -------- I am using a JMenuItem (Save) ---------///

    private void SaveActionPerformed(java.awt.event.ActionEvent evt) {
    try{
    Conexao();

    String ss = ssnT.getText();
    String Fname = FNT.getText();
    String Lname = LNT.getText();
    String Mname = MNT.getText();
    String address = AddressT.getText();
    String city = CityT.getText();
    String state = StateT.getText();
    String zipcode = ZipCodeT.getText();
    String phone = PhoneT.getText();
    String email = EmailT.getText();
    String birthday = BirthdayT.getText();
    String country = CountryT.getText();


    int i = st.executeUpdate("insert into tbWiki values('"+ ss +"','"+Fname+"','"+Lname+"','"+Mna me+"','" + address + "','" + city + "','"+ state +"','"+zipcode+"','"+country+"', '"+ phone +"','"+email+"','"+birthday+"')");
    JOptionPane.showMessageDialog(null, "Dados inseridos com sucesso!");

    con.close();
    }
    catch ( Exception ex )
    {
    JOptionPane.showMessageDialog(null, "Esse Cpf já está cadastrado! ");
    } // end catch
    }


  2. #2
    Junior Member
    Join Date
    Oct 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: executeUpdate Problem

    The Error said this:

    Cannot find Symbol

    Symbol: method executeUpdate(java.lang.String)
    Location: variable st of type java.beans.Statement

    I already import the java.land.* and java.beans.Statement

  3. #3
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,545
    My Mood
    Grumpy
    Thanks
    0
    Thanked 167 Times in 158 Posts

    Default Re: executeUpdate Problem

    The beans.Statement class does not have an executeUpdate method. Why are you using that class and not the sql.Statement class? Even better use a PreparedStatement. Also never ever do this:
    } catch (Exception e) {
     
    }
    At the very least put in a printStackTrace call so you know if anything went wrong.
    Improving the world one idiot at a time!

  4. #4
    Junior Member
    Join Date
    Nov 2011
    Posts
    7
    My Mood
    Busy
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: executeUpdate Problem

    You are using a wrong package beans;use java.sql.*;
    remove import java.beans.Sta.... line.
    it will works

  5. #5
    Junior Member
    Join Date
    May 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: executeUpdate Problem

    Thanks you are great !
    remove the import java.beans.Sta ...

Similar Threads

  1. Replies: 3
    Last Post: January 5th, 2012, 01:44 AM