RAGbasedERP is a Java-based utility designed to import data from Excel files (.xls or .xlsx) directly into a MySQL database. This project automates the process of reading Excel files, dynamically creating tables based on the file's headers, and efficiently loading the data into the specified database table.
- Universal Excel Import: Supports both
.xlsand.xlsxformats using Apache POI. - Automatic Table Creation: Dynamically creates a database table based on the header row of the Excel file, with cleaned column names.
- Robust Data Insertion: Handles empty rows, blank cells, and multiple data types (string, numeric, boolean, date, formula).
- Progress Feedback: Prints progress for large files and details on import success.
- Custom Table Naming: Allows users to specify the target table name, defaulting to
excel_dataif omitted.
- Java 8+
- MySQL Database
- Apache POI Library
- Add
poi-ooxmlandpoito your project dependencies.
- Add
By default, the utility connects to:
- URL:
jdbc:mysql://localhost:3306/project1 - User:
root - Password:
System@305
Edit these constants at the top of ExcelDB.java if your database configuration differs.
private static final String DB_URL = "jdbc:mysql://localhost:3306/project1";
private static final String USER = "root";
private static final String PASSWORD = "System@305";-
Clone the repository:
git clone https://github.com/RADson2005official/RAGbasedERP.git cd RAGbasedERP -
Ensure dependencies are available: Download Apache POI jars and place them in your classpath.
-
Compile:
javac -cp ".:path/to/poi.jar:path/to/poi-ooxml.jar:mysql-connector-java.jar" ExcelDB.java -
Run:
java -cp ".:path/to/poi.jar:path/to/poi-ooxml.jar:mysql-connector-java.jar" ExcelDB -
Follow prompts:
- Enter the path to your Excel file (e.g.,
data.xlsx) - Enter your target database table name (or press enter to use the default)
- Enter the path to your Excel file (e.g.,
- Excel Parsing: Reads the first row for headers, cleans column names, and creates a corresponding table.
- Dynamic Table Creation: If the table does not exist, it is created with columns as
TEXT. - Data Import: Each subsequent row is parsed and inserted. Progress is printed every 100 rows.
- Error Handling: Handles errors such as missing JDBC driver, database connection issues, file format problems, and unexpected exceptions.
Enter path to Excel file: data.xlsx
Enter database table name: sales_data
Connecting to database...
Connection successful!
Table structure verified/created: sales_data
Table has 5 columns (including id)
Excel data successfully imported to database table: sales_data
Imported 1200 rows into table sales_data- Apache POI for Excel file parsing
- MySQL JDBC Driver for database connectivity
Contributions are welcome! Please follow these guidelines:
- Fork the repository and create a new branch.
- Ensure your code is well-commented and follows Java conventions.
- If adding features, update this README and provide example cases.
- Submit a pull request with a clear description of changes.
No explicit license file is provided; please contact the repository owner for usage terms.
Please use the GitHub Issues tab for bug reports, feature requests, or questions.
Author: RADson2005official