hi all, i am doing my java project (video player).

This is the task :

Enter a video number and click a button to add that video to a playlist.
If the video number is valid, the video name should be added to the list
and all the names in the list should be displayed in a text area,
otherwise a suitable error message should be displayed.

the main code :
Video player

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class VideoPlayer extends JFrame
                  implements ActionListener {
        JButton check = new JButton("Check Videos");
        JButton playlist = new JButton("Create Video List");
        JButton update = new JButton("Update Videos");
        JButton quit = new JButton("Exit");

    public static void main(String[] args) {
        new VideoPlayer();
    }

    public VideoPlayer() {
        setLayout(new BorderLayout());
        setSize(450, 100);
        setTitle("Video Player");

        // close application only by clicking the quit button
        setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);

        JPanel top = new JPanel();
        top.add(new JLabel("Select an option by clicking one of the buttons below"));
        add("North", top);

        JPanel bottom = new JPanel();
        bottom.add(check); check.addActionListener(this);
        bottom.add(playlist); playlist.addActionListener(this);
        bottom.add(update); update.addActionListener(this);
        bottom.add(quit); quit.addActionListener(this);
        add("South", bottom);

        setResizable(false);
        setVisible(true);
    }

    public void actionPerformed(ActionEvent e) {
        if (e.getSource() == check) {
            new CheckVideos();
        }
          else if (e.getSource () == playlist) {
            new CreateVideoList();
        }
          else if (e.getSource() == update) {
            new UpdateVideos();    
        } 
          else if (e.getSource() == quit) {
            VideoData.close();
            System.exit(0);
        }
    }
}

the second class :

CreateVideoList

import java.awt.BorderLayout;
import java.awt.TextArea;
import java.sql.*;
import java.awt.event.*;
import static java.lang.System.out;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
import javax.swing.*;
import static javax.swing.JOptionPane.showMessageDialog;


public class CreateVideoList extends JFrame implements ActionListener {     

    JTextField videoNo = new JTextField(2);
    TextArea information = new TextArea(6, 50);
    JButton add = new JButton("Add Video");
    Statement myStatement;
    Connection Video;

    public CreateVideoList() {                                  
        setLayout(new BorderLayout());
        setBounds(100, 100, 400, 200);                      
        setTitle("Check Library");                               
        setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);  
        JPanel top = new JPanel();                          
        top.add(new JLabel("Enter Video Number:"));
        top.add(videoNo);                                
        top.add(add);
        add.addActionListener(this);
        add("North", top);                           
        JPanel middle = new JPanel();
        middle.add(information);
        add("Center", middle);                                       

        setResizable(false);                                  
        setVisible(true);             

        try {
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            String sourceURL = 
                "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=Video.mdb;";
            Connection Video = DriverManager.getConnection(sourceURL, "admin", "");
            myStatement = Video.createStatement();
        }
        // The following exceptions must be caught
        catch (ClassNotFoundException cnfe) {
            showMessageDialog(null,cnfe);
        }
        catch (SQLException sqle) {
            showMessageDialog(null,sqle);
        }
    }

    public void actionPerformed(ActionEvent e) {                
        if (e.getSource() == add) {      

                    String id = videoNo.getText();
                    String area = information.getText();
          try {

                    if (id.equals("")) {
                    showMessageDialog(this, "Please enter a valid Video ID");

                PreparedStatement pstmt = Video.prepareStatement("................");

                pstmt.setString(1, id);
                pstmt.setString(2, area);
                pstmt.executeUpdate();

             JOptionPane.showMessageDialog(null,"Inserted Successfully!");
            }
                    }

          catch(Exception ex){}
            }
        }

        }

I had created the gui, my problem is to get the "add video" button able to add video from VideoTable (table in ms access) to Playlist (table in ms access) based on the id enter in "JTextField videoNo". I have attached the ms access file as well. After the video is added to playlist table, the list should be displayed in the textarea as well.

please help.

Thank you.

Since I assume you have no experience with JPA or Hibernate, I'll suggest you this.

EDIT:
a good advice: never EVER write code like this: catch(Exception ex){}

how will you ever know whether or not an exception has been caught there, let allone how to solve the problem?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.