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 4 of 4

Thread: delete item from mysql database

  1. #1
    Junior Member
    Join Date
    Apr 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default delete item from mysql database

    hey guys..
    i have used this code to show data from mysql database through JComboBox

     DefaultComboBoxModel model=(DefaultComboBoxModel) jComboBox6.getModel();
     
            String sql="SELECT * FROM department";
            try
            {
            Class.forName("com.mysql.jdbc.Driver");
     
            Connection con=(Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/store","root","root");
            Statement stat= con.createStatement();
            ResultSet res= stat.executeQuery(sql);
     
     
            while(res.next())
            {
              String name=res.getString("dep_name");
              model.addElement(name);
           }
            }
            catch(Exception e)
            {
                JOptionPane.showMessageDialog(this, e.getMessage());
            }

    now i want the code to delete selected item from JCombBox from database plz


  2. #2
    Think of me.... Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Pakistan
    Posts
    1,136
    My Mood
    Grumpy
    Thanks
    20
    Thanked 82 Times in 78 Posts
    Blog Entries
    1

    Default Re: delete item from mysql database

    And what problems are you facing?
    Anyone who stops learning is old, whether at twenty or eighty. Anyone who keeps learning stays young. The greatest thing in life is to keep your mind young.

    - Henry Ford

  3. #3
    Junior Member
    Join Date
    Apr 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: delete item from mysql database

    Quote Originally Posted by Mr.777 View Post
    And what problems are you facing?
    there is no problem sir,
    but what i want is the java code to delete selected item from mysql database

  4. #4
    Think of me.... Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Pakistan
    Posts
    1,136
    My Mood
    Grumpy
    Thanks
    20
    Thanked 82 Times in 78 Posts
    Blog Entries
    1

    Default Re: delete item from mysql database

    Well, the problem is if you've read the forums rules, you would never ask for the code. In fact, you would come to know that everyone will ask you, what have you tried so far? Where exactly you are facing the problems. Now let's come to your question, if you will google it, you will find hundreds of result pages.
    Anyone who stops learning is old, whether at twenty or eighty. Anyone who keeps learning stays young. The greatest thing in life is to keep your mind young.

    - Henry Ford

Similar Threads

  1. connect to mysql database
    By aueddonline in forum JDBC & Databases
    Replies: 5
    Last Post: December 17th, 2011, 01:44 PM
  2. [SOLVED] Connection to MySql Database
    By dego89 in forum JDBC & Databases
    Replies: 8
    Last Post: May 26th, 2011, 08:56 AM
  3. drag item or insert item into new Jlabel in JPanel
    By qaromi in forum AWT / Java Swing
    Replies: 5
    Last Post: July 6th, 2010, 07:37 PM
  4. MySQL Database
    By pjeremy90 in forum Java Theory & Questions
    Replies: 2
    Last Post: June 12th, 2010, 10:34 AM
  5. [SOLVED] how to delete an item from a form
    By mahdi in forum Java ME (Mobile Edition)
    Replies: 3
    Last Post: August 30th, 2009, 01:06 PM