com.atlassian.jira.web.action.util
Class DatabaseConnectionBean

java.lang.Object
  extended bycom.atlassian.jira.web.action.util.DatabaseConnectionBean
Direct Known Subclasses:
BugzillaConnectionBean, MantisConnectionBean

public class DatabaseConnectionBean
extends java.lang.Object

Bean for managing a JDBC connection - storing connection details, a Connection instance, and checking if a connection can be made. Most of this code is generic, and could be factored out if something other than Bugzilla needs it.


Constructor Summary
DatabaseConnectionBean(java.lang.String driverName, java.lang.String url, java.lang.String username, java.lang.String password, java.lang.String testSQL, java.lang.String testErrorMessage)
           
 
Method Summary
 void closeConnection()
           
 java.lang.String getCompleteURL()
           
 java.sql.Connection getConnection()
           
 java.lang.String getDriverName()
           
 java.lang.String getPassword()
           
 java.lang.String getTestSQL()
           
 java.lang.String getUrl()
           
 java.lang.String getUsername()
           
 java.lang.String isValid()
          Checks that we can make a connection to the specified database and run a test query.
 boolean isValidDriverName()
           
 boolean isValidUrl()
           
 void setDriverName(java.lang.String driverName)
           
 void setPassword(java.lang.String password)
           
 void setTestSQL(java.lang.String testSQL)
           
 void setUrl(java.lang.String url)
           
 void setUsername(java.lang.String username)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DatabaseConnectionBean

public DatabaseConnectionBean(java.lang.String driverName,
                              java.lang.String url,
                              java.lang.String username,
                              java.lang.String password,
                              java.lang.String testSQL,
                              java.lang.String testErrorMessage)
Method Detail

isValidDriverName

public boolean isValidDriverName()

isValidUrl

public boolean isValidUrl()

getCompleteURL

public java.lang.String getCompleteURL()
Returns:
the JDBC URL with username and password integrated

getConnection

public java.sql.Connection getConnection()
                                  throws java.sql.SQLException
Returns:
a Connection instance - always the same one unless JDBC details are changed.
Throws:
java.sql.SQLException

isValid

public java.lang.String isValid()
Checks that we can make a connection to the specified database and run a test query.

Returns:
An error message, or null if everything is OK

closeConnection

public void closeConnection()

getDriverName

public java.lang.String getDriverName()

setDriverName

public void setDriverName(java.lang.String driverName)

getUrl

public java.lang.String getUrl()

setUrl

public void setUrl(java.lang.String url)

getTestSQL

public java.lang.String getTestSQL()

setTestSQL

public void setTestSQL(java.lang.String testSQL)

getUsername

public java.lang.String getUsername()

setUsername

public void setUsername(java.lang.String username)

getPassword

public java.lang.String getPassword()

setPassword

public void setPassword(java.lang.String password)