Fórum MySqL em java #571618
25/11/2016
0
Joaquim Barbosa
Curtir tópico
+ 0Post mais votado
25/11/2016
Jones Granatyr
Gostei + 1
Mais Posts
25/11/2016
Eduardo Pessoa
Gostei + 0
26/11/2016
Joaquim Barbosa
Estou iniciando em JAVA, creio eu que o erro esteja no código a baixo.
public String buscaHorasByPlaca(EntrarBean entrada) throws SQLException {
PreparedStatement preparedStatement = null;
String sql = "SELECT horas from entrada where placa=?";
String horas = null;
try {
PreparedStatement ps = getCon().prepareStatement(sql);
preparedStatement.setInt(1, horas);
ResultSet rs = preparedStatement.executeQuery();
while (rs.next()) {
horas = rs.getString("horas");
System.out.println("placa : " + horas);
}
return horas;
} catch (SQLException e) {
System.out.println(e.getMessage());
} finally {
if (preparedStatement != null) {
preparedStatement.close();
}
if (getCon() != null) {
getCon().close();
}
}
}
Gostei + 0
26/11/2016
Joaquim Barbosa
Gostei + 0
26/11/2016
Joaquim Barbosa
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)