I wrote the following code in a Java program.
public int insertRecord()
{
connection=PersistentieController.getInstance().getConnection();
int resultaat = 0;
String sql ="INSERT INTO TestDb (Nr Dossier, Année) VALUES (?,?)";
try
{
pstatement = initStatement(connection, sql);
pstatement.setString(1, "9999");
pstatement.setInt(2, 2012);
resultaat = pstatement.executeUpdate();
pstatement.close();
} //einde try
catch ( SQLException sqlException ){
sqlException.printStackTrace();
}
return resultaat;
} //einde insert()
I recieve an syntax error.
I checked that i don’t use reserved words.
Any ideas?
Thx.
you have escape the columnnames (with space such as
Nr Dossier) .backtick if you are using MySQL,
brackets if you are using SQLServer and MS Access,