Problem to add values in JDBC

1

The console gives me the following error:

  

FUNCTION workday. SUM does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual

Can only sql be in my prepareStatement, help me!

Dao method

public List<ViagemBean> getListaTotalDiaria(String totalDiaira) {
    try {
        List<ViagemBean> viagens = new ArrayList<ViagemBean>();

        ConexaoMySQL.conectar();

        PreparedStatement stmt = ConexaoMySQL.getConexao()
                .prepareStatement("select SUM (valorDiaria) as total from viagem where colaborador = ? ");

        stmt.setString(1, totalDiaira);  

        ResultSet rs = stmt.executeQuery();

        while (rs.next()) {
            // criando o objeto viagem
            ViagemBean viagem = new ViagemBean();

            viagem.setValorDiaria(rs.getDouble("total"));

            // adicionando o objeto à lista
            viagens.add(viagem);
        }
        rs.close();
        stmt.close();
        return viagens;
    } catch (SQLException e) {
        throw new RuntimeException(e);
    }
}
    
asked by anonymous 04.07.2015 / 01:21

1 answer

1

You left a space between the function and the parameter.

select SUM (valorDiaria) 

Arrange for:

select SUM(valorDiaria) 
    
04.07.2015 / 01:26