cli@42: /* cli@42: * SONEWS News Server cli@42: * see AUTHORS for the list of contributors cli@42: * cli@42: * This program is free software: you can redistribute it and/or modify cli@42: * it under the terms of the GNU General Public License as published by cli@42: * the Free Software Foundation, either version 3 of the License, or cli@42: * (at your option) any later version. cli@42: * cli@42: * This program is distributed in the hope that it will be useful, cli@42: * but WITHOUT ANY WARRANTY; without even the implied warranty of cli@42: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the cli@42: * GNU General Public License for more details. cli@42: * cli@42: * You should have received a copy of the GNU General Public License cli@42: * along with this program. If not, see . cli@42: */ cli@42: package org.sonews.storage.impl; cli@42: cli@45: import java.sql.SQLException; cli@48: import org.sonews.storage.Group; cli@42: import org.sonews.storage.Storage; cli@42: cli@42: /** cli@44: * A specialized JDBCDatabase supporting HSQLDB. cli@42: * @author Christian Lins cli@42: * @since sonews/1.1 cli@42: */ cli@44: public class HSQLDB extends JDBCDatabase implements Storage { cli@42: cli@45: @Override cli@45: protected void prepareAddGroupStatement() throws SQLException { cli@45: this.pstmtAddGroup0 = conn.prepareStatement( cli@45: "INSERT INTO groups (name, flags, group_id) VALUES (?, ?, IDENTITY())"); cli@45: } cli@42: cli@45: @Override cli@45: protected void prepareCountGroupsStatement() throws SQLException { cli@45: this.pstmtCountGroups = conn.prepareStatement( cli@45: "SELECT Count(group_id) FROM groups WHERE " cli@48: + "BITAND(flags, " + Group.DELETED + ") = 0"); cli@45: } cli@45: cli@45: @Override cli@45: protected void prepareGetPostingsCountStatement() throws SQLException { cli@45: this.pstmtGetPostingsCount = conn.prepareStatement( cli@45: "SELECT Count(*) FROM postings JOIN groups " cli@45: + "ON groups.name = ? GROUP BY groups.name"); cli@45: } cli@45: cli@45: @Override cli@45: protected void prepareGetSubscriptionsStatement() throws SQLException { cli@45: this.pstmtGetSubscriptions = conn.prepareStatement( cli@45: "SELECT * FROM (SELECT feedtype, host, port, peer_id FROM peers JOIN " cli@45: + "peer_subscriptions ON peers.peer_id = peer_subscriptions.peer_id) " cli@45: + "JOIN groups ON group_id = groups.group_id WHERE feedtype = ?"); cli@45: } cli@42: }