My FuelType variable is a char
how to set this in the PreparedStatement?
PreparedStatement ps = conexao.prepareStatement(sql);
ps.setString(1, veiculo.getTipoCombustivel());
My FuelType variable is a char
how to set this in the PreparedStatement?
PreparedStatement ps = conexao.prepareStatement(sql);
ps.setString(1, veiculo.getTipoCombustivel());
Exactly this way, however, it is necessary that the passed type be a String.
Therefore:
ps.setString(1, String.valueOf(veiculo.getTipoCombustivel()));
Type mapping:
JDBC Type Java Type
-------------------------------------------
CHAR String
VARCHAR String
LONGVARCHAR String
NUMERIC java.math.BigDecimal
DECIMAL java.math.BigDecimal
BIT boolean
BOOLEAN boolean
TINYINT byte
SMALLINT short