Illegal Start of Expression...>>

3 respostas
I

Estou tentando testar um BEAN via Console, mas estou esbarrando no erro Illegal Start of Expression. Toda referencia que encontrei citava que tal erro eh ocasionado pela omissao ou excedencia de uma chave ou parentese, mas nao consigo encontrar pelo menos. Alguem pode ajudar dar um help???

Esta classe tem a funcao de recuperar os dados contidos nos formularios de paginas JSP e realizar a atualizacao de um BD em Firebird.

Segue o codigo:

package ELN.Beans;

import java.sql.*;
import java.io.*;

public class PaBean {

String idAtividade="114";
String matColaborador="55567";
String local="Vila do Conde";
String dataPrevisao="18.07.2005";
String dataConcretizacao="18.08.2005";
String comoPrevisto="ioji";
String comoPrevisto2="uioi";
String comoPrevisto3="uio";
String razao="k,j,";
String custo="25";
String custoInvestimento="12";
String custoCusteio="13";


//------------------METODOS GET
public void setDataConcretizacao (String dataConcretizacao){
 this.dataConcretizacao = dataConcretizacao;
}

public void setIdAtividade(String idAtividade){
this.idAtividade = idAtividade;
}

public void setMatColaborador(String matColaborador){
this.matColaborador = matColaborador;
System.out.println("matColaborador="+matColaborador);
}
public void setLocal (String local){
this.local = local;
System.out.println("local="+local);
}
public void setDataPrevisao (String dataPrevisao){
this.dataPrevisao = dataPrevisao;
System.out.println("dataPrevisao="+dataPrevisao);
}

public void setComoPrevisto(String comoPrevisto){
 System.out.println("comoPrevisto="+comoPrevisto);
this.comoPrevisto = comoPrevisto;
}

public void setComoPrevisto2(String comoPrevisto2){

 System.out.println("comoPrevisto2="+comoPrevisto2);
  this.comoPrevisto2 =comoPrevisto2;
}

public void setComoPrevisto3(String comoPrevisto3){
 System.out.println("comoPrevisto3="+comoPrevisto3);
this.comoPrevisto3 = comoPrevisto3;
}

public void setRazao(String razao){
 System.out.println("razao="+razao);
this.razao = razao;
}

public void setCusto(String custo){
 System.out.println("custo="+custo);
this.custo=custo;
}

public void setCustoInvestimento(String custoInvestimento){
 System.out.println("custo de Investimento="+custoInvestimento);
this.custoInvestimento=custoInvestimento;
}

public void setCustoCusteio(String custoCusteio){
 System.out.println("custo de Custeio="+custoCusteio);
this.custoCusteio=custoCusteio;
}


//------------------METODOS GET
public String getIdAtividade(){
return(this.idAtividade);
}

public String getMatColaborador(){
return(this.matColaborador.trim());
}

public String getLocal(){
return(this.local.trim());
}

public String getDataPrevisao(){
return(this.dataPrevisao.trim());
}

public String getDataConcretizacao(){
return(this.dataConcretizacao.trim());
}

public String getComoPrevisto(){
return(this.comoPrevisto.trim());
}

public String getComoPrevisto2(){
return(this.comoPrevisto2.trim());
}

public String getComoPrevisto3(){
return(this.comoPrevisto3.trim());
}

public String getRazao(){
return(this.razao.trim());
}

public String getCusto(){
return(this.custo.trim());
}

public String getCustoInvestimento(){
return(this.custoInvestimento.trim());
}

public String getCustoCusteio(){
return(this.custoCusteio.trim());
}



public static void main(String args[]) {

    public String getResult(){
        String sql="";

        if(idAtividade.equals("") || matColaborador.equals("") || local.equals("") || dataPrevisao.equals("") || comoPrevisto.equals("") || razao.equals("") || (custoInvestimento.equals("") && custoCusteio.equals(""))){
        return("Faltam dados a serem preenchidos");
        System.out.println("Faltam dados a serem preenchidos");
        }

        try{
            Connection con = DriverManager.getConnection("jdbc:firebirdsql:10.5.3.2/3050:D:/Firebird/Agenda_2005.gdb", "sysdba", "masterkey");
            System.out.println("Conexão gerada com sucesso");
            if(comoPrevisto2.equals("")){
                sql ="INSERT INTO PA (intIdPa, intIdAtividade, matColaborador, strlocal, datPrevisao,DatConcretizacao, strComoPrevisto,strComoPrevisto3, strRazao, strCustoInvestimento, strCustoCusteio) VALUES (GEN_id(gn_idPa,1), '"+this.getIdAtividade()+"', '"+this.getMatColaborador()+"', '"+this.getLocal()+"', '"+this.getDataPrevisao()+"' , '"+this.getDataConcretizacao()+"','"+this.getComoPrevisto()+"', '"+this.getComoPrevisto3()+"', '"+this.getRazao()+"', '"+this.getCustoInvestimento()+"', '"+this.getCustoCusteio()+"')";
            }
            else if(comoPrevisto3.equals("")){
                sql ="INSERT INTO PA (intIdPa, intIdAtividade, matColaborador, strlocal, datPrevisao,DatConcretizacao, strComoPrevisto,strComoPrevisto2, strRazao, strCustoInvestimento, strCustoCusteio) VALUES (GEN_id(gn_idPa,1), '"+this.getIdAtividade()+"', '"+this.getMatColaborador()+"', '"+this.getLocal()+"', '"+this.getDataPrevisao()+"' , '"+this.getDataConcretizacao()+"','"+this.getComoPrevisto()+"', '"+this.getComoPrevisto2()+"', '"+this.getRazao()+"', '"+this.getCustoInvestimento()+"', '"+this.getCustoCusteio()+"')";
            }
            else{
                sql ="INSERT INTO PA (intIdPa, intIdAtividade, matColaborador, strlocal, datPrevisao,DatConcretizacao, strComoPrevisto,strComoPrevisto2,strComoPrevisto3, strRazao, strCustoInvestimento, strCustoCusteio) VALUES (GEN_id(gn_idPa,1), '"+this.getIdAtividade()+"', '"+this.getMatColaborador()+"', '"+this.getLocal()+"', '"+this.getDataPrevisao()+"' , '"+this.getDataConcretizacao()+"','"+this.getComoPrevisto()+"','"+this.getComoPrevisto2()+"','"+this.getComoPrevisto3()+"', '"+this.getRazao()+"', '"+this.getCustoInvestimento()+"', '"+this.getCustoCusteio()+"')";
            }

            PreparedStatement ps = con.prepareStatement(sql);
            ps.executeUpdate();
            //System.out.println("Registro inserido com sucesso em PA");
            ps.close();
            con.close();
            return("Registro Inserido Com sucesso!!");
            System.out.println("Registro Inserido Com Sucesso");
        }
        catch(Exception e){
            return("Erro ao Inserir Registro");
            System.out.println("Erro ao Inserir Registro");
        }
    }//Fim do Metodo getResult
}//Fim do Metodo Principal

}//Fim do Classe

[size=“11”]
[color=“red”]

  • Editado: Aumente as chances de alguém responder o seu tópico. Use BBCode em seus códigos para mantê-los identados e mais legíveis para outros usuários. - Matheus[/color][/size] :joia:

3 Respostas

M

Vc tem um método declarado dentro de outro método? O getResult() não pode ficar dentro do main!

I

OK… beleza. O que eu fiz agora foi tirar o getResult de dentro do MAIN. E como eu faco para chamar o getResult dentro do MAIN??? Esta dando a mensagem ‘non-static method getResult() cannot be referenced from a static context’. Ideias???

M

pra chamar um método dentro de um método static, o método chamado tb tem que ser static. É só definir o seu getResult() como static tb.

public static String getResult() {

   ...
}
Criado 18 de julho de 2005
Ultima resposta 18 de jul. de 2005
Respostas 3
Participantes 2