cli@42
|
1 |
/*
|
cli@42
|
2 |
* SONEWS News Server
|
cli@42
|
3 |
* see AUTHORS for the list of contributors
|
cli@42
|
4 |
*
|
cli@42
|
5 |
* This program is free software: you can redistribute it and/or modify
|
cli@42
|
6 |
* it under the terms of the GNU General Public License as published by
|
cli@42
|
7 |
* the Free Software Foundation, either version 3 of the License, or
|
cli@42
|
8 |
* (at your option) any later version.
|
cli@42
|
9 |
*
|
cli@42
|
10 |
* This program is distributed in the hope that it will be useful,
|
cli@42
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
cli@42
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
cli@42
|
13 |
* GNU General Public License for more details.
|
cli@42
|
14 |
*
|
cli@42
|
15 |
* You should have received a copy of the GNU General Public License
|
cli@42
|
16 |
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
cli@42
|
17 |
*/
|
cli@42
|
18 |
package org.sonews.storage.impl;
|
cli@42
|
19 |
|
cli@45
|
20 |
import java.sql.SQLException;
|
cli@45
|
21 |
import org.sonews.storage.Channel;
|
cli@42
|
22 |
import org.sonews.storage.Storage;
|
cli@45
|
23 |
import org.sonews.storage.StorageBackendException;
|
cli@42
|
24 |
|
cli@42
|
25 |
/**
|
cli@44
|
26 |
* A specialized JDBCDatabase supporting HSQLDB.
|
cli@42
|
27 |
* @author Christian Lins
|
cli@42
|
28 |
* @since sonews/1.1
|
cli@42
|
29 |
*/
|
cli@44
|
30 |
public class HSQLDB extends JDBCDatabase implements Storage {
|
cli@42
|
31 |
|
cli@45
|
32 |
@Override
|
cli@45
|
33 |
protected void prepareAddGroupStatement() throws SQLException {
|
cli@45
|
34 |
this.pstmtAddGroup0 = conn.prepareStatement(
|
cli@45
|
35 |
"INSERT INTO groups (name, flags, group_id) VALUES (?, ?, IDENTITY())");
|
cli@45
|
36 |
}
|
cli@42
|
37 |
|
cli@45
|
38 |
@Override
|
cli@45
|
39 |
protected void prepareCountGroupsStatement() throws SQLException {
|
cli@45
|
40 |
this.pstmtCountGroups = conn.prepareStatement(
|
cli@45
|
41 |
"SELECT Count(group_id) FROM groups WHERE "
|
cli@45
|
42 |
+ "BITAND(flags, " + Channel.DELETED + ") = 0");
|
cli@45
|
43 |
}
|
cli@45
|
44 |
|
cli@45
|
45 |
@Override
|
cli@45
|
46 |
protected void prepareGetPostingsCountStatement() throws SQLException {
|
cli@45
|
47 |
this.pstmtGetPostingsCount = conn.prepareStatement(
|
cli@45
|
48 |
"SELECT Count(*) FROM postings JOIN groups "
|
cli@45
|
49 |
+ "ON groups.name = ? GROUP BY groups.name");
|
cli@45
|
50 |
}
|
cli@45
|
51 |
|
cli@45
|
52 |
@Override
|
cli@45
|
53 |
protected void prepareGetSubscriptionsStatement() throws SQLException {
|
cli@45
|
54 |
this.pstmtGetSubscriptions = conn.prepareStatement(
|
cli@45
|
55 |
"SELECT * FROM (SELECT feedtype, host, port, peer_id FROM peers JOIN "
|
cli@45
|
56 |
+ "peer_subscriptions ON peers.peer_id = peer_subscriptions.peer_id) "
|
cli@45
|
57 |
+ "JOIN groups ON group_id = groups.group_id WHERE feedtype = ?");
|
cli@45
|
58 |
}
|
cli@42
|
59 |
}
|