This is a program which was provided to us by a teacher but most of all our teacher does not offer help and says that the program does not have mistakes and I need to correct my code because today I give it
The errors are the following (Excuse me if they are shown in image but
-**C:\Users\karen\Desktop\based1.java:90: illegal start of expression
public based1() {**
-C:\Users\karen\Desktop\based1.java:90: ';' expected
public based1() {
-C:\Users\karen\Desktop\based1.java:141: illegal start of expression
public void actionPerformed(ActionEvent e) {
-C:\Users\karen\Desktop\based1.java:141: illegal start of expression
public void actionPerformed(ActionEvent e) {
-C:\Users\karen\Desktop\based1.java:141: ';' expected
public void actionPerformed(ActionEvent e) {
-C:\Users\karen\Desktop\based1.java:141: ';' expected
public void actionPerformed(ActionEvent e) {
-C:\Users\karen\Desktop\based1.java:149: ';' expected
id=Integer.pardeI nt(linea1);
-C:\Users\karen\Desktop\based1.java:159: ';' expected
f(id>0) {
-C:\Users\karen\Desktop\based1.java:194: 'else' without 'if'
else{
-C:\Users\karen\Desktop\based1.java:207: illegal start of expression
public static void main(String[] args) {
-C:\Users\karen\Desktop\based1.java:207: illegal start of expression
public static void main(String[] args) {
-C:\Users\karen\Desktop\based1.java:207: ';' expected
public static void main(String[] args) {
^
-C:\Users\karen\Desktop\based1.java:207: '.class' expected
public static void main(String[] args) {
-C:\Users\karen\Desktop\based1.java:207: ';' expected
public static void main(String[] args) {
-C:\Users\karen\Desktop\based1.java:217: reached end of file while parsing
}
15 errors
Process completed.
The code of the program is as follows
// nota:solo ingresa 1 numero registro por vez
import java.awt.*;
import java.swing.*;
import java.awt.event.*;
import java.util.*;
import java.sql.*;
import java.util.Vector.*;
import java.swing.table.AbstrctModel;
import java.swing.event.TableModelEvent;
import java.swing.table.DefaultTableModel;
public class based1 extends JFrame implements ActionListener{
private JTextField textfield1,textfield2,textfield3,textfiedl4,textfield5;
private JLabel label1,label2,label4,label5;
private JButton boton1,boton2;
private JTextArea tecto;
//variables
int id ;
int aux1=0, aunx2=0,aux3=0,aux4=0,aux5=0;
float aux6=0;
String linea="";
String linea1="";
String linea2="";
String linea3="";
String linea4="";
String linea5="";
public void limpiar (){
textfield1.setText("");
textfield2.setText("");
textfield3.setText("");
textfield4.setText("");
textfield5.setText("");
}
public void tabla1(){
Vector nombreColumnas=new Vector ();
nombreColumnas.add("MATRICULA");
nombreColumnas.add("NOMBRES Y APELLIDOS");
nombreColumnas.add("EX1");
nombreColumnas.add("EX2");
nombreColumnas.add("EX3");
DefaultTableModel modelo=new DefaultTableModel (nombresColumnas,0);//0
JTable tabla=new JTable();
tabla.setModel(modelo);
try{ Class.forName ("sun.jdbc.odbc.Jdbc0dbcDriver");
} catch (ClassNotFoundException e1){
System.out.println(e1.getMessage());}
try{
String password ="";
//nombre de la base de datos Acces con extencion *.mdb o *.accdb
String dbName = "curso1.mdb";
//direccion de la base de datos
Sting db= System.getProperty ("user.dir") + "\" + dbName + ";PWD" +password;
Connection conexion = DriveManger.getConnection("jdbc:odbc:; Driver=Microsoft Access Driver( *.mdb,*.accdb);DBQ=");
statement estatuto = conexion.createStatement ();
ResultSet rs = estatuto.executeQuery ("select* FROM lista ORDER BY MATRICULA");
while (rs.next())
{
Vector v= new Vector();
v.add (rs.getString("MATRICULA"));
v.add (rs.getString("NOMBRE"));
v.add (rs.getString("EX1"));
v.add (rs.getString("EX2"));
v.add (rs.getString("EX3"));
modelo.addRow(v);
}
///WHILE
JScrollPane scroll=new JScrollPane (tabla);
this.getContentPane().add (scroll);
this.getContentPane().add(scroll);
scroll.setBounds(350,30,400,300);
scroll.setVievportView(tabla);
scroll.setVisible(true);
estatuto.close();
conexion.close();
}catch(SQLException e1) {System.out.println(el.getMessage());
this.setTitle("Datos Ingresados Correctamente!!!") ;
}
public based1() {
setLayout(null);
label1=new JLabel("Matricula:");
label1.setBounds(5,5,100,30);
add(Label1);
texfield1=new JTexfield();
texfield1.setBounds(65,10,100,20);
add(textfield1);
label2=new JLabel("Nombres:");
label1.setBounds(5,25,100,30);
add(Label2);
texfield2=new JTexfield();
texfield2.setBounds(65,32,200,21);
add(textfield2);
label3=new JLabel("Nota 1:");
label3.setBounds(5,53,100,30);
add(Label3);
texfield3=new JTexfield();
texfield3.setBounds(65,55,50,21);
add(textfield3);
label4=new JLabel("Nota 2:");
label4.setBounds(120,53,100,30);
add(Label4);
texfield4=new JTexfield();
texfield4.setBounds(170,55,50,21);
add(textfield4);
label5=new JLabel("Nota 3:");
label5.setBounds(225,53,100,30);
add(Label5);
texfield5=new JTexfield();
texfield5.setBounds(280,55,50,21);
add(textfield5);
boton1=new JButton("Grabar");
boton1.setMnemonic('G');
boton1.setBounds(10,120,100,30);
add(boton1);
boton1.addActionListener(this);
boton2=new JButton("Salir");
boton2.setMnemonic('S');
boton2.setBounds(10,120,100,30);
add(boton2);
boton2.addActionListener(this);
}
public void actionPerformed(ActionEvent e) {
if (e.getSource()==boton1) {
linea="";
linea1=texfield1.getText();
linea2=texfield2.getText();
linea3=texfield3.getText();
linea4=texfield4.getText();
linea5=texfield5.getText();
id=Integer.pardeI nt(linea1);
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
} catch(ClassNotFoundException e1) {
System.out.println(e1.getMessage());
}
f(id>0) {
try{
String password ="";
String dbName= "curso1.mdb";
String bd= System.getProperty("user.dir") + "\" + dbName + ";PWD=" + password;
Connection conexion =DriverManager.getConnection("jdbc:odbc:;Driver=Microsoft Acces Driver (*.mdb,*.accdb);DBQ=");
Statement estatuto= conexion.createStatement();
aux1=Integer.parseInt(linea1);
aux3=Integer.parseInt(linea3);
aux4=Integer.parseInt(linea4);
aux5=Integer.parseInt(linea5);
String q="insert into lista(MATRICULA,NOMBRE,EX1,EX2,EX3)values("+aux1 +", '"+linea2+"',"+aux3+","+aux4+","+aux5+")";
estatuto.executeUpdate(q);
estatuto.close();
conexion.close();
}catch(SQLException e1){
texto.append(e1.getMessage());
}
}
else{
JOptionPane.showMessageDialog(null, "La matricula es incorrecta, debe ser numerica");
}
tabla1();
limpiar();
}
if (e.getSource()==boton2) {
System.exit(0);
}
}
public static void main(String[] args) {
bassed1 formulario1=new bassed1();
formulario1.setBounds(1,50,850,450);
formulario1.setVisible(true);
formulario1.setTitle("Formulario de ingreso de Datos Java+Acces");
}
}
in advance I ask for an apology if it is of community annoyance my question, but I am new in programming and I have many doubts about this, thanks to all:)