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