Ajuda com inserção no banco de dados [RESOLVIDO]

Pessoal
Tenho uma classe (abaixo) cujo método setAluno recebe uma arraylist de outra classe com os dados do aluno entao o método setAluno grava esses dados no banco

em retorno tenho os tres erros

e.getSQLState()
HY000

e.getMessage()
GDS Exception. 335544569. Dynamic SQL Error
SQL error code = -206
Column unknown
M
No message for code 336397208 found.
null
null

e.getLocalizedMessage()
GDS Exception. 335544569. Dynamic SQL Error
SQL error code = -206
Column unknown
M
No message for code 336397208 found.
null
null

Não sei mais oque estou fazendo de errado :roll:

segue o codigo


package Modelo;

import java.sql.*;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.firebirdsql.management.FBManager;


public class Conecta {
    static ResultSet rs;
    static Statement cmd;
    static Connection cnx;
    private static String sql;

    
    
    public Conecta() throws SQLException{
        DriverManager.registerDriver(new org.firebirdsql.jdbc.FBDriver());
        cnx = DriverManager.getConnection("jdbc:firebirdsql://localhost/c:/controlemensalidade/controlemensalidade.fdb", "SYSDBA", "masterkey");
        cnx.setAutoCommit(true);
        cmd = cnx.createStatement();
        
    }
        
        public void bancoTeste(){
        FBManager fbManager = new FBManager();
        fbManager.setServer("localhost");
        fbManager.setPort(3050);
            try {
                fbManager.start();
                fbManager.createDatabase("c:/controlemensalidade/teste.fdb", "SYSDBA", "masterkey");
                fbManager.stop();
            } catch (Exception ex) {
                 Logger.getLogger(Conecta.class.getName()).log(Level.SEVERE, null, ex);
                 System.out.println("Erro: "+ex.getMessage());
            }
        }

        //cmd.executeUpdate("INSERT INTO ALUNO (ID, NOME, RG, CPF, TITULOELEITOR, NOMEPAI, NOMEMAE, ESTADOCIVIL, DATANASCIMENTO, SEXO) VALUES (1,'SDF', 12, 12, 12, 'SDFSD', 'SF', 'A', 123, 'A');");

        public static String getAlunoId() throws SQLException{
        String aux="";

        rs = cmd.executeQuery("select ID from ALUNO where ID = (select max(ID) from ALUNO)");
        if(rs.next()){
            aux+=""+rs.getInt("ID")+"" ;
        }
        return aux;
        }

        public static boolean setAluno(ArrayList<Object> al) throws SQLException {
            boolean res=false;
            
            try{
                cmd.executeUpdate("INSERT INTO ALUNO (ID, NOME, RG, CPF, TITULOELEITOR, DATANASCIMENTO, SEXO, NOMEPAI, NOMEMAE) VALUES ("+al.get(0)+", '"+al.get(1)+"', "+al.get(8)+", "+al.get(9)+", "+al.get(10)+", "+al.get(11)+", "+al.get(12)+", "+al.get(13)+", "+al.get(14)+")");
                res=true;
            }catch(SQLException e){

                System.out.println("erro1" +e.getSQLState()+"   2"+e.getMessage()+"  3"+e.getLocalizedMessage()+" fim");

            }


            try{
                cmd.executeUpdate("INSERT INTO email (ID, IDALUNO, EMAIL, SERVIDOR) VALUES ("+getEmailId()+", "+al.get(0)+", '"+al.get(2)+"', '"+al.get(3)+"')");
                res=true;
            }catch(Exception e){
                System.out.println("erro2");
                res=false;
            }

            try{
                cmd.executeUpdate("INSERT INTO email2 (ID, IDALUNO, EMAIL, SERVIDOR) VALUES ("+getEmail2Id()+", "+al.get(0)+", '"+al.get(5)+"', '"+al.get(6)+"')");
                res=true;
            }catch(Exception e){
                System.out.println("erro3");
                res=false;
            }

            try{
                cmd.executeUpdate("INSERT INTO telefone (ID, IDALUNO, TELEFONE) VALUES ("+getTelefoneId()+", "+al.get(0)+", "+al.get(4)+")");
                res=true;
            }catch(Exception e){
                System.out.println("erro4");
                res=false;
            }

            try{
                cmd.executeUpdate("INSERT INTO telefone2 (ID, IDALUNO, TELEFONE) VALUES ("+getTelefone2Id()+", "+al.get(0)+", "+al.get(7)+")");
                res=true;
            }catch(Exception e){
                System.out.println("erro5");
                res=false;
            }

            return res;
        }

        public static String getEmailId() throws SQLException{
            String aux="";
            rs = cmd.executeQuery("select ID from email where ID = (select max(ID) from email)");
            if(rs.next()){
                aux+=""+rs.getInt("ID")+"" ;
            }
            return aux;
        }

        public static String getEmail2Id() throws SQLException{
            String aux="";
            rs = cmd.executeQuery("select ID from email2 where ID = (select max(ID) from email2)");
            if(rs.next()){
                aux+=""+rs.getInt("ID")+"" ;
            }
            return aux;
        }

        public static String getTelefoneId() throws SQLException{
            String aux="";
            rs = cmd.executeQuery("select ID from telefone where ID = (select max(ID) from telefone)");
            if(rs.next()){
                aux+=""+rs.getInt("ID")+"" ;
            }
            return aux;
        }

        public static String getTelefone2Id() throws SQLException{
            String aux="";
            rs = cmd.executeQuery("select ID from telefone2 where ID = (select max(ID) from telefone2)");
            if(rs.next()){
                aux+=""+rs.getInt("ID")+"" ;
            }
            return aux;
        }

        public void fechar() throws SQLException{
        rs.close();
        cmd.close();
        cnx.close();

        }
        
         



}

O método que insere os dados no banco esta na linha 52

Não sei se estou fazendo da forma certa (pelo visto não porq senão funcionaria :lol: )

[quote] cmd.executeUpdate("INSERT INTO ALUNO (ID, NOME, RG, CPF, TITULOELEITOR, DATANASCIMENTO, SEXO, NOMEPAI, NOMEMAE) VALUES ("+al.get(0)+", '"+al.get(1)+"', "+al.get(8)+", "+al.get(9)+", "+al.get(10)+", "+al.get(11)+", "+al.get(12)+", "+al.get(13)+", "+al.get(14)+")"); [/quote]
Usar SQL assim com concatenação de muitas strings é sempre má ideia, já que acabam por falhar as ’ quando se inserem CHAR.

Assim, o melhor é usar PreparedStatement: http://www.j2ee.me/javase/6/docs/api/java/sql/PreparedStatement.html

:roll: :roll:

Desculpe a ignorancia do macaco mas alguem teria um exemplo mais específico? :oops:

Somebody please!!..

:cry:

Problema resolvido…

Vários deles que nem sabia que eram problemas

A saga continua kkkk obrigado a todos
8) 8) 8)