Tenho a seguinte duvida: Crie um banco no MySQL com um campo do tipo Date, declarei-o tambem do tipo Date e nao consigo adicionar o campo no banco dá o seguinte erro:
Exception in thread "main" com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'int contato (nome, endereco, cidade, estado, aniversario(date),telefone, celular' at line 1
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:936)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2985)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1631)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1723)
at com.mysql.jdbc.Connection.execSQL(Connection.java:3283)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1332)
at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:882)
at Dao.ContatoDao.adiciona_Cont(ContatoDao.java:44)
at agendapessoal.Main.main(Main.java:65)
Java Result: 1
Fiz assim:
class Dao
public void adiciona_Cont(Contato cont1) throws SQLException{
String sql = "insert int contato (aniversario) values (?)";
PreparedStatement stmt = conexao.prepareStatement(sql);
stmt.setDate(1, cont1.getAniversario());
stmt.execute();
stmt.close
Class Main
Contato cont = new Contato();
cont.setAniversario(Date.valueOf("2005-5-30"));
ContatoDao dao = new ContatoDao();
dao.adiciona_Cont(cont);
Se alguem puder mim ajudar eu agradeço!