code: public static LineString createLine(GeometryCollection points) throws SQLException {
          if(points == null) {
              return null;
          }
          final int size = points.getNumGeometries();
          if (!atLeastTwoPoints(points)) {
              throw new SQLException("At least two points are required to make a line.");
          }
          List<Coordinate> coordinateList = new LinkedList<Coordinate>();
          for (int i = 0; i < size; i++) {
              coordinateList.addAll(Arrays.asList(points.getGeometryN(i).getCoordinates()));
          }
          return points.getGeometryN(0).getFactory().createLineString(
                  coordinateList.toArray(new Coordinate[size]));
      }
docs: Constructs a LINESTRING from the given collection of POINTs and/or
  MULTIPOINTs
  
  @param points Points
  @return The LINESTRING constructed from the given collection of POINTs
  and/or MULTIPOINTs
  @throws SQLException