Package org.sonews.storage.impl.jdbc
Klasse JDBCDatabase
java.lang.Object
org.sonews.storage.impl.jdbc.JDBCDatabase
- Alle implementierten Schnittstellen:
Storage
Storage backend facade class for a relational SQL database using JDBC. The
statements used should work for at least PostgreSQL and MySQL.
- Seit:
- sonews/0.5.0
- Autor:
- Christian Lins
-
Feldübersicht
FelderModifizierer und TypFeldBeschreibungprotected Connectionprivate org.slf4j.Loggerstatic final intprotected PreparedStatementprotected PreparedStatementprotected PreparedStatementprotected PreparedStatementprotected PreparedStatementprotected PreparedStatementprotected PreparedStatementprotected PreparedStatementprotected PreparedStatementprotected PreparedStatementprotected PreparedStatementprotected PreparedStatementprotected PreparedStatementprotected PreparedStatementprotected PreparedStatementprotected PreparedStatementprotected PreparedStatementprotected PreparedStatementprotected PreparedStatementprotected PreparedStatementprotected PreparedStatementprotected PreparedStatementprotected PreparedStatementprotected PreparedStatementprotected PreparedStatementprotected PreparedStatementprotected PreparedStatementprotected PreparedStatementprotected PreparedStatementprotected PreparedStatementprotected PreparedStatementprotected intHow many times the database connection was reinitialized -
Konstruktorübersicht
Konstruktoren -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungvoidaddArticle(Article article) Adds an article to the database.protected voidaddArticle(Article article, int newArticleID) Adds an article to the database.protected voidarise()Rises the database: reconnect and recreate all prepared statements.booleanauthenticateUser(String username, char[] password) TODO Move to separate Authentication Backendvoidclose()Closes the JDBCDatabase connection.protected voidintvoidcreateOrUpdateGroup(Group group) voidgetArticle(long articleIndex, long gid) Retrieves an article by its ID.getArticle(String messageID) private StringgetArticleHeaders(long articleID) getArticleHeaders(Group group, long start, long end, String headerKey, String patStr) Searches for fitting header values using the given regular expression.getArticleHeads(Group group, long first, long last) Returns a list of Long/ArticleImpl Pairs.longgetArticleIndex(Article article, Group group) getArticleNumbers(long gid) intgetFirstArticleNumber(Group group) intgetLastArticleNumber(Group group) private intThis method is only called by addArticle which is already synchronized, so we do not need a synchronization here.private intgetMaxArticleIndex(long groupID) Returns the largest article index (watermark) in this very group.intgetPostingsCount(String groupname) booleanisArticleExisting(String messageID) Checks if there is an article with the given messageid in the JDBCDatabase.protected voidvoidpurgeGroup(Group group) Performes a purge operation in the storage backend, e.g. to delete old messages or release allocated resources.protected voidrestartConnection(SQLException cause) Restart the JDBC connection to the Database server.booleanUpdates headers and group references of the given article.protected voidupdateWatermark(Group group, long watermark)
-
Felddetails
-
MAX_RESTARTS
public static final int MAX_RESTARTS- Siehe auch:
-
log
private org.slf4j.Logger log -
conn
-
pstmtAddArticle1
-
pstmtAddArticle2
-
pstmtAddArticle3
-
pstmtAddArticle4
-
pstmtCountArticles
-
pstmtCreateOrUpdateGroup0
-
pstmtCreateOrUpdateGroup1
-
pstmtCreateOrUpdateGroup2
-
pstmtCreateOrUpdateGroup3
-
pstmtDeleteArticle0
-
pstmtDeleteArticle1
-
pstmtDeleteArticle2
-
pstmtDeleteArticle3
-
pstmtGetArticle0
-
pstmtGetArticle1
-
pstmtGetArticleHeaders0
-
pstmtGetArticleHeaders1
-
pstmtGetArticleHeads
-
pstmtGetArticleIDs
-
pstmtGetArticleIndex
-
pstmtGetFirstArticleNumber
-
pstmtGetGroups
-
pstmtGetLastArticleNumber
-
pstmtGetMaxArticleID
-
pstmtGetMaxArticleIndex
-
pstmtGetOldestArticle
-
pstmtGetPostingsCount
-
pstmtIsArticleExisting
-
pstmtPurgeGroup0
-
pstmtPurgeGroup1
-
pstmtUpdateWatermark
-
restarts
protected int restartsHow many times the database connection was reinitialized
-
-
Konstruktordetails
-
JDBCDatabase
public JDBCDatabase()
-
-
Methodendetails
-
prepareGetPostingsCountStatement
- Löst aus:
SQLException
-
arise
Rises the database: reconnect and recreate all prepared statements.- Löst aus:
SQLException
-
closeResultSet
-
addArticle
Adds an article to the database.- Angegeben von:
addArticlein SchnittstelleStorage- Parameter:
article-- Löst aus:
StorageBackendException
-
addArticle
protected void addArticle(Article article, int newArticleID) throws SQLException, StorageBackendException Adds an article to the database. Method is not synchronized as it is only called by an already synchronized method.- Parameter:
article-newArticleID-- Löst aus:
SQLExceptionStorageBackendException
-
countArticles
- Angegeben von:
countArticlesin SchnittstelleStorage- Löst aus:
StorageBackendException
-
createOrUpdateGroup
- Angegeben von:
createOrUpdateGroupin SchnittstelleStorage- Löst aus:
StorageBackendException
-
delete
- Angegeben von:
deletein SchnittstelleStorage- Löst aus:
StorageBackendException
-
getArticle
- Angegeben von:
getArticlein SchnittstelleStorage- Löst aus:
StorageBackendException
-
getArticle
Retrieves an article by its ID.- Angegeben von:
getArticlein SchnittstelleStorage- Parameter:
articleIndex-gid-- Gibt zurück:
- Löst aus:
StorageBackendException
-
getArticleHeaders
public List<Pair<Long,String>> getArticleHeaders(Group group, long start, long end, String headerKey, String patStr) throws StorageBackendException, PatternSyntaxException Searches for fitting header values using the given regular expression.- Angegeben von:
getArticleHeadersin SchnittstelleStorage- Parameter:
group-start-end-headerKey-patStr-- Gibt zurück:
- Löst aus:
StorageBackendExceptionPatternSyntaxException
-
getArticleHeaders
- Löst aus:
StorageBackendException
-
getArticleIndex
- Angegeben von:
getArticleIndexin SchnittstelleStorage- Löst aus:
StorageBackendException
-
getArticleHeads
public List<Pair<Long,Article>> getArticleHeads(Group group, long first, long last) throws StorageBackendException Returns a list of Long/ArticleImpl Pairs.- Angegeben von:
getArticleHeadsin SchnittstelleStorage- Parameter:
group-first-last-- Gibt zurück:
- Löst aus:
StorageBackendException
-
getArticleNumbers
- Angegeben von:
getArticleNumbersin SchnittstelleStorage- Löst aus:
StorageBackendException
-
getMaxArticleIndex
Returns the largest article index (watermark) in this very group. Currently this method returns an int but this is probably not enough for VERY large (or old) groups. The SQL template was changed to BIGINT but some servers may still use INTEGER here.- Parameter:
groupID-- Gibt zurück:
- Löst aus:
StorageBackendException
-
getGroups
- Angegeben von:
getGroupsin SchnittstelleStorage- Löst aus:
StorageBackendException
-
getMaxArticleID
This method is only called by addArticle which is already synchronized, so we do not need a synchronization here.- Gibt zurück:
- Löst aus:
StorageBackendException
-
getLastArticleNumber
- Angegeben von:
getLastArticleNumberin SchnittstelleStorage- Löst aus:
StorageBackendException
-
getFirstArticleNumber
- Angegeben von:
getFirstArticleNumberin SchnittstelleStorage- Löst aus:
StorageBackendException
-
getOldestArticle
- Angegeben von:
getOldestArticlein SchnittstelleStorage- Löst aus:
StorageBackendException
-
getPostingsCount
- Angegeben von:
getPostingsCountin SchnittstelleStorage- Löst aus:
StorageBackendException
-
isArticleExisting
Checks if there is an article with the given messageid in the JDBCDatabase.- Angegeben von:
isArticleExistingin SchnittstelleStorage- Parameter:
messageID-- Gibt zurück:
- Löst aus:
StorageBackendException
-
close
Closes the JDBCDatabase connection. -
purgeGroup
Beschreibung aus Schnittstelle kopiert:StoragePerformes a purge operation in the storage backend, e.g. to delete old messages or release allocated resources.- Angegeben von:
purgeGroupin SchnittstelleStorage- Parameter:
group-- Löst aus:
StorageBackendException
-
restartConnection
Restart the JDBC connection to the Database server.- Parameter:
cause-- Löst aus:
StorageBackendException
-
update
Beschreibung aus Schnittstelle kopiert:StorageUpdates headers and group references of the given article.- Angegeben von:
updatein SchnittstelleStorage- Parameter:
article-- Gibt zurück:
- Löst aus:
StorageBackendException
-
updateWatermark
- Löst aus:
StorageBackendException
-
authenticateUser
Beschreibung aus Schnittstelle kopiert:StorageTODO Move to separate Authentication Backend- Angegeben von:
authenticateUserin SchnittstelleStorage- Parameter:
username-password-- Gibt zurück:
- Löst aus:
StorageBackendException
-