summaryrefslogtreecommitdiffstats
path: root/org/madore/damlengine/WeblogSelect.java
blob: ad61cbc6e640370d14475e9de90642c9d9540a65 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package org.madore.damlengine;

import java.util.HashSet;
import java.util.ArrayList;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

public final class WeblogSelect {

    private WeblogSelect() { // Forbid instantiation
	throw new AssertionError("WeblogSelect cannot be instantiated");
    }

    public static void main(String[] args)
	throws Exception {

	String year = "2011";
	String month = "08";

	final Connection conn = WeblogDatabaseConnection.getConnection();

	final PreparedStatement selSt
	    = conn.prepareStatement("SELECT id , content FROM entries WHERE edate LIKE ? ORDER BY id DESC");
	selSt.setString(1,year+"-"+month+"-__");

	final ResultSet selRes = selSt.executeQuery();
	final Context.WeblogSelectionContext wsc
	    = new Context.WeblogMonthSelectionContext(year,month);
	wsc.sel = new HashSet<Integer>();
	wsc.xmlData = new ArrayList<String>();
	while ( selRes.next() ) {
	    int id = selRes.getInt(1);
	    String content = selRes.getString(2);
	    wsc.sel.add(new Integer(id));
	    wsc.xmlData.add(content);
	}

	DamlEngine.fullProcess("weblog-month-template.daml", System.out, wsc);

    }

}