code: private void setNumeric(PreparedStatement stmt,
                              int varIndex,
                              String columnName,
                              String value) throws SQLException {
          try {
              stmt.setInt(varIndex, Integer.parseInt(value));
          } catch (NumberFormatException e) {
              try {
                  stmt.setLong(varIndex, Long.parseLong(value));
              } catch (NumberFormatException e2) {
                  throw new SQLException("Value specified for " + columnName
                          + ", '" + value + "' was"
                          + " specified as numeric, but is not");
              }
          }
      }
docs: Sets a numeric value in the prepared statement. Parsing the string is
  attempted as an int, then a long, and if that fails, a SQLException is
  thrown.