Environment Variables:
Set environment variables in your development environment or use a .env file and load it using a library like dotenv-java. The environment variables are: LOCAL_DB_URL, LOCAL_DB_USER, LOCAL_DB_PASS CLOUD_DB_URL, CLOUD_DB_USER, CLOUD_DB_PASS README.md: Create a README.md to describe the project, how to run it, and its purpose. Here's an example template:
markdown Copy Edit
This project provides a service that synchronizes data between two MySQL databases (local and cloud). It periodically checks for missing records in each database and inserts them into the other.
- Syncs tables between two databases (local and cloud).
- Prevents primary key violations by using
INSERT IGNORE
. - Syncs data every minute.
- Clone the repository:
git clone https://github.com/ThaminduDisnaZ/cloud-local-db-sync.git
Set up environment variables:
Set the following environment variables: LOCAL_DB_URL, LOCAL_DB_USER, LOCAL_DB_PASS CLOUD_DB_URL, CLOUD_DB_USER, CLOUD_DB_PASS Run the application:
Compile the code: bash Copy Edit javac DatabaseSyncService.java Run the application: bash Copy Edit java DatabaseSyncService License: This project is licensed under the MIT License.
markdown Copy Edit
- .gitignore:
Add a
.gitignore
to exclude unnecessary files:
Ignore compiled class files *.class
Ignore environment files .env
Ignore IntelliJ IDEA files .idea/
Ignore Eclipse project files *.project *.classpath
shell Copy Edit
/database-sync-service ├── src/ │ └── DatabaseSyncService.java ├── .gitignore ├── README.md └── .env (optional)
css Copy Edit
Now you have a GitHub-friendly version of your DatabaseSyncService
code that follows best practices! Let me know if you need further adjustme