2015-12-29 1:35 GMT+01:00 Rowan Worth <rowanw at dugeo.com>:

> On 29 December 2015 at 08:23, Cecil Westerhof <cldwesterhof at gmail.com>
> wrote:
>
> > When working in Python I can use:
> >     con.create_collation("mycollation", collate)
> >
> > To change the sort order. How should I do this in Java?
> >
>
> Note there are multiple ways to use sqlite from java, so it would help to
> specify which bindings you are using. eg. sqlite4java doesn't provide a
> create_collation call as far as I can tell.
>
> Based on your previous posts I assume you are accessing sqlite via JDBC; I
> can be no help there.
>

?I am using:
    https://github.com/xerial/sqlite-jdbc

For the moment being I read everything in an ArrayList and I sort that with
a Collation. Not the best solution, but the output is at the moment only 51
KB, so not a problem now.

Instead of using (as I should):
        bw    = new BufferedWriter(new FileWriter(outputfile));
        stmt  = conn.createStatement();
        rs    = stmt.executeQuery(selectProverbs);
        while (rs.next()) {
            bw.write(rs.getString("proverb") + "\n");
        }
        rs.close();
        stmt.close();
        bw.close();

I am using at the moment:
        stmt  = conn.createStatement();
        rs    = stmt.executeQuery(selectProverbs);
        while (rs.next()) {
            lineList.add(rs.getString("proverb"));
        }
        rs.close();
        stmt.close();
        Collections.sort(lineList, collator);
        out = new PrintWriter(new FileWriter(outputfile));
        for (String outputLine : lineList) {
            out.println(outputLine);
        }
        out.flush();
        out.close();

-- 
Cecil Westerhof

Reply via email to