|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectweka.core.converters.DatabaseConnection
public class DatabaseConnection
Connects to a database. WARNING:This class was taken from the weka_src.jar and modified in order to put some logs and to make possible the connection to the DB through SpagoBI
Field Summary | |
---|---|
static int |
BOOL
|
static int |
BYTE
|
protected java.sql.Connection |
connection
The database connection |
static int |
DATE
|
static int |
DOUBLE
|
protected static java.util.Vector |
DRIVERS
Holds the jdbc drivers to be used (only to stop them being gc'ed) |
static int |
FLOAT
|
static int |
INTEGER
|
static int |
LONG
|
protected boolean |
m_checkForUpperCaseNames
|
protected boolean |
m_createIndex
|
protected java.lang.String |
m_DatabaseURL
Database URL |
protected boolean |
m_Debug
True if debugging output should be printed |
protected java.lang.String |
m_password
Database Password |
protected java.sql.PreparedStatement |
m_PreparedStatement
The prepared statement used for database queries. |
protected boolean |
m_setAutoCommit
|
protected java.lang.String |
m_userName
Database username |
protected static java.util.Properties |
PROPERTIES
Properties associated with the database connection |
protected static java.lang.String |
PROPERTY_FILE
The name of the properties file |
static int |
SHORT
|
static int |
STRING
|
Constructor Summary | |
---|---|
DatabaseConnection()
Sets up the database drivers. |
Method Summary | |
---|---|
static java.lang.String |
arrayToString(java.lang.Object[] array)
Converts an array of objects to a string by inserting a space between each element. |
void |
connectToDatabase()
Opens a connection to the database. |
java.lang.String |
databaseURLTipText()
Returns the tip text for this property. |
void |
disconnectFromDatabase()
Closes the connection to the database. |
boolean |
execute(java.lang.String query)
Executes a SQL query. |
boolean |
fastExecute(java.lang.String query)
Fast execute. |
java.lang.String |
getDatabaseURL()
Get the value of DatabaseURL. |
java.sql.DatabaseMetaData |
getMetaData()
Gets meta data for the database connection object. |
java.lang.String |
getPassword()
Get the database password. |
java.sql.ResultSet |
getResultSet()
Gets the results generated by a previous query. |
int |
getUpdateCount()
Dewtermines if the current query retrieves a result set or updates a table. |
boolean |
getUpperCase()
Check if the property checkUpperCaseNames in the DatabaseUtils file is set to true or false. |
java.lang.String |
getUsername()
Get the database username. |
boolean |
isConnected()
Returns true if a database connection is active. |
boolean |
isConnectionMenagedByExternalPool()
Checks if is connection menaged by external pool. |
boolean |
isTableEmpty(java.lang.String tableName)
Checks that a given table is empty. |
void |
setConnection(java.sql.Connection connection)
Sets the connection. |
void |
setConnectionMenagedByExternalPool(boolean connectionMenagedByExternalPool)
Sets the connection menaged by external pool. |
void |
setDatabaseURL(java.lang.String newDatabaseURL)
Set the value of DatabaseURL. |
void |
setPassword(java.lang.String password)
Set the database password. |
void |
setUsername(java.lang.String username)
Set the database username. |
boolean |
tableExists(java.lang.String tableName)
Checks that a given table exists. |
static java.lang.String |
typeName(int type)
Returns the name associated with a SQL type. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static java.lang.String PROPERTY_FILE
protected static java.util.Vector DRIVERS
protected static java.util.Properties PROPERTIES
protected java.lang.String m_DatabaseURL
protected java.sql.PreparedStatement m_PreparedStatement
protected java.sql.Connection connection
protected boolean m_Debug
protected boolean m_checkForUpperCaseNames
protected boolean m_setAutoCommit
protected boolean m_createIndex
protected java.lang.String m_userName
protected java.lang.String m_password
public static final int STRING
public static final int BOOL
public static final int DOUBLE
public static final int BYTE
public static final int SHORT
public static final int INTEGER
public static final int LONG
public static final int FLOAT
public static final int DATE
Constructor Detail |
---|
public DatabaseConnection() throws java.lang.Exception
java.lang.Exception
- the exception
java.lang.Exception
- if an error occursMethod Detail |
---|
public void setUsername(java.lang.String username)
username
- Username for Database.public java.lang.String getUsername()
public void setPassword(java.lang.String password)
password
- Password for Database.public java.lang.String getPassword()
public java.lang.String databaseURLTipText()
public java.lang.String getDatabaseURL()
public void setDatabaseURL(java.lang.String newDatabaseURL)
newDatabaseURL
- Value to assign to DatabaseURL.public boolean getUpperCase()
public static java.lang.String arrayToString(java.lang.Object[] array)
array
- the array of objects
public static java.lang.String typeName(int type)
type
- the SQL type
public void connectToDatabase() throws java.lang.Exception
java.lang.Exception
- the exception
java.lang.Exception
- if an error occurspublic void disconnectFromDatabase() throws java.lang.Exception
java.lang.Exception
- the exception
java.lang.Exception
- if an error occurspublic java.sql.DatabaseMetaData getMetaData() throws java.lang.Exception
java.lang.Exception
- the exception
java.sql.SQLException
- if an error occurspublic boolean isConnected()
public boolean execute(java.lang.String query) throws java.sql.SQLException
query
- the SQL query
java.sql.SQLException
- the SQL exception
java.sql.SQLException
- if an error occurspublic boolean fastExecute(java.lang.String query) throws java.sql.SQLException
query
- the query
java.sql.SQLException
- the SQL exceptionpublic java.sql.ResultSet getResultSet() throws java.sql.SQLException
java.sql.SQLException
- the SQL exception
java.sql.SQLException
- if an error occurspublic int getUpdateCount() throws java.sql.SQLException
java.sql.SQLException
- the SQL exception
java.sql.SQLException
- if an error occurspublic boolean tableExists(java.lang.String tableName) throws java.lang.Exception
tableName
- the name of the table to look for.
java.lang.Exception
- the exception
java.lang.Exception
- if an error occurs.public boolean isTableEmpty(java.lang.String tableName) throws java.lang.Exception
tableName
- the name of the table to look for.
java.lang.Exception
- the exception
java.lang.Exception
- if an error occurs.public boolean isConnectionMenagedByExternalPool()
public void setConnectionMenagedByExternalPool(boolean connectionMenagedByExternalPool)
connectionMenagedByExternalPool
- the new connection menaged by external poolpublic void setConnection(java.sql.Connection connection)
connection
- the new connection
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |