0
I’m developing the system for a school.
I need to create the vacation part.
For this I need to add the number of days already launched so that per year are not launched more than 30 days per employee.
For this I saw that there is the SUM function of SQL
However it keeps giving column error not found.
I checked and the name of the column is identical.
Can someone tell me what happened?
public void getSomaQuantidadeFerias(String rf, String exercicio) { ArrayList<Integer> total = new ArrayList<Integer>();
try {
Connection con = new FabricaConexao("administracao").abrirConexao();
PreparedStatement stmt = con.prepareStatement("select sum(quantidade_dias) from ferias_alunos WHERE rf =? AND exercicio ?");
stmt.setString(1, rf);
stmt.setString(2, exercicio);
ResultSet rs = stmt.executeQuery();
while(rs.next()){
total.add(rs.getInt("quantidade_dias"));
}
for (int i = 0; i < total.size(); i++) {
System.out.println(total.get(i));
}
System.out.println(total);
rs.close();
stmt.close();
con.close();
}
catch (SQLException sql) {
JOptionPane.showMessageDialog(null, "Deu ruim");
sql.fillInStackTrace();
System.out.println(sql.getLocalizedMessage());
sql.printStackTrace();
}
Error:
net.ucanaccess.jdbc.UcanaccessSQLException: UCAExc:::4.0.3 Column not found: quantidade_dias
at control.CrtTelaAdministracao.getSomaQuantidadeFerias(CrtTelaAdministracao.java:1008)
at view.TelaFeriasA$2.actionPerformed(TelaFeriasA.java:418)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)UCAExc:::4.0.3 Column not found: quantidade_dias
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Hello Josi, is missing a space here holidays.
– Geilton Xavier Santos de Jesus
I did, but it didn’t solve the problem :(
– Josi
There is one operator missing in: "AND exercise ?"?
– anonimo