4
My typical variable is a char
how to set this in Preparedstatement ?
PreparedStatement ps = conexao.prepareStatement(sql);
ps.setString(1, veiculo.getTipoCombustivel());
4
My typical variable is a char
how to set this in Preparedstatement ?
PreparedStatement ps = conexao.prepareStatement(sql);
ps.setString(1, veiculo.getTipoCombustivel());
3
Exactly this way, however it is necessary that the type passed is 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
@Jarwin Convert your variable char
for String
. Luiz, if you can update your answer by adding this information, to reflect the update in the question. Then it is complete. Hug!
Browser other questions tagged java swing jdbc
You are not signed in. Login or sign up in order to post.
Use
ps.setString(1, String.valueOf(veiculo.getTipoCombustivel()));
– Franchesco
Thanks, it worked out !
– Marcelo T. Cortes