org.opennms.bb.common.db
Class DBConnection
java.lang.Object
|
+--org.opennms.bb.common.db.DBConnection
- public class DBConnection
- extends Object
This class is responsible for opening up the proper database
(information contained in the system property file) and for
executing various types of statements against the database such
as SELECT statements and CREATE statements.
- Version:
- $Revision: 1.7 $
- Author:
- Jason Johns, Vishwa Gujje, OpenNMS
Constructor Summary |
DBConnection()
Default constructor, read the property file to get database information
and opens the connection to the database. |
Methods inherited from class java.lang.Object |
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait |
m_conn
private Connection m_conn
- The connection to the database.
DBConnection
public DBConnection()
throws DBOpenFailureException
- Default constructor, read the property file to get database information
and opens the connection to the database.
executeSelect
public List executeSelect(String statement)
throws SQLException
- This method executes a SELECT statement on the connected database.
The resultset will be put into a List interface via an ArrayList
and returned.
- Parameters:
String
- statement, the SELECT statement to be run- Returns:
- List holding the result of the SELECT statement
- Throws:
SQLException
-
getResultSet
public ResultSet getResultSet(String statement)
throws SQLException
- This method executes a SELECT statement that returns a result set.
- Parameters:
String
- statement, the SELECT statement to be run- Returns:
- ResultSet, holding the result of the SELECT statement
- Throws:
SQLException
-
executeCreate
public void executeCreate(String statement)
throws SQLException
- This method will execute a CREATE, DELETE or similar
statement on the database.
- Parameters:
String
- statement, the statement to be run on the database- Throws:
SQLException
-
executeInsert
public void executeInsert(String sql)
throws SQLException
- This method will execute a INSERT,UPDATE, DELETE or similar
statement on the database.
- Parameters:
String
- sql, the prepared statement to be run on the database- Throws:
SQLException
-
prepareStatement
public PreparedStatement prepareStatement(String sqlStr)
throws SQLException
- This method creates a prepared statement
- Parameters:
sqlStr
- a SQL statement that may contain one or more '?'IN parameters- See Also:
java.sql.Connection#prepareStatement()