VERY Urgent Help!jdbc

I have this project due tommorow and i can't figure out two errors which is in line 39 identifier expected in the catch statement.

I'm posting my codes here i hope u guys can help me!

import java.awt.*;

import javax.swing.*;

import java.awt.event.*;

import java.sql.*;

class HAddFrame extends Frame{//Start of function

public static void main (String args[]){

//Set frame for HAddFrame

HAddFrame frame = new HAddFrame();

frame.setVisible(true);

}

private static final int FRAME_WIDTH = 800;

private static final int FRAME_HEIGHT = 580;

private static final int FRAME_X_ORIGIN = 0;

private static final int FRAME_Y_ORIGIN = 0;

private static final int BUTTON_WIDTH = 80;

private static final int BUTTON_HEIGHT = 30;

private String url;

private Connection con;

Button saveButton;

Button resetButton;

Button cancelButton;

public HAddFrame()//Set labels for HAddFrame

{

try{

url = "jdbc:odbc:PP";

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

con = DriverManager.getConnection(url);

}

catch()

{}

setSize(FRAME_WIDTH, FRAME_HEIGHT);

setResizable(false);

setTitle("Malaysian Department Of Forestry (Harvest File)");

setLocation(FRAME_X_ORIGIN, FRAME_Y_ORIGIN);

setFont (new Font ("ArialBack", Font.BOLD | Font.PLAIN, 18));

addWindowListener(new ProgramTerminator());

//The insertion of the Forestry's logo

ImageComponent displayFrame = new ImageComponent();

add(displayFrame,"West");

displayFrame.setBounds( 90,100,52,58);

Panel topPanel = new ForestryPanel();

add(topPanel,"North");

Panel picturePanel = new HAddSidePanel();

add(picturePanel,"West");

Panel detailPanel = new Panel();

detailPanel.setBackground(Color.white);

detailPanel.setLayout(null);

detailPanel.setBounds(new Rectangle (0,0,500,550));

//Set labels for the HAddFrame

Label l3 = new Label("Segment Code:");

l3.setBounds(0,50,200,25);

detailPanel.add(l3);

final TextField tf = new TextField("",10);

tf.setBounds(210,50,150,25);

detailPanel.add(tf);

Label l4 = new Label("Tree Code:");

l4.setBounds(0,85,200,25);

detailPanel.add(l4);

final TextField tf1 = new TextField("",20);

tf1.setBounds(210,85,150,25);

detailPanel.add(tf1);

Label l5 = new Label("Date of Harvest:");

l5.setBounds(0,120,200,25);

detailPanel.add(l5);

final TextField tf2 = new TextField("",10);

tf2.setBounds(210,120,150,25);

detailPanel.add(tf2);

Label l6 = new Label("Number of Trees:");

l6.setBounds(0,155,200,25);

detailPanel.add(l6);

final TextField tf3 = new TextField("",10);

tf3.setBounds(210,155,150,25);

detailPanel.add(tf3);

Label ll6 = new Label("Revenue");

ll6.setBounds(0,190,150,25);

detailPanel.add(ll6);

final TextField tf4 = new TextField("",10);

tf4.setBounds(210,190,175,25);

detailPanel.add(tf4);

Label ll7 = new Label("Number Of Trees Remaining:");

ll7.setBounds(0,230,300,25);

detailPanel.add(ll7);

final TextField tf5 = new TextField("",10);

tf5.setBounds(300,230,150,25);

detailPanel.add(tf5);

Label l7 = new Label("Forest Officer in Charge:");

l7.setBounds(0,270,270,25);

detailPanel.add(l7);

final TextField tf6 = new TextField("",10);

tf6.setBounds(300,270,150,25);

detailPanel.add(tf6);

Label l8 = new Label("Comments:");

l8.setBounds(0,310,200,25);

detailPanel.add(l8);

final TextField tf7 = new TextField("",10);

tf7.setBounds(240,310,150,25);

detailPanel.add(tf7);

//The implementation of buttons

saveButton = new Button("SAVE");

saveButton.setBounds(80,350, BUTTON_WIDTH, BUTTON_HEIGHT);

detailPanel.add(saveButton);

resetButton = new Button("RESET");

resetButton.setBounds(180,350, BUTTON_WIDTH, BUTTON_HEIGHT);

detailPanel.add(resetButton);

cancelButton = new Button("CANCEL");

cancelButton.setBounds(280,350, BUTTON_WIDTH, BUTTON_HEIGHT);

detailPanel.add(cancelButton);

add(detailPanel,"East");

//The implementation of ActionListener

cancelButton.addActionListener (

new ActionListener() {

public void actionPerformed(ActionEvent e)

{

RecordTFrame lala = new RecordTFrame();

lala.show();

}

}

);

saveButton.addActionListener(

new ActionListener() {

public void actionPerformed(ActionEvent e) {

Statement stmt = con.createStatement();

stmt.executeUpdate("insert into HarvestFile (TreeID, SegmentCode, DateOfHarvest, NumberOfTrees, NumberRemaining, Revenue, ForestOfficer, Comments" +

"values ('" + tf1.getText() + "','" + tf.getText() + "','" + tf2.getText() + "','" + tf3.getText() + "','" +

tf5.getText() + "', '" + tf4.getText() + "','" + tf6.getText() + "','" + tf7.getText() + "')");

}

}

);

resetButton.addActionListener (

new ActionListener() {

public void actionPerformed(ActionEvent e)

{

tf.setText("");

tf1.setText("");

tf2.setText("");

tf3.setText("");

tf4.setText("");

tf5.setText("");

tf6.setText("");

tf7.setText("");

}

}

);

}

}

}//End of function

I'm also having trouble implaying event handling on this particular program. Can anyone suggest any why to implement event handeling for example the user is not suppose to enter str in a textfield

Thanks in advance!

Your help is GREATLY appreaciated...

pal

[5934 byte] By [palv] at [2007-9-26 1:51:40]
# 1

> try{

> url = "jdbc:odbc:PP";

>

> Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

> con = DriverManager.getConnection(url);

> }

>

> catch()

> {}

The catch (!):

try{

}

catch( Exception e ) {

}

missing the argument

mchan0 at 2007-6-29 3:00:25 > top of Java-index,Archived Forums,Java Programming...
# 2
*. u r not catching any Exception in catch()*. u can avoid user to modify TextField by saying :-textfieldobject.setEditable(false);-Mala
dev_mala at 2007-6-29 3:00:25 > top of Java-index,Archived Forums,Java Programming...
# 3
trap the exception.....catch (ClassNotFoundException ex) {System.err.println("Cannot find the database driver classes.");ex.printStackTrace();}
pedro.garcia at 2007-6-29 3:00:25 > top of Java-index,Archived Forums,Java Programming...
# 4
Thanks for the fast repalyI'm still having a probelm with the catch statement i've neven tried the two method suggested aboveOne more this i would like to add is how do i implement error handing using TextEvent or textlistener into my programThanks!pal
palv at 2007-6-29 3:00:25 > top of Java-index,Archived Forums,Java Programming...
# 5

Hello,

i've tried to work up on my file but i'm stiil getting this error and i can't understand why

on = DriverManager.getConnection(url);

unreported exception java.sql.SQLExceptionl must be caught or declared to be thrown

The codes are the same as the above

Thanks

pal

palv at 2007-6-29 3:00:25 > top of Java-index,Archived Forums,Java Programming...
# 6

Method in which u r getting connection , add this in method declaration :-

public your method (parameter) throws SQLException, FileNotFoundException {

body of method...

}

or

catch that code with :-

catch(SQLException se) {}

and

catch(FileNotFoundException fe) {}

-Mala

dev_mala at 2007-6-29 3:00:25 > top of Java-index,Archived Forums,Java Programming...