I have problem with SQL query in JAVA.
JAVA code:
public boolean zeKontrolaExistujiciZalohyTest(String datum) {
        try {
            connected();
            boolean existujeZaloha = false;
            int pocet;
            ResultSet rs = statement.executeQuery("SELECT count(id) FROM "+table_ze+"\n" +
                            "WHERE TO_CHAR(TO_DATE(datum, 'dd.mm.yyyy'), 'mm.yyyy') = TO_CHAR(TO_DATE('"+datum+"', 'dd.mm.yyyy'), 'mm.yyyy')");            
            rs.next();
            pocet = rs.getInt(1);
            rs.close();
            closed();
            if (pocet >= 0) {
                existujeZaloha = true;
            } else {
                existujeZaloha = false;
            }
            return existujeZaloha;
        } catch (Exception e) {
            e.printStackTrace();
            Dialogs.create()
                .title("Exception Dialog")
                .showException(e);
            return true;
        }
    }
SQL query in SQL Developer:
SELECT count(id) FROM pbtest.u_zalohy_energie
WHERE TO_CHAR(TO_DATE(datum, 'dd.mm.yyyy'), 'mm.yyyy') = TO_CHAR(TO_DATE('15.09.2014', 'dd.mm.yyyy'), 'mm.yyyy');
When I run JAVA code, so result a variable is "pocet = 0". But, when I run SQL query in any the SQL Developer, so result column COUNT(id) is "1".
When I do change the SQL query, let me run JAVA code retuns a variable "pocet = 1".
Change sql code:
ResultSet rs = statement.executeQuery("SELECT count(id) FROM "+table_ze+"\n" +
            "WHERE datum = TO_DATE('"+datum+"', 'dd.mm.yyyy')");
Does anyone know where is the problem?
For information: I use an Oracle database.
Thank you.
 
     
     
    