|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.rapidminer.tools.jdbc.DatabaseHandler
public class DatabaseHandler
This class hides the database. Using
connect(String,String,boolean), you can extablish a
connection to the database. Once connected, queries and updates are possible.
Please note that the queries does not end with the statement terminator (e.g. ; for Oracle or GO for Sybase). The JDBC driver will automatically add the correct terminator.
| Field Summary | |
|---|---|
static int |
OVERWRITE_MODE_APPEND
|
static int |
OVERWRITE_MODE_NONE
|
static int |
OVERWRITE_MODE_OVERWRITE
|
static int |
OVERWRITE_MODE_OVERWRITE_FIRST
|
static java.lang.String[] |
OVERWRITE_MODES
|
| Constructor Summary | |
|---|---|
DatabaseHandler(java.lang.String databaseURL,
JDBCProperties properties)
Constructor of the database handler. |
|
| Method Summary | |
|---|---|
void |
addColumn(Attribute attribute,
java.lang.String tableName)
Adds a column for the given attribute to the table with name tableName. |
void |
commit()
Makes all changes to the database permanent. |
void |
connect(java.lang.String username,
java.lang.String passwd,
boolean autoCommit)
Establishes a connection to the database. |
static java.util.List<Attribute> |
createAttributes(java.sql.ResultSet rs)
Creates a list of attributes reflecting the result set's column meta data. |
java.sql.PreparedStatement |
createPreparedStatement(java.lang.String sqlString,
boolean scrollableAndUpdatable)
Create a prepared statement where result sets will have the properties TYPE_SCROLL_SENSITIVE and CONCUR_UPDATABLE. |
java.sql.Statement |
createStatement(boolean scrollableAndUpdatable)
Create a statement where result sets will have the properties TYPE_SCROLL_SENSITIVE and CONCUR_UPDATABLE. |
void |
createTable(ExampleSet exampleSet,
java.lang.String tableName,
int overwriteMode,
boolean firstAttempt,
int defaultVarcharLength)
Creates a new table in this connection and fills it with the provided data. |
void |
disconnect()
Closes the connection to the database. |
java.util.Map<java.lang.String,java.util.List<ColumnIdentifier>> |
getAllTableMetaData()
|
static DatabaseHandler |
getConnectedDatabaseHandler(java.lang.String databaseURL,
java.lang.String username,
java.lang.String password,
JDBCProperties properties,
LoggingHandler logging)
Returns a connected database handler instance from the given connection data. |
java.sql.Connection |
getConnection()
Returns the connection. |
static java.lang.String |
getDatabaseName(Attribute attribute)
Deprecated. Use the open and close quotes for identifiers from the properties instead |
JDBCProperties |
getProperties()
Returns the JDBC properties associated with this handler. |
static int |
getRapidMinerTypeIndex(int sqlType)
Returns for the given SQL-type the name of the corresponding RapidMiner-Type from com.rapidminer.tools.Ontology. |
java.sql.ResultSet |
query(java.lang.String sqlQuery)
Deprecated. Use the method createStatement(boolean) instead and perform the queries explicitely since this method would not allow closing the statement |
void |
removeColumn(Attribute attribute,
java.lang.String tableName)
Removes the column of the given attribute from the table with name tableName. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String[] OVERWRITE_MODES
public static final int OVERWRITE_MODE_NONE
public static final int OVERWRITE_MODE_OVERWRITE_FIRST
public static final int OVERWRITE_MODE_OVERWRITE
public static final int OVERWRITE_MODE_APPEND
| Constructor Detail |
|---|
public DatabaseHandler(java.lang.String databaseURL,
JDBCProperties properties)
connect(String, String, boolean). If you want to directly use
a connected database handler you might use the static method
getConnectedDatabaseHandler(String, String, String, JDBCProperties, LoggingHandler) instead.
| Method Detail |
|---|
public static DatabaseHandler getConnectedDatabaseHandler(java.lang.String databaseURL,
java.lang.String username,
java.lang.String password,
JDBCProperties properties,
LoggingHandler logging)
throws OperatorException,
java.sql.SQLException
OperatorException
java.sql.SQLExceptionpublic JDBCProperties getProperties()
public void connect(java.lang.String username,
java.lang.String passwd,
boolean autoCommit)
throws java.sql.SQLException
username - Name with which to log in to the database. Might be null.passwd - Password with which to log in to the database. Might be null.autoCommit - If TRUE, all changes to the database will be committed
automatically. If FALSE, the commit()-Method has to be called
to make changes permanent.
java.sql.SQLException
public void disconnect()
throws java.sql.SQLException
java.sql.SQLExceptionpublic java.sql.Connection getConnection()
public java.sql.Statement createStatement(boolean scrollableAndUpdatable)
throws java.sql.SQLException
SQLException if the handler is not connected.
java.sql.SQLException
public java.sql.PreparedStatement createPreparedStatement(java.lang.String sqlString,
boolean scrollableAndUpdatable)
throws java.sql.SQLException
SQLException if the handler is not connected.
java.sql.SQLException
public void commit()
throws java.sql.SQLException
java.sql.SQLException
@Deprecated
public java.sql.ResultSet query(java.lang.String sqlQuery)
throws java.sql.SQLException
createStatement(boolean) instead and perform the queries explicitely since this method would not allow closing the statement
sqlQuery - An SQL-String.
java.sql.SQLException
public void addColumn(Attribute attribute,
java.lang.String tableName)
throws java.sql.SQLException
java.sql.SQLException
public void removeColumn(Attribute attribute,
java.lang.String tableName)
throws java.sql.SQLException
java.sql.SQLException
public void createTable(ExampleSet exampleSet,
java.lang.String tableName,
int overwriteMode,
boolean firstAttempt,
int defaultVarcharLength)
throws java.sql.SQLException
java.sql.SQLException - if the table should be overwritten but a table with this name already existspublic static int getRapidMinerTypeIndex(int sqlType)
public static java.util.List<Attribute> createAttributes(java.sql.ResultSet rs)
throws java.sql.SQLException
java.sql.SQLException@Deprecated public static java.lang.String getDatabaseName(Attribute attribute)
public java.util.Map<java.lang.String,java.util.List<ColumnIdentifier>> getAllTableMetaData()
throws java.sql.SQLException
java.sql.SQLException
|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||