Errors in java database in sentences [closed]

0

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

    
asked by Karen Liliana Robledo 28.01.2016 в 22:39
source

3 answers

5

I was able to review your code more in detail. Effectively the code was modified intentionally by your teacher and has many type details

textfield1 -> notar el cambio de ld
textfiedl1

Where you have to find if some expression is misspelled.

We will not do you any good if we find the mistakes for you

But we can guide you

Step 1

Indent your code. If you work with notebook remember the basic rules. You can guide yourself to this very good article

Step 2

Do step 1 again. Seriously, your code is totally illegible and due to the brutal number of errors an IDE could not indent it, so it remains to do it by hand

Step 3

Be good at finding words written differently, for example nombreColumnas and nombresColumnas . There are many more scattered everywhere.

Step 4

Check your import s, it seems that some point to some wrong place.

It seems that there is no more, except for the consumption of the database that we can not prove, you should not do anything else.

    
answered by 28.01.2016 / 23:10
source
2

In Java as a rule it is to put names of classes in Capital Letter .

and check this line has an error:

 id=Integer.pardeI  nt(linea1);

staying like this:

        linea5=texfield5.getText();
        id=Integer.parseInt(linea1);

This block is missing a letter "i"

                                   }
f(id>0) {

staying like this:

                                 }
if(id>0) {

Those are 2 errors that your code has, could be more, for which you get the mentioned errors, I recommend you as I mentioned another user, depending on your IDE, first independence your code :

Eclipse: Crtl + Shift + f

Netbeans: Alt + Shift + f

Intellij IDEA Crtl + Alt + l

Temp

        //..
        public void tabla1() {
        //..
            } catch (SQLException e1) {
                System.out.println(el.getMessage());


                this.setTitle("Datos Ingresados Correctamente!!!");
            }
        //aqui
        public based1() {
        //..
        }

        public void actionPerformed(ActionEvent e) {
        //..
        }

        public static void main(String[] args) {
        //..
        }

} //si este fuera class falta en table1 }

hence this error:

'.class' expected
public static void main(String[] args) {
    
answered by 28.01.2016 в 22:58
0

Hello, I think the answers of others are good, this is to help you more instead of giving you the code well. My help is going The methods have a structure like the following:

midificadorAcceso valorDeRetorno nombreMetodo(argumentos){ }

access modifiers: default , public , private , protected return value any type of data or object in case the method does not return any value you would put the reserved word void name of the method the name must be some action in case the name is composed of two words the first letter of the name by convention is lower case and the first letter of the upper case, for example: setEdad() argunentos: the method can receive or not arguments if it receives an example would be the following: setEdad(int edad) < ----- first type of data and variable. In case you do not receive arguments, an example would be the following: getEdad()

    
answered by 29.01.2016 в 00:47