Swing/JDBC problem (edited message)

hello.

my name is james mcfadden. this is the same message as the last one called Swing/JDBC problem. i just made a little mistake when i was typing in the original message. i have developed a video library system. i have problems compiling the main program, which is called Demo.java. would you know what is causing these errors, and how should i correct them?

the errors as well as the code are shown below.

-jGRASP exec: javac -g X:\CP4B Project\Demo.java

ProductForm.java:57: int cannot be dereferenced

productNumber=Integer.parseInt(""+productNumber.getText());

^

ProductForm.java:58: setProductNumber(int) in Product cannot be applied to (java.lang.String)

p.setProductNumber(txtFlds[0].getText());

^

ProductForm.java:59: int cannot be dereferenced

productNumber = Integer.parseInt(productNumber.getText());

^

ProductForm.java:61: float cannot be dereferenced

rentalPrice=Float.parseFloat(""+rentalPrice.getText());

^

ProductForm.java:62: setRentalPrice(float) in Product cannot be applied to (java.lang.String)

p.setRentalPrice(txtFlds[2].getText());

^

ProductForm.java:63: float cannot be dereferenced

rentalPrice = Float.parseFloat(rentalPrice.getText());

^

ProductForm.java:66: int cannot be dereferenced

year=Integer.parseInt(""+year.getText());

^

ProductForm.java:67: setYear(int) in Product cannot be applied to (java.lang.String)

p.setYear(txtFlds[5].getText());

^

ProductForm.java:68: int cannot be dereferenced

year = Integer.parseInt(year.getText());

^

Member.java:8: cannot find symbol

symbol : class Date

location: class Member

Date dateOfBirth;

^

Member.java:9: cannot find symbol

symbol : class Date

location: class Member

Date dateRegistered;

^

Member.java:36: cannot find symbol

symbol : class Date

location: class Member

public void setDateOfBirth(Date m){

^

Member.java:40: cannot find symbol

symbol : class Date

location: class Member

public void setDateRegistered(Date n){

^

Member.java:69: cannot find symbol

symbol : class Date

location: class Member

public Date getDateOfBirth(){

^

Member.java:73: cannot find symbol

symbol : class Date

location: class Member

public Date getDateRegistered(){

^

MemberForm.java:59: int cannot be dereferenced

memberNumber=Integer.parseInt(""+memberNumber.getText());

^

MemberForm.java:60: setMemberNumber(int) in Member cannot be applied to (java.lang.String)

m.setMemberNumber(txtFlds[0].getText());

^

MemberForm.java:61: int cannot be dereferenced

memberNumber = Integer.parseInt(memberNumber.getText());

^

Rental.java:7: cannot find symbol

symbol : class Date

location: class Rental

Date rentalDate;

^

Rental.java:8: cannot find symbol

symbol : class Date

location: class Rental

Date returnDate;

^

Rental.java:33: cannot find symbol

symbol : class Date

location: class Rental

public void setRentalDate(Date o){

^

Rental.java:37: cannot find symbol

symbol : class Date

location: class Rental

public void setReturnDate(Date p){

^

Rental.java:70: cannot find symbol

symbol : class Date

location: class Rental

public Date getRentalDate(){

^

Rental.java:74: cannot find symbol

symbol : class Date

location: class Rental

public Date getReturnDate(){

^

RentalForm.java:60: int cannot be dereferenced

productNumber=Integer.parseInt(""+productNumber.getText());

^

RentalForm.java:61: setProductNumber(int) in Rental cannot be applied to (java.lang.String)

r.setProductNumber(txtFlds[0].getText());

^

RentalForm.java:62: int cannot be dereferenced

productNumber = Integer.parseInt(productNumber.getText());

^

RentalForm.java:64: int cannot be dereferenced

memberNumber=Integer.parseInt(""+memberNumber.getText());

^

RentalForm.java:65: setMemberNumber(int) in Rental cannot be applied to (java.lang.String)

r.setMemberNumber(txtFlds[2].getText());

^

RentalForm.java:66: int cannot be dereferenced

memberNumber = Integer.parseInt(memberNumber.getText());

^

RentalForm.java:72: float cannot be dereferenced

fine=Float.parseFloat(""+fine.getText());

^

RentalForm.java:73: setFine(float) in Rental cannot be applied to (java.lang.String)

r.setFine(txtFlds[8].getText());

^

RentalForm.java:74: float cannot be dereferenced

fine = Float.parseFloat(fine.getText());

^

RentalForm.java:85: cannot find symbol

symbol: variable address

stmt.executeUpdate("update rental set lastName= "+lastName+"address= "+address+"where memberNumber= "+memberNumber);

^

34 errors

-jGRASP wedge2: exit code for process is 1.

-jGRASP: operation complete.

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

import javax.swing.table.*;

import javax.swing.JOptionPane;

import java.sql.*;

/*

import java.awt.BorderLayout;

import java.awt.Component;

import java.io.IOException;

import java.net.URL;

import javax.media.CannotRealizeException;

import javax.media.Manager;

import javax.media.NoPlayerException;

import javax.media.Player;

import javax.swing.JPanel;

import java.io.File;

import java.net.MalformedURLException;

import javax.swing.JFileChooser;

import javax.swing.JFrame;

*/

public class Demo extends JFrame{

static String url="jdbc:odbc:VideoLibrary";

static Statement stmt;

static Connection con;

JTextField hostField;

JTextField queryField;

QueryTableModel qtm;

JComboBox comboBox;

public static void main(String[] args){

int choice=-1;

do{

choice=getChoice();

if(choice!=0){

getSelected(choice);

}//end if

}while(choice!=16);//end do-while

System.exit(0);//closes down the menu screen

/*

//create a file chooser

JFileChooser fileChooser=new JFileChooser();

//show open file dialog

int result=fileChooser.showOpenDialog( null );

if(result==JFileChooser.APPROVE_OPTION){//user chose a file

URL mediaURL=null;

try{

//get the file as URL

mediaURL=fileChooser.getSelectedFile().toURL();

}//end try

catch(MalformedURLException malformedURLException){

System.err.println("Could not create URL for the file");

} // end catch

if(mediaURL!=null){//only display if there is a valid URL

JFrame mediaTest=new JFrame("Media Tester");

mediaTest.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

mediaTest.add(mediaPanel);

mediaTest.setSize(300,300);

mediaTest.setVisible(true);

}//end inner if

}//end outer if

*/

}//end main

public static int getChoice(){

String choice;//a variable of type string

int ch;//a variable of type int

choice=JOptionPane.showInputDialog(null,"1.Add product details\n"+"2.Add member details\n"+"3.Add rental details\n"+"4.Edit product details\n"+"5.Edit member details\n"+"6.Edit rental details\n"+"7.Delete product details\n"+"8.Delete member details\n"+"9.Delete rental details\n"+"10. View product details\n"+"11. View member details\n"+"12. View rental details\n"+"13. Hear sound clips\n"+"14. View movie previews\n"+"15. View game previews\n"+"16. Log Off\n\n"+"Enter your choice");//asks the user for some input

ch=Integer.parseInt(choice);//a class that wraps a value of the primitive type int in an object

return ch;//a method that returns an integer value

}//end getChoice

public static void getSelected(int choice){

if(choice==1){

insertProducts();

}//end if

if(choice==2){

insertMembers();

}//end if

if(choice==3){

insertRentals();

}//end if

if(choice==4){

editProducts();

}//end if

if(choice==5){

editMembers();

}//end if

if(choice==6){

editRentals();

}//end if

if(choice==7){

deleteProducts();

}//end if

if(choice==8){

deleteMembers();

}//end if

if(choice==9){

deleteRentals();

}//end if

if(choice==10){

viewProducts();

}//end if

if(choice==11){

viewMembers();

}//end if

if(choice==12){

viewRentals();

}//end if

if(choice==13){

//hearSongs();

}//end if

if(choice==14){

//viewMovies();

}//end if

if(choice==15){

//viewGames();

}//end if

}//end getSelected

public static Connection getConnection(){

try {

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

}//end try

catch(java.lang.ClassNotFoundException e){

System.err.print("ClassNotFoundException: ");

System.err.println(e.getMessage());

}//end catch

try{

con=DriverManager.getConnection(url,"","");

}//end try

catch(SQLException ex) {

System.err.println("SQLException: " + ex.getMessage());

}//end catch

return con;

}//end getConnection

public static void insertProducts(){

ProductForm product=new ProductForm();

}

public static void insertMembers(){

MemberForm member=new MemberForm();

}

public static void insertRentals(){

RentalForm rental=new RentalForm();

}

public static void editProducts(){

ProductForm product=new ProductForm();

}

public static void editMembers(){

MemberForm member=new MemberForm();

}

public static void editRentals(){

RentalForm rental=new RentalForm();

}

public static void deleteProducts(){

ProductForm product=new ProductForm();

}

public static void deleteMembers(){

MemberForm member=new MemberForm();

}

public static void deleteRentals(){

RentalForm rental=new RentalForm();

}

public static void viewProducts(){

Demo test = new Demo();//invokes the constructor Demo()

test.setVisible(true);//shows the JTable component by marking it as visible

}

public static void viewMembers(){

Demo test = new Demo();//invokes the constructor Demo()

test.setVisible(true);//shows the JTable component by marking it as visible

}

public static void viewRentals(){

Demo test = new Demo();//invokes the constructor Demo()

test.setVisible(true);//shows the JTable component by marking it as visible

}

public static void hearSongs(){

//Demo mediaPanel=new Demo(mediaURL);

}

public static void viewMovies(){

//Demo mediaPanel=new Demo(mediaURL);

}

public static void viewGames(){

//Demo mediaPanel=new Demo(mediaURL);

}

public Demo(){//a constructor

super("Demo Test Frame");//overrides the constructor

setSize(350, 200);

comboBox = new JComboBox();//invokes the class JComboBox

comboBox.addItem("jdbc:odbc:VideoLibrary");

qtm = new QueryTableModel();//invokes the class QueryTableModel

JTable table = new JTable(qtm);

JScrollPane scrollpane = new JScrollPane(table);

JPanel p1 = new JPanel();

p1.setLayout(new GridLayout(3, 2));

p1.add(comboBox);

p1.add(new JLabel("Enter your query: "));

p1.add(queryField = new JTextField());

p1.add(new JLabel("Click here to send: "));

JButton jb = new JButton("Search");

jb.addActionListener(new ActionListener(){

public void actionPerformed(ActionEvent e){

qtm.setHostURL();//invokes the method setHostURL

qtm.setQuery(queryField.getText().trim());

}

} );//end addActionListener

p1.add(jb);

getContentPane().add(p1, BorderLayout.NORTH);

getContentPane().add(scrollpane, BorderLayout.CENTER);//Returns the content pane

}//end Demo

/*

public Demo(URL mediaURL){

setLayout(new BorderLayout());//use a BorderLayout

//Use lightweight components for Swing compatibility

Manager.setHint(Manager.LIGHTWEIGHT_RENDERER,true);

try{

//create a player to play the media specified in the URL

Player mediaPlayer=Manager.createRealizedPlayer(mediaURL);

//get the components for the video and the playback controls

Component video=mediaPlayer.getVisualComponent();

Component controls=mediaPlayer.getControlPanelComponent();

if(video!=null)

add(video,BorderLayout.CENTER);//add video component

if(controls!=null)

add(controls,BorderLayout.SOUTH);//add controls

mediaPlayer.start();//start playing the media clip

}//end try

catch(NoPlayerException noPlayerException){

System.err.println("No media player found");

}//end catch

catch(CannotRealizeException cannotRealizeException){

System.err.println("Could not realize media player");

}//end catch

catch(IOException iOException){

System.err.println("Error reading from the source");

}//end catch

}//end Demo

*/

}//end class Demo

import javax.swing.*;

import java.awt.*;

import java.awt.event.*;

import java.sql.*;

public class ProductForm extends JFrame{

JPanel pnlTitle,pnlBody,pnlFooter;

JButton btnDBAdd=new JButton("Add");

JButton btnDBEdit=new JButton("Edit");

JButton btnDBDelete=new JButton("Delete");

JLabel[] lblForm=new JLabel[14];

JLabel lblTitle=new JLabel("Product Form");

JTextField[] txtFlds=new JTextField[60];

String[] listFormNames={"Product Number","Name","Rental Price","Age Category","Type","Year"};

Container contentpane;

String url="jdbc:odbc:VideoLibrary";

Connection con=null;

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

//con=DriverManager.getConnection(url,"","");

int productNumber;

String name;

float rentalPrice;

String ageCategory;

String type;

int year;

public ProductForm(){

super("Product");

contentpane=getContentPane();

contentpane.setLayout(new BorderLayout());

pnlTitle=new JPanel();

pnlBody=new JPanel();

pnlFooter=new JPanel();

pnlBody.setLayout(new GridLayout(listFormNames.length,2,20,20));

for(int i=0;i<listFormNames.length;i++){

System.out.println(listFormNames);

lblForm=new JLabel(listFormNames);

pnlBody.add(lblForm);

txtFlds=new JTextField(25);

pnlBody.add(txtFlds);

}

lblTitle.setForeground(Color.RED);

pnlTitle.add(lblTitle);

pnlFooter.add(btnDBAdd);

pnlFooter.add(btnDBEdit);

pnlFooter.add(btnDBDelete);

contentpane.add(pnlTitle,BorderLayout.NORTH);

contentpane.add(pnlBody,BorderLayout.CENTER);

contentpane.add(pnlFooter,BorderLayout.SOUTH);

pack();

setVisible(true);

final Statement stmt=con.createStatement();

Product p=new Product();

productNumber=Integer.parseInt(""+productNumber.getText());

p.setProductNumber(txtFlds[0].getText());

productNumber = Integer.parseInt(productNumber.getText());

p.setName(txtFlds[1].getText());

rentalPrice=Float.parseFloat(""+rentalPrice.getText());

p.setRentalPrice(txtFlds[2].getText());

rentalPrice = Float.parseFloat(rentalPrice.getText());

p.setAgeCategory(txtFlds[3].getText());

p.setType(txtFlds[4].getText());

year=Integer.parseInt(""+year.getText());

p.setYear(txtFlds[5].getText());

year = Integer.parseInt(year.getText());

btnDBAdd.addActionListener(new ActionListener(){

public void actionPerformed(ActionEvent e){

stmt.executeUpdate("insert into product (productNumber,name,rentalPrice,ageCategory,type,year)"+"values("+productNumber+name+rentalPrice+ageCategory+type+year+")" );

}

});

btnDBEdit.addActionListener(new ActionListener(){

public void actionPerformed(ActionEvent e){

stmt.executeUpdate("update product set name= "+name+"where productNumber= "+productNumber);

}

});

btnDBDelete.addActionListener(new ActionListener(){

public void actionPerformed(ActionEvent e){

stmt.executeUpdate("delete * from product");

}

});

stmt.close();

con.close();

}

public static void main(String[] args){

ProductForm test=new ProductForm();

test.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

}

}

import javax.swing.*;

import java.awt.*;

import java.awt.event.*;

import java.sql.*;

public class MemberForm extends JFrame{

JPanel pnlTitle,pnlBody,pnlFooter;

JButton btnDBAdd=new JButton("Add");

JButton btnDBEdit=new JButton("Edit");

JButton btnDBDelete=new JButton("Delete");

JLabel[] lblForm=new JLabel[19];

JLabel lblTitle=new JLabel("Member Form");

JTextField[] txtFlds=new JTextField[70];

String[] listFormNames={"Member Number","First Name","Last Name","Address","Phone Number","Mobile Phone Number","Date of Birth","Date Registered"};

Container contentpane;

String url="jdbc:odbc:VideoLibrary";

Connection con=null;

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

//con=DriverManager.getConnection(url,"","");

int memberNumber;

String firstName;

String lastName;

String address;

String phoneNumber;

String mobilePhoneNumber;

Date dateOfBirth;

Date dateRegistered;

public MemberForm(){

super("Member");

contentpane=getContentPane();

contentpane.setLayout(new BorderLayout());

pnlTitle=new JPanel();

pnlBody=new JPanel();

pnlFooter=new JPanel();

pnlBody.setLayout(new GridLayout(listFormNames.length,2,20,20));

for(int i=0;i<listFormNames.length;i++){

System.out.println(listFormNames);

lblForm=new JLabel(listFormNames);

pnlBody.add(lblForm);

txtFlds=new JTextField(25);

pnlBody.add(txtFlds);

}

lblTitle.setForeground(Color.RED);

pnlTitle.add(lblTitle);

pnlFooter.add(btnDBAdd);

pnlFooter.add(btnDBEdit);

pnlFooter.add(btnDBDelete);

contentpane.add(pnlTitle,BorderLayout.NORTH);

contentpane.add(pnlBody,BorderLayout.CENTER);

contentpane.add(pnlFooter,BorderLayout.SOUTH);

pack();

setVisible(true);

final Statement stmt=con.createStatement();

Member m=new Member();

memberNumber=Integer.parseInt(""+memberNumber.getText());

m.setMemberNumber(txtFlds[0].getText());

memberNumber = Integer.parseInt(memberNumber.getText());

m.setFirstName(txtFlds[1].getText());

m.setLastName(txtFlds[2].getText());

m.setAddress(txtFlds[3].getText());

m.setPhoneNumber(txtFlds[4].getText());

m.setMobilePhoneNumber(txtFlds[5].getText());

m.setDateOfBirth(txtFlds[6].getText());

m.setDateRegistered(txtFlds[7].getText());

btnDBAdd.addActionListener(new ActionListener(){

public void actionPerformed(ActionEvent e){

stmt.executeUpdate("insert into member (memberNumber,firstName,lastName,address,phoneNumber,mobilePhoneNumber,dateOfBirth,dateRegistered)"+"values("+memberNumber+firstName+lastName+address+phoneNumber+mobilePhoneNumber+dateOfBirth+dateRegistered+")" );

}

});

btnDBEdit.addActionListener(new ActionListener(){

public void actionPerformed(ActionEvent e){

stmt.executeUpdate("update member set lastName= "+lastName+"address= "+address+"where memberNumber= "+memberNumber);

}

});

btnDBDelete.addActionListener(new ActionListener(){

public void actionPerformed(ActionEvent e){

stmt.executeUpdate("delete * from member");

}

});

stmt.close();

con.close();

}

public static void main(String[] args){

MemberForm test=new MemberForm();

test.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

}

}

import javax.swing.*;

import java.awt.*;

import java.awt.event.*;

import java.sql.*;

public class RentalForm extends JFrame{

JPanel pnlTitle,pnlBody,pnlFooter;

JButton btnDBAdd=new JButton("Add");

JButton btnDBEdit=new JButton("Edit");

JButton btnDBDelete=new JButton("Delete");

JLabel[] lblForm=new JLabel[16];

JLabel lblTitle=new JLabel("Rental Form");

JTextField[] txtFlds=new JTextField[60];

String[] listFormNames={"Product Number","Name","Member Number","First Name","Last Name","Rental Date","Return Date","Overdue Reminder","Fine"};

Container contentpane;

String url="jdbc:odbc:VideoLibrary";

Connection con=null;

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

//con=DriverManager.getConnection(url,"","");

int productNumber;

String name;

int memberNumber;

String firstName;

String lastName;

Date rentalDate;

Date returnDate;

String overdueReminder;

float fine;

public RentalForm(){

super("Rental");

contentpane=getContentPane();

contentpane.setLayout(new BorderLayout());

pnlTitle=new JPanel();

pnlBody=new JPanel();

pnlFooter=new JPanel();

pnlBody.setLayout(new GridLayout(listFormNames.length,2,20,20));

for(int i=0;i<listFormNames.length;i++){

System.out.println(listFormNames);

lblForm=new JLabel(listFormNames);

pnlBody.add(lblForm);

txtFlds=new JTextField(25);

pnlBody.add(txtFlds);

}

lblTitle.setForeground(Color.RED);

pnlTitle.add(lblTitle);

pnlFooter.add(btnDBAdd);

pnlFooter.add(btnDBEdit);

pnlFooter.add(btnDBDelete);

contentpane.add(pnlTitle,BorderLayout.NORTH);

contentpane.add(pnlBody,BorderLayout.CENTER);

contentpane.add(pnlFooter,BorderLayout.SOUTH);

pack();

setVisible(true);

final Statement stmt=con.createStatement();

Rental r=new Rental();

productNumber=Integer.parseInt(""+productNumber.getText());

r.setProductNumber(txtFlds[0].getText());

productNumber = Integer.parseInt(productNumber.getText());

r.setName(txtFlds[1].getText());

memberNumber=Integer.parseInt(""+memberNumber.getText());

r.setMemberNumber(txtFlds[2].getText());

memberNumber = Integer.parseInt(memberNumber.getText());

r.setFirstName(txtFlds[3].getText());

r.setLastName(txtFlds[4].getText());

r.setRentalDate(txtFlds[5].getText());

r.setReturnDate(txtFlds[6].getText());

r.setOverdueReminder(txtFlds[7].getText());

fine=Float.parseFloat(""+fine.getText());

r.setFine(txtFlds[8].getText());

fine = Float.parseFloat(fine.getText());

btnDBAdd.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

stmt.executeUpdate("insert into rental (productNumber,name,memberNumber,firstName,lastName,rentalDate,returnDate,overdueReminder,fine)"+"values("+productNumber+name+memberNumber+firstName+lastName+rentalDate+returnDate+overdueReminder+fine+")");

}

});

btnDBEdit.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

stmt.executeUpdate("update rental set lastName= "+lastName+"address= "+address+"where memberNumber= "+memberNumber);

}

});

btnDBDelete.addActionListener(new ActionListener() {

public final void actionPerformed(ActionEvent e) {

stmt.executeUpdate("delete * from rental");

}

});

stmt.close();

con.close();

}

public static void main(String[] args){

RentalForm test=new RentalForm();

test.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

}

}

public class Product{

int productNumber;

String name;

float rentalPrice;

String ageCategory;

String type;

int year;

//setters

public void setProductNumber(int a){

this.productNumber = a;

}

public void setName(String b){

this.name = b;

}

public void setRentalPrice(float c){

this.rentalPrice = c;

}

public void setAgeCategory(String d){

this.ageCategory = d;

}

public void setType(String e){

this.type = e;

}

public void setYear(int f){

this.year = f;

}

//getters

public int getProductNumber(){

return this.productNumber;

}

public String getName(){

return this.name;

}

public float getRentalPrice(){

return this.rentalPrice;

}

public String getAgeCategory(){

return this.ageCategory;

}

public String getType(){

return this.type;

}

public int getYear(){

return this.year;

}

}

public class Member{

int memberNumber;

String firstName;

String lastName;

String address;

String phoneNumber;

String mobilePhoneNumber;

Date dateOfBirth;

Date dateRegistered;

//setters

public void setMemberNumber(int g){

this.memberNumber = g;

}

public void setFirstName(String h){

this.firstName = h;

}

public void setLastName(String i){

this.lastName = i;

}

public void setAddress(String j){

this.address = j;

}

public void setPhoneNumber(String k){

this.phoneNumber = k;

}

public void setMobilePhoneNumber(String l){

this.mobilePhoneNumber = l;

}

public void setDateOfBirth(Date m){

this.dateOfBirth = m;

}

public void setDateRegistered(Date n){

this.dateRegistered = n;

}

//getters

public int getMemberNumber(){

return this.memberNumber;

}

public String getFirstName(){

return this.firstName;

}

public String getLastName(){

return this.lastName;

}

public String getAddress(){

return this.address;

}

public String getPhoneNumber(){

return this.phoneNumber;

}

public String getMobilePhoneNumber(){

return this.mobilePhoneNumber;

}

public Date getDateOfBirth(){

return this.dateOfBirth;

}

public Date getDateRegistered(){

return this.dateRegistered;

}

}

public class Rental{

int productNumber;

String name;

int memberNumber;

String firstName;

String lastName;

Date rentalDate;

Date returnDate;

String overdueReminder;

float fine;

//setters

public void setProductNumber(int a){

this.productNumber = a;

}

public void setName(String b){

this.name = b;

}

public void setMemberNumber(int g){

this.memberNumber = g;

}

public void setFirstName(String h){

this.firstName = h;

}

public void setLastName(String i){

this.lastName = i;

}

public void setRentalDate(Date o){

this.rentalDate = o;

}

public void setReturnDate(Date p){

this.returnDate = p;

}

public void setOverdueReminder(String q){

this.overdueReminder = q;

}

public void setFine(float r){

this.fine = r;

}

//getters

public int getProductNumber(){

return this.productNumber;

}

public String getName(){

return this.name;

}

public int getMemberNumber(){

return this.memberNumber;

}

public String getFirstName(){

return this.firstName;

}

public String getLastName(){

return this.lastName;

}

public Date getRentalDate(){

return this.rentalDate;

}

public Date getReturnDate(){

return this.returnDate;

}

public String getOverdueReminder(){

return this.overdueReminder;

}

public float getFine(){

return this.fine;

}

}>

[28723 byte] By [james-mcfaddena] at [2007-11-26 23:43:06]
# 1
http://forum.java.sun.com/thread.jspa?threadID=5155783
prometheuzza at 2007-7-11 15:12:42 > top of Java-index,Java Essentials,Java Programming...
# 2

To: prometheuzz : He knows that he has posted twice.

To the OP, i think you should firstly sort out the small problems of names that cannot be resolved etc. There is a load of them and do it class by class. Also int being dereferenced sort that out too, then post again, because there is a lot of code and i think its hard for people to fix because its simply too long. :)

abshirf2a at 2007-7-11 15:12:42 > top of Java-index,Java Essentials,Java Programming...
# 3

Try to compile your programs one by one if you are not using any IDE. Then you can figure out the problem easily.

In your program every error says that you are trying to get data from itself.

ProductForm.java:57: int cannot be dereferenced

productNumber=Integer.parseInt(""+productNumber.getText());

here you are trying to get text data from productNumber and trying to parse the same which is already an int variable.

Leelavathia at 2007-7-11 15:12:42 > top of Java-index,Java Essentials,Java Programming...
# 4
You can't use a method "getText" against an int or a float.Typically getText is used to get the String textual content from a GUI Textfield. I see you have a couple of those - queryField and hostField. Perhaps you meant to get the Text String from those?
abillconsla at 2007-7-11 15:12:42 > top of Java-index,Java Essentials,Java Programming...
# 5
> To: prometheuzz : He knows that he has posted twice.> > ...Three times. And in two of the three threads he got answered.
prometheuzza at 2007-7-11 15:12:42 > top of Java-index,Java Essentials,Java Programming...
# 6

hello.

thanks for the reply.

i forgot to give you all the 8th bit of code, which is shown below.

//Written by:Seamus McFadden

//Class:CP4B

//Program Number:2

//Program Name:QueryTableModel.java

//Description:A basic implementation of the TableModel interface that fills out a Vector of String[] structures from a query's result set

//Supervisor:Gerard McCloskey

import java.sql.*;//Provides the API for accessing and processing data stored in a data source using the Java programming language

import java.io.*;//Provides for system input and output through data streams, serialization and the file system

import java.util.Vector;//provides a class that implements a growable array of objects

import javax.swing.*;//Provides a set of lightweight components that, to the maximum degree possible, work the same on all platforms

import javax.swing.table.*;//Provides classes and interfaces for dealing with javax.swing.JTable

//From Marc Loy, et al.

//http://www.javafaq.nu/java-example-code-870.html

public class QueryTableModel extends AbstractTableModel{

Vector cache;//a class that constructs an empty vector so that its internal data array has size 10 and its standard capacity increment is zero

int colCount;//a variable that counts the number of columns in the three tables

String[] headers;//a class that represents character strings and all string literals in this program are implemented as instances of the String class

Connection db;//an interface that allows a connection to be made to a database

Statement statement;//an interface that allows executes the given SQL statement, which returns a single ResultSet object

String currentURL;//a variable that allows the URL to be displayed in a combo box

public QueryTableModel(){//a constructor

cache=new Vector();//constructs an empty vector so that its internal data array has size 10 and its standard capacity increment is zero

try{

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");//used by opening a JDBC connection using an URL

}//end try

catch(Exception e){

System.out.println("problem loading the driver ");//an error message

}//end catch

}//end QueryTableModel

public String getColumnName(int i){//Returns the designated column's name

return headers[i];//returns the name of each column in the three table

}//end getColumnName

public int getColumnCount(){//Returns the number of columns in the column model

return colCount;//returns the number of columns in the three tables

}//end getColumnCount

public int getRowCount(){//Returns the number of rows in this table's model

return cache.size();//returns the number of components in the vector

}//end getRowCount

public Object getValueAt(int row, int col){//Returns the cell value at row and column

return ((String[])cache.elementAt(row))[col];//Returns the component at the specified index

}//end getValueAt

public void setHostURL(){//sets the URL for the database

String url = "jdbc:odbc:VideoLibrary";//a variable that allows a connection to be made to a database called VideoLibrary

closeDB();//invokes the method closeDB()

try{

db=DriverManager.getConnection(url,"","");//tries to create a connection with the database using the DriverManager class

statement=db.createStatement();//Creates a Statement object for sending SQL statements to the database

}//end try

catch(Exception e){

System.out.println("Could not initialize the database.");//an error message

e.printStackTrace();//a Throwable method that prints this throwable and it's backtrace to the standard error stream

}//end catch

}//end setHostURL

public void setQuery(String q){//sets the kind of query that is to be sent to the database

cache=new Vector();//constructs an empty vector so that its internal data array has size 10 and its standard capacity increment is zero

String s="select * from Product";//a variable that causes all the data that is in the product table to be displayed in a JTable, which also means that all the data that is in both the member and rental tables can also be displayed in a JTable

try{

ResultSet rs=statement.executeQuery(q);//an interface that is used to generate a database result set by executing a statement that queries the database

ResultSetMetaData meta=rs.getMetaData();//an interface that is used to get information about the types and properties of the columns in a ResultSet object

colCount=meta.getColumnCount();//Returns the number of columns in this ResultSet object

headers=new String[colCount];//gets the name of each column in the three tables

for(int h=1;h<=colCount;h++){

headers[h-1]=meta.getColumnName(h);//Get the designated column's name

}//end for

while(rs.next()){

String[] record=new String[colCount];//stores the name of each column in the three tables in memory

for(int i=0;i<colCount;i++){

record[i]=rs.getString(i+1);//Retrieves the value of the designated column in the current row of this ResultSet object as a String

}//end for

cache.addElement(record);//Adds the specified component to the end of this vector, increasing its size by one

}//end while

fireTableChanged(null);//Forwards the given notification event to all TableModelListeners that registered themselves as listeners for this table model

}//end try

catch(Exception e){

cache=new Vector();//constructs an empty vector so that its internal data array has size 10 and its standard capacity increment is zero

e.printStackTrace();//a Throwable method that prints this throwable and it's backtrace to the standard error stream

}//end catch

}//end setQuery

public void initDB(String url){

try{

db=DriverManager.getConnection(url);//tries to create a connection with the database using the DriverManager class

statement=db.createStatement();//Creates a Statement object for sending SQL statements to the database

}//end try

catch(Exception e){

System.out.println("Could not initialize the database.");//an error message

e.printStackTrace();//a Throwable method that prints this throwable and it's backtrace to the standard error stream

}//end catch

}//end initDB

public void closeDB(){

try{

if(statement!=null){

statement.close();//Releases this Statement object's database and JDBC resources immediately instead of waiting for this to happen when it is automatically closed

}//end if

if(db!=null){

db.close();//Releases this Connection object's database and JDBC resources immediately instead of waiting for them to be automatically released

}//end if

}//end try

catch(Exception e){

System.out.println("Could not close the current connection.");//an error message

e.printStackTrace();//a Throwable method that prints this throwable and it's backtrace to the standard error stream

}//end catch

}//end closeDB

}//end class QueryTableModel

>

james-mcfaddena at 2007-7-11 15:12:42 > top of Java-index,Java Essentials,Java Programming...
# 7

hello.

thanks for the reply.

i forgot to give you all the 8th bit of code, which is shown below.

//Written by:Seamus McFadden

//Class:CP4B

//Program Number:2

//Program Name:QueryTableModel.java

//Description:A basic implementation of the TableModel interface that fills out a Vector of String[] structures from a query's result set

//Supervisor:Gerard McCloskey

import java.sql.*;//Provides the API for accessing and processing data stored in a data source using the Java programming language

import java.io.*;//Provides for system input and output through data streams, serialization and the file system

import java.util.Vector;//provides a class that implements a growable array of objects

import javax.swing.*;//Provides a set of lightweight components that, to the maximum degree possible, work the same on all platforms

import javax.swing.table.*;//Provides classes and interfaces for dealing with javax.swing.JTable

//From Marc Loy, et al.

//http://www.javafaq.nu/java-example-code-870.html

public class QueryTableModel extends AbstractTableModel{

Vector cache;//a class that constructs an empty vector so that its internal data array has size 10 and its standard capacity increment is zero

int colCount;//a variable that counts the number of columns in the three tables

String[] headers;//a class that represents character strings and all string literals in this program are implemented as instances of the String class

Connection db;//an interface that allows a connection to be made to a database

Statement statement;//an interface that allows executes the given SQL statement, which returns a single ResultSet object

String currentURL;//a variable that allows the URL to be displayed in a combo box

public QueryTableModel(){//a constructor

cache=new Vector();//constructs an empty vector so that its internal data array has size 10 and its standard capacity increment is zero

try{

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");//used by opening a JDBC connection using an URL

}//end try

catch(Exception e){

System.out.println("problem loading the driver ");//an error message

}//end catch

}//end QueryTableModel

public String getColumnName(int i){//Returns the designated column's name

return headers[i];//returns the name of each column in the three table

}//end getColumnName

public int getColumnCount(){//Returns the number of columns in the column model

return colCount;//returns the number of columns in the three tables

}//end getColumnCount

public int getRowCount(){//Returns the number of rows in this table's model

return cache.size();//returns the number of components in the vector

}//end getRowCount

public Object getValueAt(int row, int col){//Returns the cell value at row and column

return ((String[])cache.elementAt(row))[col];//Returns the component at the specified index

}//end getValueAt

public void setHostURL(){//sets the URL for the database

String url = "jdbc:odbc:VideoLibrary";//a variable that allows a connection to be made to a database called VideoLibrary

closeDB();//invokes the method closeDB()

try{

db=DriverManager.getConnection(url,"","");//tries to create a connection with the database using the DriverManager class

statement=db.createStatement();//Creates a Statement object for sending SQL statements to the database

}//end try

catch(Exception e){

System.out.println("Could not initialize the database.");//an error message

e.printStackTrace();//a Throwable method that prints this throwable and it's backtrace to the standard error stream

}//end catch

}//end setHostURL

public void setQuery(String q){//sets the kind of query that is to be sent to the database

cache=new Vector();//constructs an empty vector so that its internal data array has size 10 and its standard capacity increment is zero

String s="select * from Product";//a variable that causes all the data that is in the product table to be displayed in a JTable, which also means that all the data that is in both the member and rental tables can also be displayed in a JTable

try{

ResultSet rs=statement.executeQuery(q);//an interface that is used to generate a database result set by executing a statement that queries the database

ResultSetMetaData meta=rs.getMetaData();//an interface that is used to get information about the types and properties of the columns in a ResultSet object

colCount=meta.getColumnCount();//Returns the number of columns in this ResultSet object

headers=new String[colCount];//gets the name of each column in the three tables

for(int h=1;h<=colCount;h++){

headers[h-1]=meta.getColumnName(h);//Get the designated column's name

}//end for

while(rs.next()){

String[] record=new String[colCount];//stores the name of each column in the three tables in memory

for(int i=0;i<colCount;i++){

record[i]=rs.getString(i+1);//Retrieves the value of the designated column in the current row of this ResultSet object as a String

}//end for

cache.addElement(record);//Adds the specified component to the end of this vector, increasing its size by one

}//end while

fireTableChanged(null);//Forwards the given notification event to all TableModelListeners that registered themselves as listeners for this table model

}//end try

catch(Exception e){

cache=new Vector();//constructs an empty vector so that its internal data array has size 10 and its standard capacity increment is zero

e.printStackTrace();//a Throwable method that prints this throwable and it's backtrace to the standard error stream

}//end catch

}//end setQuery

public void initDB(String url){

try{

db=DriverManager.getConnection(url);//tries to create a connection with the database using the DriverManager class

statement=db.createStatement();//Creates a Statement object for sending SQL statements to the database

}//end try

catch(Exception e){

System.out.println("Could not initialize the database.");//an error message

e.printStackTrace();//a Throwable method that prints this throwable and it's backtrace to the standard error stream

}//end catch

}//end initDB

public void closeDB(){

try{

if(statement!=null){

statement.close();//Releases this Statement object's database and JDBC resources immediately instead of waiting for this to happen when it is automatically closed

}//end if

if(db!=null){

db.close();//Releases this Connection object's database and JDBC resources immediately instead of waiting for them to be automatically released

}//end if

}//end try

catch(Exception e){

System.out.println("Could not close the current connection.");//an error message

e.printStackTrace();//a Throwable method that prints this throwable and it's backtrace to the standard error stream

}//end catch

}//end closeDB

}//end class QueryTableModel

>

james-mcfaddena at 2007-7-11 15:12:43 > top of Java-index,Java Essentials,Java Programming...
# 8

hello.

thanks for the reply.

i forgot to give you all the 8th bit of code, which is shown below.

//Written by:Seamus McFadden

//Class:CP4B

//Program Number:2

//Program Name:QueryTableModel.java

//Description:A basic implementation of the TableModel interface that fills out a Vector of String[] structures from a query's result set

//Supervisor:Gerard McCloskey

import java.sql.*;//Provides the API for accessing and processing data stored in a data source using the Java programming language

import java.io.*;//Provides for system input and output through data streams, serialization and the file system

import java.util.Vector;//provides a class that implements a growable array of objects

import javax.swing.*;//Provides a set of lightweight components that, to the maximum degree possible, work the same on all platforms

import javax.swing.table.*;//Provides classes and interfaces for dealing with javax.swing.JTable

//From Marc Loy, et al.

//http://www.javafaq.nu/java-example-code-870.html

public class QueryTableModel extends AbstractTableModel{

Vector cache;//a class that constructs an empty vector so that its internal data array has size 10 and its standard capacity increment is zero

int colCount;//a variable that counts the number of columns in the three tables

String[] headers;//a class that represents character strings and all string literals in this program are implemented as instances of the String class

Connection db;//an interface that allows a connection to be made to a database

Statement statement;//an interface that allows executes the given SQL statement, which returns a single ResultSet object

String currentURL;//a variable that allows the URL to be displayed in a combo box

public QueryTableModel(){//a constructor

cache=new Vector();//constructs an empty vector so that its internal data array has size 10 and its standard capacity increment is zero

try{

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");//used by opening a JDBC connection using an URL

}//end try

catch(Exception e){

System.out.println("problem loading the driver ");//an error message

}//end catch

}//end QueryTableModel

public String getColumnName(int i){//Returns the designated column's name

return headers[i];//returns the name of each column in the three table

}//end getColumnName

public int getColumnCount(){//Returns the number of columns in the column model

return colCount;//returns the number of columns in the three tables

}//end getColumnCount

public int getRowCount(){//Returns the number of rows in this table's model

return cache.size();//returns the number of components in the vector

}//end getRowCount

public Object getValueAt(int row, int col){//Returns the cell value at row and column

return ((String[])cache.elementAt(row))[col];//Returns the component at the specified index

}//end getValueAt

public void setHostURL(){//sets the URL for the database

String url = "jdbc:odbc:VideoLibrary";//a variable that allows a connection to be made to a database called VideoLibrary

closeDB();//invokes the method closeDB()

try{

db=DriverManager.getConnection(url,"","");//tries to create a connection with the database using the DriverManager class

statement=db.createStatement();//Creates a Statement object for sending SQL statements to the database

}//end try

catch(Exception e){

System.out.println("Could not initialize the database.");//an error message

e.printStackTrace();//a Throwable method that prints this throwable and it's backtrace to the standard error stream

}//end catch

}//end setHostURL

public void setQuery(String q){//sets the kind of query that is to be sent to the database

cache=new Vector();//constructs an empty vector so that its internal data array has size 10 and its standard capacity increment is zero

String s="select * from Product";//a variable that causes all the data that is in the product table to be displayed in a JTable, which also means that all the data that is in both the member and rental tables can also be displayed in a JTable

try{

ResultSet rs=statement.executeQuery(q);//an interface that is used to generate a database result set by executing a statement that queries the database

ResultSetMetaData meta=rs.getMetaData();//an interface that is used to get information about the types and properties of the columns in a ResultSet object

colCount=meta.getColumnCount();//Returns the number of columns in this ResultSet object

headers=new String[colCount];//gets the name of each column in the three tables

for(int h=1;h<=colCount;h++){

headers[h-1]=meta.getColumnName(h);//Get the designated column's name

}//end for

while(rs.next()){

String[] record=new String[colCount];//stores the name of each column in the three tables in memory

for(int i=0;i<colCount;i++){

record[i]=rs.getString(i+1);//Retrieves the value of the designated column in the current row of this ResultSet object as a String

}//end for

cache.addElement(record);//Adds the specified component to the end of this vector, increasing its size by one

}//end while

fireTableChanged(null);//Forwards the given notification event to all TableModelListeners that registered themselves as listeners for this table model

}//end try

catch(Exception e){

cache=new Vector();//constructs an empty vector so that its internal data array has size 10 and its standard capacity increment is zero

e.printStackTrace();//a Throwable method that prints this throwable and it's backtrace to the standard error stream

}//end catch

}//end setQuery

public void initDB(String url){

try{

db=DriverManager.getConnection(url);//tries to create a connection with the database using the DriverManager class

statement=db.createStatement();//Creates a Statement object for sending SQL statements to the database

}//end try

catch(Exception e){

System.out.println("Could not initialize the database.");//an error message

e.printStackTrace();//a Throwable method that prints this throwable and it's backtrace to the standard error stream

}//end catch

}//end initDB

public void closeDB(){

try{

if(statement!=null){

statement.close();//Releases this Statement object's database and JDBC resources immediately instead of waiting for this to happen when it is automatically closed

}//end if

if(db!=null){

db.close();//Releases this Connection object's database and JDBC resources immediately instead of waiting for them to be automatically released

}//end if

}//end try

catch(Exception e){

System.out.println("Could not close the current connection.");//an error message

e.printStackTrace();//a Throwable method that prints this throwable and it's backtrace to the standard error stream

}//end catch

}//end closeDB

}//end class QueryTableModel

>

james-mcfaddena at 2007-7-11 15:12:43 > top of Java-index,Java Essentials,Java Programming...
# 9

hello.

thanks for the reply.

i forgot to give you all the 8th bit of code, which is shown below.

//Written by:Seamus McFadden

//Class:CP4B

//Program Number:2

//Program Name:QueryTableModel.java

//Description:A basic implementation of the TableModel interface that fills out a Vector of String[] structures from a query's result set

//Supervisor:Gerard McCloskey

import java.sql.*;//Provides the API for accessing and processing data stored in a data source using the Java programming language

import java.io.*;//Provides for system input and output through data streams, serialization and the file system

import java.util.Vector;//provides a class that implements a growable array of objects

import javax.swing.*;//Provides a set of lightweight components that, to the maximum degree possible, work the same on all platforms

import javax.swing.table.*;//Provides classes and interfaces for dealing with javax.swing.JTable

//From Marc Loy, et al.

//http://www.javafaq.nu/java-example-code-870.html

public class QueryTableModel extends AbstractTableModel{

Vector cache;//a class that constructs an empty vector so that its internal data array has size 10 and its standard capacity increment is zero

int colCount;//a variable that counts the number of columns in the three tables

String[] headers;//a class that represents character strings and all string literals in this program are implemented as instances of the String class

Connection db;//an interface that allows a connection to be made to a database

Statement statement;//an interface that allows executes the given SQL statement, which returns a single ResultSet object

String currentURL;//a variable that allows the URL to be displayed in a combo box

public QueryTableModel(){//a constructor

cache=new Vector();//constructs an empty vector so that its internal data array has size 10 and its standard capacity increment is zero

try{

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");//used by opening a JDBC connection using an URL

}//end try

catch(Exception e){

System.out.println("problem loading the driver ");//an error message

}//end catch

}//end QueryTableModel

public String getColumnName(int i){//Returns the designated column's name

return headers[i];//returns the name of each column in the three table

}//end getColumnName

public int getColumnCount(){//Returns the number of columns in the column model

return colCount;//returns the number of columns in the three tables

}//end getColumnCount

public int getRowCount(){//Returns the number of rows in this table's model

return cache.size();//returns the number of components in the vector

}//end getRowCount

public Object getValueAt(int row, int col){//Returns the cell value at row and column

return ((String[])cache.elementAt(row))[col];//Returns the component at the specified index

}//end getValueAt

public void setHostURL(){//sets the URL for the database

String url = "jdbc:odbc:VideoLibrary";//a variable that allows a connection to be made to a database called VideoLibrary

closeDB();//invokes the method closeDB()

try{

db=DriverManager.getConnection(url,"","");//tries to create a connection with the database using the DriverManager class

statement=db.createStatement();//Creates a Statement object for sending SQL statements to the database

}//end try

catch(Exception e){

System.out.println("Could not initialize the database.");//an error message

e.printStackTrace();//a Throwable method that prints this throwable and it's backtrace to the standard error stream

}//end catch

}//end setHostURL

public void setQuery(String q){//sets the kind of query that is to be sent to the database

cache=new Vector();//constructs an empty vector so that its internal data array has size 10 and its standard capacity increment is zero

String s="select * from Product";//a variable that causes all the data that is in the product table to be displayed in a JTable, which also means that all the data that is in both the member and rental tables can also be displayed in a JTable

try{

ResultSet rs=statement.executeQuery(q);//an interface that is used to generate a database result set by executing a statement that queries the database

ResultSetMetaData meta=rs.getMetaData();//an interface that is used to get information about the types and properties of the columns in a ResultSet object

colCount=meta.getColumnCount();//Returns the number of columns in this ResultSet object

headers=new String[colCount];//gets the name of each column in the three tables

for(int h=1;h<=colCount;h++){

headers[h-1]=meta.getColumnName(h);//Get the designated column's name

}//end for

while(rs.next()){

String[] record=new String[colCount];//stores the name of each column in the three tables in memory

for(int i=0;i<colCount;i++){

record[i]=rs.getString(i+1);//Retrieves the value of the designated column in the current row of this ResultSet object as a String

}//end for

cache.addElement(record);//Adds the specified component to the end of this vector, increasing its size by one

}//end while

fireTableChanged(null);//Forwards the given notification event to all TableModelListeners that registered themselves as listeners for this table model

}//end try

catch(Exception e){

cache=new Vector();//constructs an empty vector so that its internal data array has size 10 and its standard capacity increment is zero

e.printStackTrace();//a Throwable method that prints this throwable and it's backtrace to the standard error stream

}//end catch

}//end setQuery

public void initDB(String url){

try{

db=DriverManager.getConnection(url);//tries to create a connection with the database using the DriverManager class

statement=db.createStatement();//Creates a Statement object for sending SQL statements to the database

}//end try

catch(Exception e){

System.out.println("Could not initialize the database.");//an error message

e.printStackTrace();//a Throwable method that prints this throwable and it's backtrace to the standard error stream

}//end catch

}//end initDB

public void closeDB(){

try{

if(statement!=null){

statement.close();//Releases this Statement object's database and JDBC resources immediately instead of waiting for this to happen when it is automatically closed

}//end if

if(db!=null){

db.close();//Releases this Connection object's database and JDBC resources immediately instead of waiting for them to be automatically released

}//end if

}//end try

catch(Exception e){

System.out.println("Could not close the current connection.");//an error message

e.printStackTrace();//a Throwable method that prints this throwable and it's backtrace to the standard error stream

}//end catch

}//end closeDB

}//end class QueryTableModel

>

james-mcfaddena at 2007-7-11 15:12:43 > top of Java-index,Java Essentials,Java Programming...
# 10

Was that done for spite, to be funny, or just an honest mistake? Did you see the replies that refer to your compilation errors? These replies were meant to help you and should solicit an reply of confirmation in return, not just a barrage of code. Is there some missing communication?

~Bill

abillconsla at 2007-7-11 15:12:43 > top of Java-index,Java Essentials,Java Programming...