|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sourceforge.jdbdump.connect.DatabaseConnector net.sourceforge.jdbdump.connect.connectors.MysqlConnector
public class MysqlConnector
This is a class handling connection to the database, an implementation of the abstract class DatabaseConnector. It is a specific connector, providing connection to MySQL databases.
DatabaseConnector
Field Summary | |
---|---|
protected int |
columns
Number of columns in the current table. |
protected java.sql.ResultSet |
dataSet
A ResultSet storing table data when it is being downloaded. |
static int |
FETCH_SIZE
Maximum number of table records downloaded at a time. |
protected int |
position
Number of current record in a table while it is being downloaded. |
protected java.lang.String |
query
The query used to download next parts of a table into dataSet. |
Fields inherited from class net.sourceforge.jdbdump.connect.DatabaseConnector |
---|
connection, meta |
Constructor Summary | |
---|---|
MysqlConnector()
|
Method Summary | |
---|---|
protected void |
clearConstraints(Table table)
Removes constraints from the database's tables (if they exist), before they are dropped from the database and then inserted from a dump. |
protected void |
clearDatabase(Dump dump)
Clears tables from the database if they already exist, before they are inserted from a dump. |
void |
connect(java.lang.String url,
java.lang.String user,
java.lang.String pass)
Opens a connection to the database, using the provided connection data. |
java.lang.String |
createURL(DatabaseConnectionData data)
Creates a MySQL-specific JDBC connection url (it has the form: jdbc:mysql://host:port/database). |
Dump |
dump()
Creates a backup of the structure of the entire database. |
protected void |
dumpColumn(Column column,
java.sql.ResultSet rsColumns)
Downloads the structure of a single table column from the database. |
protected void |
dumpTableForeignKeys(Table table)
Downloads the table's foreign (imported) keys from the database. |
protected void |
dumpTablePrimaryKeys(Table table)
Downloads the table's primary key from the database. |
java.lang.String[] |
getTableDataLine()
Downloads one record of data from the previously initialized table in database. |
void |
initializeTableData(java.lang.String tableName)
Prepares the given table for downloading its data. |
void |
restore(Dump dump)
Restores the structure of the database from a Dump object loaded from a previously created backup file. |
protected void |
restoreTableConstraints(Table table)
Restores the table's constraints (e.g. |
protected void |
restoreTableData(Table table)
Restores the table's data into the database. |
protected void |
restoreTableStructure(Table table)
Creates a single table using information from a dump. |
Methods inherited from class net.sourceforge.jdbdump.connect.DatabaseConnector |
---|
connect, disconnect, dumpTable, dumpTables, printResultSet |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.sql.ResultSet dataSet
protected java.lang.String query
protected int position
protected int columns
public static final int FETCH_SIZE
Constructor Detail |
---|
public MysqlConnector()
Method Detail |
---|
public void connect(java.lang.String url, java.lang.String user, java.lang.String pass) throws java.sql.SQLException, java.lang.ClassNotFoundException
connect
in class DatabaseConnector
url
- a correct connection URLuser
- user's login in the databasepass
- user's password
java.sql.SQLException
- if the connection is not possible
java.lang.ClassNotFoundException
- if there is a problem with loading a driverpublic Dump dump()
dump
in class DatabaseConnector
java.sql.SQLException
- if the backup process is interrupted by a critical errorprotected void dumpTablePrimaryKeys(Table table) throws java.sql.SQLException
dumpTablePrimaryKeys
in class DatabaseConnector
table
- a table which should be checked for primary keys
java.sql.SQLException
- if the backup process is interrupted by a critical errorprotected void dumpTableForeignKeys(Table table) throws java.sql.SQLException
dumpTableForeignKeys
in class DatabaseConnector
table
- a table which should be checked for foreign keys
java.sql.SQLException
- if the backup process is interrupted by a critical errorprotected void dumpColumn(Column column, java.sql.ResultSet rsColumns) throws java.sql.SQLException
dumpColumn
in class DatabaseConnector
column
- a column which should have its parameters downloadedrsColumns
- a ResultSet returned by DatabaseMetaData.getColumns(),
set on this column's record
java.sql.SQLException
- if the backup process is interrupted by a critical errorpublic void restore(Dump dump) throws java.sql.SQLException
restore
in class DatabaseConnector
dump
- a Dump object containing information about database structure
java.sql.SQLException
- if the restore process is interrupted by a critical errorprotected void clearDatabase(Dump dump) throws java.sql.SQLException
dump
- the dump which contains names of the tables which should be cleared
java.sql.SQLException
- if the clear process is interrupted by a critical errorprotected void clearConstraints(Table table) throws java.sql.SQLException
table
- the table which contains constraints which should be removed
java.sql.SQLException
- if the clear process is interrupted by a critical errorprotected void restoreTableStructure(Table table) throws java.sql.SQLException
table
- the table which should be added to the database
java.sql.SQLException
- if the create process is interrupted by a critical errorprotected void restoreTableConstraints(Table table) throws java.sql.SQLException
table
- the table whose constraints should be added
java.sql.SQLException
protected void restoreTableData(Table table) throws java.sql.SQLException
table
- the table whose data should be uploaded
java.sql.SQLException
- when the data can't be uploadedpublic java.lang.String createURL(DatabaseConnectionData data)
createURL
in class DatabaseConnector
data
- an object providing all the data necessary to open the connection
public void initializeTableData(java.lang.String tableName) throws java.sql.SQLException
initializeTableData
in class DatabaseConnector
tableName
- name of the table from which data should be downloaded
java.sql.SQLException
public java.lang.String[] getTableDataLine() throws java.sql.SQLException
getTableDataLine
in class DatabaseConnector
java.sql.SQLException
- if data record can't be downloaded because of a connection error
or an error in the database
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |