net.sf.bloof.db
Class Database

java.lang.Object
  |
  +--net.sf.bloof.db.Database

public class Database
extends java.lang.Object

This class manages the interaction with the database via JDBC Connection

Version:
$Id: Database.java,v 1.19 2003/09/06 08:35:09 pekacki Exp $
Author:
Lukasz Pekacki

Field Summary
protected static java.lang.String CREATE_INDEX_FILE
           
protected static java.lang.String CREATE_TABLE_FILE
           
protected static java.lang.String DROP_TABLE_FILE
           
 
Constructor Summary
Database(java.sql.Connection aConnection)
          Sets the connection and fills the hashtables with the already stored keys in the database
 
Method Summary
 void close()
          Closes the Database
 java.sql.ResultSet executeQuery(java.lang.String aSqlQuery)
          Returns the ResultSet for a SQL Query
 java.lang.String formatResultSet(java.sql.ResultSet aResultSet)
          Formats the ResultSet as plain mono-spaced text and outputs the result as String
 StringIterator getDevelopersOrderedByName()
          Returns the StringIterator of all Developers ordered by name
 StringIterator getFilesOrderdByPath()
          Returns the StringIterator of all Files ( pathname ) ordered by pathname
 java.sql.ResultSet getOnlyRowResultSet(java.lang.String aSqlQuery)
          Returns a result set that point on the first row.
 ScmAccess getProjectScmAccess()
          Returns the SCM Access to the project
 TimeInterval getTimespanBoundaries()
          Returns the maximum TimeInterval on the whole project
 void populateDatabase(ScmRevisionIterator aRevisonIter)
          Populates the database with the revisions of the specified RevisionIterator Already existing revisions will not be updated in the database
protected static void proccessDBScript(java.lang.String aScriptFileName, java.sql.Connection aDbConnection)
          Evaluates the input script and outputs the result to the output stream.
 void updateDatabase(ScmRevisionIterator aRevisonIter)
          Updates a project
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CREATE_TABLE_FILE

protected static final java.lang.String CREATE_TABLE_FILE
See Also:
Constant Field Values

CREATE_INDEX_FILE

protected static final java.lang.String CREATE_INDEX_FILE
See Also:
Constant Field Values

DROP_TABLE_FILE

protected static final java.lang.String DROP_TABLE_FILE
See Also:
Constant Field Values
Constructor Detail

Database

public Database(java.sql.Connection aConnection)
         throws java.sql.SQLException
Sets the connection and fills the hashtables with the already stored keys in the database

Parameters:
aConnection - The connection to set
Throws:
java.sql.SQLException - on connection error
Method Detail

proccessDBScript

protected static void proccessDBScript(java.lang.String aScriptFileName,
                                       java.sql.Connection aDbConnection)
                                throws java.io.IOException
Evaluates the input script and outputs the result to the output stream. Returns the list of Connections established.

Parameters:
aScriptFileName - name of the Script file
aDbConnection - connectin to the database
Throws:
java.io.IOException - on error

close

public void close()
           throws java.sql.SQLException,
                  java.io.IOException
Closes the Database

Throws:
java.sql.SQLException - on error
java.io.IOException - on error

executeQuery

public java.sql.ResultSet executeQuery(java.lang.String aSqlQuery)
                                throws java.sql.SQLException
Returns the ResultSet for a SQL Query

Parameters:
aSqlQuery - SQL statement to run on the database
Returns:
ResultSet for the specified SQL query
Throws:
java.sql.SQLException - on sql error

formatResultSet

public java.lang.String formatResultSet(java.sql.ResultSet aResultSet)
                                 throws java.sql.SQLException
Formats the ResultSet as plain mono-spaced text and outputs the result as String

Parameters:
aResultSet - input set
Returns:
String return
Throws:
java.sql.SQLException - on error

getDevelopersOrderedByName

public StringIterator getDevelopersOrderedByName()
                                          throws java.sql.SQLException
Returns the StringIterator of all Developers ordered by name

Returns:
StringIterator of a Select on all Developers
Throws:
java.sql.SQLException - on sql error

getFilesOrderdByPath

public StringIterator getFilesOrderdByPath()
                                    throws java.sql.SQLException
Returns the StringIterator of all Files ( pathname ) ordered by pathname

Returns:
StringIterator of a Select on all Files ( pathname ) ordered by pathname
Throws:
java.sql.SQLException - on sql error

getOnlyRowResultSet

public java.sql.ResultSet getOnlyRowResultSet(java.lang.String aSqlQuery)
                                       throws java.sql.SQLException
Returns a result set that point on the first row. This method is a shortcut for fetching a SELECT from a database that has only one row as result, e.g. "SELECHT COUNT( * ) FROM table". If the request has no result rows, null is returned

Parameters:
aSqlQuery - the query specified
Returns:
ResultSet
Throws:
java.sql.SQLException - on sql error

getProjectScmAccess

public ScmAccess getProjectScmAccess()
                              throws java.sql.SQLException
Returns the SCM Access to the project

Returns:
SCM Access to the project
Throws:
java.sql.SQLException - on db error

getTimespanBoundaries

public TimeInterval getTimespanBoundaries()
                                   throws java.sql.SQLException
Returns the maximum TimeInterval on the whole project

Returns:
TimeInterval of the whole project
Throws:
java.sql.SQLException - on sql error

populateDatabase

public void populateDatabase(ScmRevisionIterator aRevisonIter)
                      throws java.sql.SQLException
Populates the database with the revisions of the specified RevisionIterator Already existing revisions will not be updated in the database

Parameters:
aRevisonIter - Iterator for revisions
Throws:
java.sql.SQLException - if errors occur

updateDatabase

public void updateDatabase(ScmRevisionIterator aRevisonIter)
                    throws java.sql.SQLException
Updates a project

Parameters:
aRevisonIter - iterator on the new revisions
Throws:
java.sql.SQLException - on database error


Copyright © 2003 bloof@Sourceforge. All Rights Reserved.