Hi

well wishes to all

i have written the code for to create to-do list in java swings with mysql

i hereby attached my code to you for reference

Req: Taskno(set as primary key), Task Name, Task GroupName, TaskPriority(high, low and medium which is mentioned in combo box), task status( ongoing, completed, planned), task start date( in date), end date(date), task result)

for these req: i want to add, delete, search , view (in MYSQL)

but here the code is not properly run

can anyone find out the errors in the code and guide me to complete the code

Regards
Kevin

Comments
Another thread in the same topic, will you never learn
Attachments
import java.awt.*;
import java.awt.event.*; 
import javax.swing.*;
import java.sql.*;
import javax.swing.table.*;
import javax.swing.plaf.*;
import javax.swing.plaf.metal.*;
import com.sun.java.swing.plaf.motif.*;
import com.sun.java.swing.plaf.windows.*;


public class Rough extends JFrame {
    boolean inAnApplet = true;   
    final boolean shouldFill = true;
    final boolean shouldWeightX = true;
    final static String MYPANEL1 = " LOGIN ";
    final static String MYPANEL2 = " ADD TASK ";
    final static String MYPANEL3 = " MODIFY/DELETE TASK ";
    final static String MYPANEL4 = " TASK DETAILS ";
    final static String MYPANEL5 = " SEARCH TASK DETAILS ";
    final static String MYPANEL6 = " VIEW TASK DETAILS ";
    final static String MYPANEL7 = " GENERATE TASK DETAILS ";
    String imagename = "c:/kevin/logo.jpg";
    ImageIcon ii = new ImageIcon(imagename);
    Font dataFont = new Font("courier new",Font.PLAIN,12);
    Font titleFont = new Font("courier new",Font.BOLD,14);
    ComboBoxListener cbListener = new ComboBoxListener();
    GridBagLayout gridbag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();	
    GridBagConstraints c2 = new GridBagConstraints();	
    GridBagConstraints c5 = new GridBagConstraints();	
    Container contentPane = getContentPane();		
    JDialog dialog = new JDialog((Frame) null, "!DELETE CONFIRMATION!", true);
    Container dialogContentPane = dialog.getContentPane();		
    JLabel jLabel, jLabel1, jLabel2, jLabel3, jLabel4, jLabel5, jLabel6, jLabel7,jLabel8,jLabel9,jLabel10,jLabel11;
    JLabel jLabeldlg = new JLabel("Do You Really want to Delete ?");
    JComboBox jCombobox1, jCombobox2,jcombobox3;
    JTextField jTextfield;		
    JTextField loginname = new JTextField(40);	
    JTextField loginpass = new JTextField(40);
    JTextField taskno = new JTextField(40);
    JTextField taskname = new JTextField(20);	
    JTextField taskgroupname = new JTextField(20);
    JTextField taskstartdate = new JTextField(20);		
    JTextField taskenddate = new JTextField(20);		
    JTextField taskresult = new JTextField(20);
    String driver="com.mysql.jdbc.Driver";
    String url="jdbc:mysql://localhost:3306/project";		
    String dialogtitle = "Task Added";
    String dialogf = "LOGIN FAILED";
    String dialogm = "DATABASE RECORD UPDATED";
    String dialogd = "DATABASE RECORD DELETED";
    String tempname = "";
    String qry = "";
    String sql,dialogmessage;
    int startdate,enddate;
    int tempcnt;
    int dialogtype = JOptionPane.PLAIN_MESSAGE;
    JPanel jPanel, p1, p2, p3;
    JTabbedPane tabbedPane = new JTabbedPane();
    JButton login = new JButton("LOGIN");
    JButton button, ADD,MODIFY,VIEW,DELETE;
    JButton QUERY;
    Object[] data = new Object[5];
    DefaultTableModel defaulttablemodel = new DefaultTableModel();
    JTable jtable = new JTable(defaulttablemodel);
    MetalLookAndFeel metalLF = new MetalLookAndFeel();
    MotifLookAndFeel motifLF = new MotifLookAndFeel();
    WindowsLookAndFeel windowsLF = new WindowsLookAndFeel();
    
    public static void main(String args[]) {
        Rough r = new Rough();
    }
    private String no;
    
    public Rough() {
        super("To-Do List"); 
  	setup();
  	pack();
  	addWindowListener(new WindowEventHandler());
  	show();
    }
    
    void setup() {
        setupMenuBar(); 
	showpane1();	
	contentPane.add(tabbedPane, BorderLayout.CENTER);
    }
    
    void setupMenuBar() {
        MenuBar menuBar = new MenuBar();
	Menu fileMenu = new Menu("File");
        MenuItem fileExit = new MenuItem("Exit");
        fileExit.addActionListener(new MenuItemHandler()); 
	fileMenu.add(fileExit);					
	menuBar.add(fileMenu);
        Menu styleMenu = new Menu("Style");		
	MenuItem styleWin = new MenuItem("Windows");	
	styleWin.addActionListener(new MenuItemHandler()); 
	styleMenu.add(styleWin);
	MenuItem styleMotif = new MenuItem("Motif");
	styleMotif.addActionListener(new MenuItemHandler()); 
	styleMenu.add(styleMotif);
	MenuItem styleMetal = new MenuItem("Metal");
	styleMetal.addActionListener(new MenuItemHandler()); 	
	styleMenu.add(styleMetal);						
	menuBar.add(styleMenu);
	setMenuBar(menuBar);
    }
    
    void showpane1() {
        p1 = new JPanel() {
            public Dimension getPreferredSize() {
                Dimension size = super.getPreferredSize();
                size.width = 785;	
                size.height = 495;	
                return size;
            }
        };
        p1.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),"Login Panel"));
	p1.setFont(titleFont);
	p1.setLayout(gridbag);  						
	jLabel1 = new JLabel("Enter Username");
	jLabel1.setFont(dataFont); 
	c.weighty = 0.0;   	  	
	c.ipady = 2;       	 			
	c.ipadx = 2; 		  
	c.anchor = GridBagConstraints.WEST; 	
        c.gridwidth = 1;   	  			
        c.gridx = 0;       	   					   
	c.gridy = 0;       	   	
	gridbag.setConstraints(jLabel1, c);
	p1.add(jLabel1);				
	loginname = new JTextField(" ");
	c.ipady = 2;       						
	c.ipadx = 2;       						
	c.weighty = 0.0;   						
        c.anchor = GridBagConstraints.WEST; 	
        c.gridwidth = 2;   						
        c.gridx = 1;       						    
        c.gridy = 0;       						
        gridbag.setConstraints(loginname, c);
	p1.add(loginname);				
	jLabel2 = new JLabel("Enter Password");
	jLabel2.setFont(dataFont);
	c.ipady = 2;       						
	c.ipadx = 2;       						
	c.weighty = 0.0;   						
	c.anchor = GridBagConstraints.WEST; 	
	c.gridwidth = 1;   						
	c.gridx = 0;       						     
	c.gridy = 1;       						
	gridbag.setConstraints(jLabel2, c);
	p1.add(jLabel2);				
	loginpass = new JTextField(" ");
	c.ipady = 2;       						
	c.ipadx = 2;       						
	c.weighty = 0.0;   						
	c.anchor = GridBagConstraints.WEST; 	
	c.gridwidth = 2;   						
	c.gridx = 1;       						     
	c.gridy = 1;       						
        gridbag.setConstraints(loginpass, c);
	p1.add(loginpass);				
	button = new JButton("LOGIN");
        c.ipady = 2;       						
	c.ipadx = 2;       						
        c.weighty = 0.0;   						
	c.anchor = GridBagConstraints.CENTER; 	        
        c.gridwidth = 1;   						
        c.gridx = 1;       						      
        c.gridy = 2;       						
        gridbag.setConstraints(button, c);
        button.addActionListener(new ButtonHandler());
        p1.add(button);	
	tabbedPane.addTab(MYPANEL1, p1);
    }
    
    void showpane2() {
        p2 = new JPanel();
	p2.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),"Add Task"));
	p2.setLayout(gridbag);
        jLabel3 = new JLabel("Task No");	
	jLabel3.setFont(dataFont);		
	c.fill = GridBagConstraints.BOTH;		
	c.ipady = 2;       						
	c.ipadx = 2;  
	c.gridx = 0;       						     
	c.gridy = 1;       						
	gridbag.setConstraints(jLabel3, c);				
	p2.add(jLabel3);															
	c.ipady = 2;       						
	c.ipadx = 2;  
	c.gridx = 1;       						     
	c.gridy = 1;       						
	gridbag.setConstraints(taskno, c);				
	p2.add(taskno);									
	jLabel4 = new JLabel("Task Name");	
	jLabel4.setFont(dataFont);				
	c.ipady = 2;       						
	c.ipadx = 2;  
	c.gridx = 0;       						     
	c.gridy = 2;       						
	gridbag.setConstraints(jLabel4, c);		
	p2.add(jLabel4);																		  
	c.ipady = 2;       						
	c.ipadx = 2;  
	c.gridx = 1;       						     
	c.gridy = 2;   
	gridbag.setConstraints(taskname, c);	
	p2.add(taskname);						
	jLabel5 = new JLabel("Task Group Name");	
	jLabel5.setFont(dataFont);				
	c.ipady = 2;       						
	c.ipadx = 2;  
	c.gridx = 0;       						     
	c.gridy = 3;       						
	gridbag.setConstraints(jLabel5, c);				
	p2.add(jLabel5);											
	c.ipady = 2;       						
	c.ipadx = 2;  
	c.gridx = 1;       						     
	c.gridy = 3;       						
	gridbag.setConstraints(taskgroupname, c);				
	p2.add(taskgroupname);				
	jLabel6 = new JLabel("Priority");	
	jLabel6.setFont(dataFont);				
	c.ipady = 2;       						
	c.ipadx = 2;  
	c.gridx = 0;       						     
	c.gridy = 5;       						
        gridbag.setConstraints(jLabel6, c);				
	p2.add(jLabel6);													
	jCombobox1 = new JComboBox();
	jCombobox1.setFont(dataFont);	
	jCombobox1.addItem("High");
	jCombobox1.addItem("Medium");
        jCombobox1.addItem("Low");
	c.fill = GridBagConstraints.BOTH;
	c.insets = new Insets(10,0,0,30);  		
	c.ipady = 2;     						
	c.ipadx = 2;							
        c.gridx = 1;							
	c.gridy = 5;							
	jCombobox1.addItemListener(cbListener);	
	gridbag.setConstraints(jCombobox1, c);
	p2.add(jCombobox1);
        jLabel7 = new JLabel("Status");	
	jLabel7.setFont(dataFont);				
	c.ipady = 2;       						
	c.ipadx = 2;  
	c.gridx = 0;       						     
	c.gridy = 5;       						
        gridbag.setConstraints(jLabel7, c);				
	p2.add(jLabel7);													
	jCombobox2 = new JComboBox();
	jCombobox2.setFont(dataFont);	
	jCombobox2.addItem("Planned");
	jCombobox2.addItem("Ongoing");
        jCombobox2.addItem("Completed");
	c.fill = GridBagConstraints.BOTH;
	c.insets = new Insets(10,0,0,30);  		
	c.ipady = 2;     						
	c.ipadx = 2;							
        c.gridx = 1;							
	c.gridy = 5;							
	jCombobox2.addItemListener(cbListener);	
	gridbag.setConstraints(jCombobox2, c);
	p2.add(jCombobox2);	
	jLabel8 = new JLabel("Start Date");	
	jLabel8.setFont(dataFont);				
	c.ipady = 2;       						
	c.ipadx = 2;  
	c.gridx = 0;       						     
	c.gridy = 2;       						
	gridbag.setConstraints(jLabel8, c);		
	p2.add(jLabel8);																		  
	c.ipady = 2;       						
	c.ipadx = 2;  
	c.gridx = 1;       						     
	c.gridy = 2;   
	gridbag.setConstraints(taskstartdate, c);	
	p2.add(taskstartdate);	
        jLabel9 = new JLabel("End Date");	
	jLabel9.setFont(dataFont);				
	c.ipady = 2;       						
	c.ipadx = 2;  
	c.gridx = 0;       						     
	c.gridy = 2;       						
	gridbag.setConstraints(jLabel9, c);		
	p2.add(jLabel9);																		  
	c.ipady = 2;       						
	c.ipadx = 2;

Where do you get the errors? (at which lines)
Post part of the code where you get the error, with the error message

Man another *%$#@&* thread on mysql & swing created by kevinpeterson22,
what the hell is your problem ?
When some responds to any of your threads you just do not reply back.
Do you think just cause you are making thread after thread on the same topic some one is going to do your work for you ???

Three threads (Now merged to one by the moderator):-
http://www.daniweb.com/forums/thread142547.html
http://www.daniweb.com/forums/thread142547.html
http://www.daniweb.com/forums/thread142547.html

And you refuse to provide any information on the errors you are encountering.
Basically I am begining to think you just picked up that code from the internet (or some kind soul lend it to you) and you want us to fix it for you.

Comments

Just guessing, coz you don't provide the line where the error occured.
Try delete the

throw new UnsupportedOperationException("Not yet implemented");

from your

accessDBinit

method.

Tell me if it's working.
Just suggestion, why don't you use

PreparedStatement

instead of

Statement

for cleaner code, and try-finally block when you dealing with open-close database connection ..

This article has been dead for over six months. Start a new discussion instead.