title: Unable to fetch ID using Postgres Stored Function - Bad value for type int
body: <p>I am trying to get location information from the schema Location. 
  Postgres version is <code>9.3.15</code> and maven jar used is <code>9.4-1200-jdbc4</code> ubuntu 14.04 LTS. For connection pooling, I am using <code>mchange</code> version <code>0.9.5.2</code>.</p>
  
  <pre><code>org.postgresql.util.PSQLException: Bad value for type int : -,24.7477464699999992,32.7477464700000027,232328,xxxx,xxxxx,xxxx,"xxxx",India,landmark
      at org.postgresql.jdbc2.AbstractJdbc2ResultSet.toInt(AbstractJdbc2ResultSet.java:2962)
      at org.postgresql.jdbc2.AbstractJdbc2ResultSet.getInt(AbstractJdbc2ResultSet.java:2145)
      at com.mchange.v2.c3p0.impl.NewProxyResultSet.getInt(NewProxyResultSet.java:425)
      at com.creo.hike.direct.storage.jdbc.service.LocationService.getLocation(LocationService.java:74)
      at com.creo.hike.direct.storage.jdbc.service.LocationService.getLocation(LocationService.java:66)
      at com.creo.hike.direct.testapp.App.testLocationService(App.java:38)
      at com.creo.hike.direct.testapp.App.main(App.java:19)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
  </code></pre>
  
  <p>Location Schema. </p>
  
  <pre><code>CREATE TABLE Location (
      LocationId  SERIAL PRIMARY KEY,
      Latitude    DOUBLE PRECISION NOT NULL DEFAULT 0.0,
      Longitude   DOUBLE PRECISION NOT NULL DEFAULT 0.0,
      Pincode     INTEGER NOT NULL DEFAULT 0,
      InnerAddress TEXT NOT NULL DEFAULT 'Unknown',
      Locality     TEXT NOT NULL DEFAULT 'Unknown',
      City         TEXT NOT NULL DEFAULT 'Unknown',
      State        TEXT NOT NULL DEFAULT 'Unknown',
      Country      TEXT NOT NULL DEFAULT 'Unknown',
      Landmark     TEXT NOT NULL DEFAULT 'Unknown'
  );
  </code></pre>
  
  <p>Insertion of Location is working good, but when trying to fetch Location with generated <code>LocationId</code>, it is failed using stored function .
  Stored procedure - Getting location by id <code>gets_location_by_id</code></p>
  
  <pre><code>CREATE OR REPLACE FUNCTION gets_location_by_id(
      localId INTEGER
   ) RETURNS Location AS $$
    DECLARE
       row Location%ROWTYPE;
    BEGIN
       SELECT * INTO row
       FROM Location
           WHERE LocationId = localId;
       RETURN row;
    END;
    $$ LANGUAGE plpgsql;
  </code></pre>
  
  <p>Please let me know, if I am missing something here. Java code to get location by id is</p>
  
  <pre><code>String sql = "SELECT gets_location_by_id(?)";
  PreparedStatement statement = connection.prepareStatement(sql);
  statement.setInt(1, locationId);
  ResultSet resultSet  = statement.executeQuery();
   location = new Location(
                  resultSet.getInt(1),
                  resultSet.getDouble(2),
                  resultSet.getDouble(3),
                  resultSet.getInt(4),
                  resultSet.getString(5),
                  resultSet.getString(6),
                  resultSet.getString(7),
                  resultSet.getString(8),
                  resultSet.getString(9),
                  resultSet.getString(10));
  </code></pre>