Estou fazendo uma classe dao, embora o metodo do java 5 estar dando problemas segundo o erro na linha "public List<Contato> getListaNome() throws SQLException ":
Exception in thread “main” java.lang.Error: Unresolved compilation problems:
The type List is not generic; it cannot be parameterized with arguments <Contato>
Syntax error, parameterized types are only available if source level is 5.0
The type List is not generic; it cannot be parameterized with arguments <Contato>
Syntax error, parameterized types are only available if source level is 5.0
The type ArrayList is not generic; it cannot be parameterized with arguments <Contato>
Syntax error, parameterized types are only available if source level is 5.0
lista cannot be resolved
at br.com.caelum.jdbc.ContatoDAO.<init>(ContatoDAO.java:33)
at br.com.caelum.jdbc.TesteInsere.main(TesteInsere.java:25)
CODE:
package br.com.caelum.jdbc;
import java.awt.List;
import java.sql.<em>;
import java.util.ArrayList;
import java.util.</em>;
import com.mysql.jdbc.PreparedStatement;
import com.mysql.jdbc.ResultSet;
public class ContatoDAO {
private Connection connection;
public ContatoDAO() throws SQLException
{
this.connection = ConnectionFactory.getConnection();
}
public void inseri(Contato contato) throws SQLException
{
String gravaContatos = "INSERT CONTATOS(NOME, EMAIL, ENDERECO) VALUES(?, ?, ?)";
PreparedStatement stmt = (PreparedStatement) this.connection.prepareStatement(gravaContatos);
stmt.setString(1, contato.getNome().toString());
stmt.setString(2, contato.getEmail().toString());
stmt.setString(3, contato.getEndereco().toString());
//executa
stmt.execute();
stmt.close();
}
[b]public List<Contato> getListaNome() throws SQLException
{
String strContatos = "SELECT * FROM CONTATOS";
PreparedStatement stmt = (PreparedStatement) this.connection.prepareStatement(strContatos);
ResultSet rs = (ResultSet) stmt.executeQuery();
List<Contato> list = new ArrayList<Contato>();
return lista;
}[/b]
}