Home > Default > Facing error in compiling

Facing error in compiling

November 30Hits:0
Advertisement
What does this error mean???
registerForm.java:189: reached end of file while parsing
} ->
1 error
Here the coding of that error
+++++++++++++++++++++
import javax.swing.JOptionPane ;
import java.awt.*;
import java.applet.*;
import java.lang.StringBuffer;
import java.io.IOException;
import java.io.*;
import java.sql.*; //allows sql calls to the database
public class registerForm //extends Applet implements ActionListener
     //private DataPanel myDataPanel;
     private Connection dbconn;
     private static int numPeople=0;
     private static String info;
          public static void getlinkDB()
               try
                    String url = "jdbc:odbc:registerDB"; //make this match your data source name
                    Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
                    dbconn = DriverManager.getConnection( url );
                    //info="Connection successful\n";
                    catch ( ClassNotFoundException cnfex ) //yes 3 catches
                         JOptionPane.showMessageDialog ( null,"ClassNotFoundException: " + getMessage());
                         //info=info+"Connection unsuccessful\n" + cnfex.toString();
                         catch ( SQLException sqlex )
                              JOptionPane.showMessageDialog ( null, sqlex.printStackTrace());
                              //info=info+"Connection unsuccessful\n" +sqlex.toString();
                              catch ( Exception excp )
                                   JOptionPane.showMessageDialog ( null, excp.printStackTrace());
                                   //info=info+excp.toString();
class AppletPanel extends Applet implements ActionListener
               Font reFont;
               Label labelform;
               Label labelUser;
               Label labelPassword;
               Label labelName;
               Label labelIC;
               Label labelEmail;
               TextField txtUser;
               TextField txtPassword;
               TextField txtName;
               TextField txtIC;
               TextField txtEmail;
               Button btnSubmit;
               Button btnReset;
          public void init()
               setLayout(null);
               reFont = new Font("Arial",Font.BOLD,20);
               labelform = new Label("Please fill up the form");
               labelform.setFont(reFont);
               labelUser = new Label("Username");
               labelUser.setFont(reFont);
               labelPassword = new Label("Password");
               labelName = new Label("Full Name");
               labelIC = new Label("IC Number");
               labelEmail = new Label("Email");
               txtUser = new TextField("");
               txtPassword = new TextField("");
               txtPassword.setEchoChar('*');
               txtName = new TextField("");
               txtIC = new TextField("");
               txtEmail = new TextField("");
               btnSubmit = new Button("Submit");
               btnReset = new Button("Reset");
               labelform.setBounds(20,20,300,50);
               labelUser.setBounds(20,90,120,30);
               labelPassword.setBounds(20,130,120,30);
               labelName.setBounds(20,170,120,30);
               labelIC.setBounds(20,210,120,30);
               labelEmail.setBounds(20,250,120,30);
               txtUser.setBounds(150,90,250,30);
               txtPassword.setBounds(150,130,250,30);
               txtName.setBounds(150,170,250,30);
               txtIC.setBounds(150,210,250,30);
               txtEmail.setBounds(150,250,250,30);
               btnSubmit.setBounds(190,300,100,30);
               btnReset.setBounds(300,300,100,30);
               add(labelform);
               add(labelUser);
               add(labelPassword);
               add(labelName);
               add(labelIC);
               add(labelEmail);
               add(txtUser);
               add(txtPassword);
               add(txtName);
               add(txtIC);
               add(txtEmail);
               add(btnSubmit);
               add(btnReset);
               btnSubmit.addActionListener(this);
               btnReset.addActionListener(this);
          public void actionPerformed(ActionEvent event)
                         String User=""; //must initialize to ""
                         String Pass="";
                         String Name="";
                         String IC="";
                         String Email="";
                         Object source=event.getSource();
                         User=txtUser.getText().trim();
                         txtUser.setText(User);
                         Pass=txtPassword.getText().trim(); //removes addtional characters
                    txtPassword.setText(Pass); //sets fields in their places
                    Name=txtName.getText().trim();
                         txtName.setText(Name);
                         IC=txtIC.getText().trim();
                         txtIC.setText(IC);
                         Email=txtEmail.getText().trim();
                         txtEmail.setText(Email);
                         if (source.equals(btnSubmit))
                    try {
                    Statement statement = dbconn.createStatement();
                    if ( !User.equals( "" ) && !Pass.equals( "" ) && !Name.equals( "" )
                              && !IC.equals( "" ) && !Email.equals("") )
                    String temp = "INSERT INTO register" +
                    "VALUES ('"+User+"', '"+Pass+"', '"+Name+"', '"+IC+"', '"+Email+"')";
                    //txtInfo.append( "\nInserting: " +
                    //dbconn.nativeSQL( temp ) + "\n" );
                    int result = statement.executeUpdate( temp );
                    if ( result == 1 )
                    {    //does a query to see if insertion successful
                              JOptionPane.showMessageDialog ( null,"Insertion successful");
                    else
                    JOptionPane.showMessageDialog ( null,"Insertion failed" );
                    txtUser.setText( "" );
                    txtPassword.setText( "" );
                    txtName.setText( "" );
                    txtIC.setText( "" );
                    txtEmail.setText( "" );
                    else
                    JOptionPane.showMessageDialog ( null,"Please Fill Up the Form Then Press Submit" );
                    statement.close();
                    catch ( SQLException sqlex )
                    JOptionPane.showMessageDialog ( null,"InsertData: " + sqlex.getMessage() );
                         //txtFirst.setText("Entry already exists -- reenter");
          }

Answers

I got the that error fixed but others error pop up haha.....
registerForm.java:21 invalid method declaration; return type required
public getlinkDB()
^
import javax.swing.JOptionPane ;
import java.awt.*;
import java.applet.*;
import java.lang.StringBuffer;
import java.io.IOException;
import java.io.*;
import java.sql.*;  //allows sql calls to the database
public class registerForm //extends Applet implements ActionListener
        //private DataPanel myDataPanel;
        private Connection dbconn;
        private static int numPeople=0;
        private static String info;
          public getlinkDB()
               try
                    String url = "jdbc:odbc:registerDB";  //make this match your data source name
                    Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
                    dbconn = DriverManager.getConnection(url);
                    //info="Connection successful\n";
               catch ( ClassNotFoundException cnfex )           //yes 3 catches
                    JOptionPane.showMessageDialog ( null,"ClassNotFoundException: " + getMessage());
                    //info=info+"Connection unsuccessful\n" + cnfex.toString();
               catch ( SQLException sqlex )
                    JOptionPane.showMessageDialog ( null, sqlex.printStackTrace());
                    //info=info+"Connection unsuccessful\n" +sqlex.toString();
               catch ( Exception excp )
                    JOptionPane.showMessageDialog ( null, excp.printStackTrace());
                    //info=info+excp.toString();
class AppletPanel extends Applet implements ActionListener
               Font reFont;
               Label labelform;
               Label labelUser;
               Label labelPassword;
               Label labelName;
               Label labelIC;
               Label labelEmail;
               TextField txtUser;
               TextField txtPassword;
               TextField txtName;
               TextField txtIC;
               TextField txtEmail;
               Button btnSubmit;
               Button btnReset;
          public void init()
               setLayout(null);
               reFont = new Font("Arial",Font.BOLD,20);
               labelform = new Label("Please fill up the form");
               labelform.setFont(reFont);
               labelUser = new Label("Username");
               labelUser.setFont(reFont);
               labelPassword = new Label("Password");
               labelName = new Label("Full Name");
               labelIC = new Label("IC Number");
               labelEmail = new Label("Email");
               txtUser = new TextField("");
               txtPassword = new TextField("");
               txtPassword.setEchoChar('*');
               txtName = new TextField("");
               txtIC = new TextField("");
               txtEmail = new TextField("");
               btnSubmit = new Button("Submit");
               btnReset = new Button("Reset");
               labelform.setBounds(20,20,300,50);
               labelUser.setBounds(20,90,120,30);
               labelPassword.setBounds(20,130,120,30);
               labelName.setBounds(20,170,120,30);
               labelIC.setBounds(20,210,120,30);
               labelEmail.setBounds(20,250,120,30);
               txtUser.setBounds(150,90,250,30);
               txtPassword.setBounds(150,130,250,30);
               txtName.setBounds(150,170,250,30);
               txtIC.setBounds(150,210,250,30);
               txtEmail.setBounds(150,250,250,30);
               btnSubmit.setBounds(190,300,100,30);
               btnReset.setBounds(300,300,100,30);
               add(labelform);
               add(labelUser);
               add(labelPassword);
               add(labelName);
               add(labelIC);
               add(labelEmail);
               add(txtUser);
               add(txtPassword);
               add(txtName);
               add(txtIC);
               add(txtEmail);
               add(btnSubmit);
               add(btnReset);
               btnSubmit.addActionListener(this);
               btnReset.addActionListener(this);
          public void actionPerformed(ActionEvent event)
                         String User="";     //must initialize to ""
                         String Pass="";
                         String Name="";
                         String IC="";
                         String Email="";
                         Object source=event.getSource();
                         User=txtUser.getText().trim();
                         txtUser.setText(User);
                         Pass=txtPassword.getText().trim();  //removes addtional characters
                        txtPassword.setText(Pass);          //sets fields in their places
                        Name=txtName.getText().trim();
                         txtName.setText(Name);
                         IC=txtIC.getText().trim();
                         txtIC.setText(IC);
                         Email=txtEmail.getText().trim();
                         txtEmail.setText(Email);
                         if (source.equals(btnSubmit))
                        try
                              Statement statement = dbconn.createStatement();
                              if ( !User.equals( "" ) && !Pass.equals( "" ) && !Name.equals( "" )
                                        && !IC.equals( "" ) && !Email.equals("") )
                                     String temp = "INSERT INTO register" +
                                        "VALUES ('"+User+"', '"+Pass+"', '"+Name+"', '"+IC+"', '"+Email+"')";
                                        //txtInfo.append( "\nInserting: " +
                                        //dbconn.nativeSQL( temp ) + "\n" );
                                  int result = statement.executeUpdate( temp );
                                  if ( result == 1 )
                                  {    //does a query to see if insertion successful
                                        JOptionPane.showMessageDialog ( null,"Insertion successful");
                                 else
                                     JOptionPane.showMessageDialog ( null,"Insertion failed" );
                                     txtUser.setText( "" );
                                     txtPassword.setText( "" );
                                     txtName.setText( "" );
                                     txtIC.setText( "" );
                                     txtEmail.setText( "" );
                                else
                                  JOptionPane.showMessageDialog ( null,"Please Fill Up the Form Then Press Submit" );
                               statement.close();
                            catch ( SQLException sqlex )
                               JOptionPane.showMessageDialog ( null,"InsertData: " + sqlex.getMessage() );
                                  //txtFirst.setText("Entry already exists -- reenter");
     }

Read other 9 answers

Tags:

Related Articles

Copyright (C) 2019 wisumpire.com, All Rights Reserved. webmaster#wisumpire.com 14 q. 0.643 s.