Persistir Date usando Reflexão

Ola pessoal…
estou tentando persistir um objeto do tipo Date utilizando reflexão,
mas o compilador rotorna um erro de sintaxe, exception java.sql.SQLSyntaxErrorException-Syntax
malditas linhas vermelhas que aparecem no meu console…iuehiuehie

eis o código que estou usando, se alguém puder me ajudar agradeço, pois jah bati bastante a kbeça tentndo resolver
vlwwww

public void insere(Object objeto) throws BDExceptions {

		StringBuilder sbInsert = new StringBuilder();
		StringBuilder sbValues = new StringBuilder();
	 try{
		sbInsert.append("insert into " + objeto.getClass().getSimpleName() + "(");
		for(Field f : objeto.getClass().getDeclaredFields()){
			if(!f.getName().equalsIgnoreCase("id")){
				f.setAccessible(true);
				sbInsert.append(f.getName() + ",");
				if(f.getType().toString().endsWith("String"))
					sbValues.append("'" + f.get(objeto) + "',");
				else 
					sbValues.append(f.get(objeto) + ",");
			}
		}
		sbInsert.replace(sbInsert.lastIndexOf(","), sbInsert.length(), ") values(");
		sbValues.replace(sbValues.lastIndexOf(","), sbValues.length(), ")");
		sbInsert.append(sbValues);
		
		System.out.println("SQL: " + sbInsert.toString());
		Statement s = this.conexao.createStatement();
		s.execute(sbInsert.toString());
	 }catch (SQLException e){
		 throw new BDExceptions(e.getClass().getName() + "-" + e.getMessage());
		
	}catch (IllegalArgumentException e) {
		 throw new BDExceptions(e.getClass().getName() + "-" + e.getMessage());
			
	}catch (IllegalAccessException e) {
		 throw new BDExceptions(e.getClass().getName() + "-" + e.getMessage());
	}
		
}
System.out.println("SQL: " + sbInsert.toString());

Cola aqui o resultado desse print.


SQL: insert into Veiculo(placa,tipo,modelo,montadora,tipoCombustivel,anoFabricacao,anoAquisicao) values('A','A','A','A','A',Fri Nov 01 00:00:00 BRST 3901,Wed Jan 01 00:00:00 BRST 3902)
execoes.BDExceptions: Exceção de BD : java.sql.SQLSyntaxErrorException-Syntax error: Encountered "Nov" at line 1, column 124.
	at dao.DAOReflexao.insere(DAOReflexao.java:50)
	at dao.DAOReflexao.main(DAOReflexao.java:69)

Entaum Anderson, eu usei o construtor Date(int, int, int) da classe Date passando ano, mes e dia
e ai estaum o resultado que vc pediu

e a exception que retornou
Obrigado desde jah pela ajuda

Como você ta fazendo a query sem nenhum ORM você não pode só passar o new Date porque seu banco não vai entender o “Fri Jul 25 00:00:00 BRT 3884” (Um framework de ORM faria a conversão pra você e funcionaria)

Uma forma que deve resolver é montando a data na mão:

sbValues.append( ((Date)f.get(objeto)).getYear() +  ((Date)f.get(objeto)).getMonth() + ((Date)f.get(objeto)).getDay() + ",");  

Acho que essa não é a forma maii bonita de resolver mas deve funcionar.

Lembrando que você vai precisar por aspas simples e somar 1 no mês, pois Janeiro é Zero.

Vou tentar uma forma melhor, se achar posto de novo pra ti.

[]s