This is a Java application for exporting data from a MySQL database to various formats (e.g., HTML, XML, etc.). The application uses Swing for the graphical user interface and supports a plug-and-play architecture for adding new export formats without changing existing code.
Find a file
Amit Kumar Nandi 1389fb8bba Initial commit
2024-02-17 22:38:33 +05:30
src Initial commit 2024-02-17 22:38:33 +05:30
.gitignore Initial commit 2024-02-17 22:38:33 +05:30
pom.xml Initial commit 2024-02-17 22:38:33 +05:30
Readme.md Initial commit 2024-02-17 22:38:33 +05:30

Database Exporter Application

This is a Java application for exporting data from a MySQL database to various formats (e.g., HTML, XML, etc.). The application uses Swing for the graphical user interface and supports a plug-and-play architecture for adding new export formats without changing existing code.

Table of Contents

Features

  • Export data from MySQL database tables.
  • Supports multiple export formats (e.g., HTML, XML, etc.).
  • Extensible architecture for adding new export formats without modifying existing code.
  • Graphical user interface using Swing.
  • Virtually configurationless operation.

Prerequisites

  • Java 11 or higher
  • MySQL database

Getting Started

  1. Clone the repository:

    git clone https://github.com/aamitn/db-exporter.git

  2.  Compile the code:

    cd db-exporter

    javac -cp .:path/to/mysql-connector-java.jar org/nmpl/*.java org/nmpl/exporters/*.java org/nmpl/exceptions/*.java

  3. Run the application:

    java -cp .:path/to/mysql-connector-java.jar org.nmpl.App

Usage

Launch the application using the steps mentioned in the Getting Started section.
Connect to your MySQL database by entering the database name, username, and password.
Click "Show Tables" to display the available tables.
Select a table from the list.
Choose an export format from the dropdown menu.
Click "Export Table" to export the selected table to the chosen format.

Example Factory Class Usage:

ExporterFactory exportFactory = new ExporterFactory(connection);
Exportable exporter = exportFactory.getExporter("xml"); 
exporter.export("your_table_name", "output.xml");

Plugin Architecture

The application employs a plugin architecture, allowing you to add new export formats without modifying existing code. To add a new export format, simply create a new class implementing the Exportable interface and place it in the org.nmpl.exporters package.

Example for creating a new export format:

package org.nmpl.exporters;
import org.nmpl.Exportable;
public class NewFormatExporter implements Exportable {
// Implement the export method as per your requirements
}

No changes to the existing code are needed. The new class is automatically recognized and integrated into the application at runtime.

Configurationless Operation

The application is designed for configurationless operation. The config.xml file, located in the resources directory, maps export formats to their corresponding Java class names. This enables the application to dynamically recognize and utilize new exporters without explicit configuration.

Example config.xml:

<exporters>
	<exporter> 
 		<type>html</type> 
		<class>org.nmpl.exporters.HTMLExporter</class> 
	</exporter> 
	<exporter>
		<type>xml</type>
 		<class>org.nmpl.exporters.XMLExporter</class> 
	</exporter>
 	<exporter> 
		<type>newformat</type> 
		<class>org.nmpl.exporters.NewFormatExporter</class>
 	</exporter>
 <!-- Add more exporter configurations as needed --> 
</exporters>

Fork the repository

Create a new branch (git checkout -b feature/new-feature)
Make your changes and commit them (git commit -am 'Add new feature')
Push to the branch (git push origin feature/new-feature)
Open a pull request

License

This project is licensed under the MIT License - see the LICENSE file for details.