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

        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);


    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) {

the second class :


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");                               
        JPanel top = new JPanel();                          
        top.add(new JLabel("Enter Video Number:"));
        add("North", top);                           
        JPanel middle = new JPanel();
        add("Center", middle);                                       


        try {
            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) {
        catch (SQLException 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);

             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.

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, learning, and sharing knowledge.