title: invalid number oracle jdbc
body: <p>I'm trying to execute the following query:</p>
  
  <pre><code>String query =  "select NUMERO_CHAUFFEUR, avg(DISTANCE) as DISTANCE " +
                  "from " +
                  "(select NUMERO_CHAUFFEUR, " +
                  "6387.7 * ACOS((sin(LATITUDE_DEPART / 57.29577951) * SIN(LATITUDE_ARRIVEE / 57.29577951)) + " +
                  "(COS(LATITUDE_DEPART / 57.29577951) * COS(LATITUDE_ARRIVEE / 57.29577951) * " +
                  "COS(LONGITUDE_ARRIVEE / 57.29577951 - LONGITUDE_DEPART / 57.29577951))) as DISTANCE " +
                  "from " +
                  "(select l.NUMERO_CHAUFFEUR, " +
                  "regexp_substr(d1.COORDONNEES, '^[^,]+') as LATITUDE_DEPART, " +
                  "trim(leading ',' FROM regexp_substr(d1.COORDONNEES, ',.*$')) AS LONGITUDE_DEPART, " +
                  "regexp_substr(d2.COORDONNEES, '^[^,]+') as LATITUDE_ARRIVEE, " +
                  "trim(leading ',' FROM regexp_substr(d2.COORDONNEES, ',.*$')) AS LONGITUDE_ARRIVEE " +
                  "from LIVRAISONS l " +
                  "inner join DEPOTS d1 on(l.NUMERO_DEPOT_DEPART = d1.NUMERO_DEPOT) " +
                  "inner join DEPOTS d2 on(l.NUMERO_DEPOT_ARRIVE = d2.NUMERO_DEPOT) " +
                  ")) " +
                  "group by (NUMERO_CHAUFFEUR)";
  </code></pre>
  
  <p>But a java.sql.SQLException: ORA-01722: invalid number is being thrown. Does anyone know why? Because if I execute the query directly in sql using sqlplus it works fine.</p>
  
  <p>Result of execution of the query using sqlplus:</p>
  
  <pre><code>NUMERO_CHAUFFEUR AVG(DISTANCE)
  ---------------- -------------
             1    507.064894
             2    703.326572
             5    846.966137
             4    511.914202
  </code></pre>
  
  <p>I've tried the following but the error still persists:</p>
  
  <pre><code>String query =  "select NUMERO_CHAUFFEUR, avg(DISTANCE) as DISTANCE " +
                  "from " +
                  "(select NUMERO_CHAUFFEUR, " +
                  "to_number('6387.7') * ACOS((sin(LATITUDE_DEPART / to_number('57.29577951')) * SIN(LATITUDE_ARRIVEE / to_number('57.29577951'))) + " +
                  "(COS(LATITUDE_DEPART / to_number('57.29577951')) * COS(LATITUDE_ARRIVEE / to_number('57.29577951')) * " +
                  "COS(LONGITUDE_ARRIVEE / to_number('57.29577951') - LONGITUDE_DEPART / to_number('57.29577951')))) as DISTANCE " +
                  "from " +
                  "(select l.NUMERO_CHAUFFEUR, " +
                  "to_number(regexp_substr(d1.COORDONNEES, '^[^,]+')) as LATITUDE_DEPART, " +
                  "to_number(trim(leading ',' FROM to_number(regexp_substr(d1.COORDONNEES, ',.*$')))) AS LONGITUDE_DEPART, " +
                  "to_number(regexp_substr(d2.COORDONNEES, '^[^,]+')) as LATITUDE_ARRIVEE, " +
                  "to_number(trim(leading ',' FROM to_number(regexp_substr(d2.COORDONNEES, ',.*$')))) AS LONGITUDE_ARRIVEE " +
                  "from LIVRAISONS l " +
                  "inner join DEPOTS d1 on(l.NUMERO_DEPOT_DEPART = d1.NUMERO_DEPOT) " +
                  "inner join DEPOTS d2 on(l.NUMERO_DEPOT_ARRIVE = d2.NUMERO_DEPOT) " +
                  ")) " +
                  "group by (NUMERO_CHAUFFEUR)";
  </code></pre>