-
Notifications
You must be signed in to change notification settings - Fork 0
database management
The project uses the H2 database for development and testing purposes. Below are strategies and practices for efficient management of the database.
The H2 database is an embedded in-memory database that is easy to configure and use. It allows for quick testing and development without needing an external database server.
# H2 Console
spring.h2.console.enabled=true
spring.h2.console.path=/h2-console
spring.h2.console.settings.web-allow-others=true
# Datasource
spring.datasource.url=jdbc:h2:mem:java_base;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.username=sa
spring.datasource.password=The H2 console is a web interface that allows you to execute queries and manage the in-memory database.
Start the application.
Open the browser and go to http://localhost:8080/h2-console.
Use the following settings to connect to the H2 database:
- JDBC URL: jdbc:h2:mem:java_base
- User Name: sa
- Password: (leave blank)
After connecting to the H2 console, you can execute SQL queries to view and manipulate the data.
SELECT * FROM CURRENCY_CONVERSIONS;The in-memory H2 database is volatile, and all data will be lost upon restarting the application. To persist data, you need to configure a persistent database, such as PostgreSQL or MySQL.
To configure a persistent database, you should change the datasource properties in application.properties to point to the desired database. For example, to use PostgreSQL:
spring.datasource.url=jdbc:postgresql://localhost:5432/java_base
spring.datasource.driverClassName=org.postgresql.Driver
spring.datasource.username=your-username
spring.datasource.password=your-password
spring.jpa.hibernate.ddl-auto=updateUsing CURL
curl -s -X GET "http://localhost:8080/api/v1/conversions/convert?source=BRL&target=EUR&amount=33" -H "Accept: application/json" | jqImport the file postman_collection.json in Postman to use the application.
mvn clean compile
mvn exec:java -Dexec.mainClass="com.sognisport.swing.CurrencyConverterSwingApp"The H2 database is an excellent tool for development and testing due to its simplicity and ease of configuration. However, for production environments, it is recommended to use a more robust and persistent relational database, such as PostgreSQL or MySQL.
- Easy configuration and use
- Ideal for quick development and testing
- No need for additional software installation
- Data does not persist between restarts
- Not recommended for production environments
The H2 database is a powerful tool for development, providing a quick and efficient way to test the application and manage temporary data. By following these instructions, you can configure, access, and use H2 effectively in your project.
- Overview: Presentation of the project, highlighting its purpose and the context in which it is embedded.
- Project Objectives: Enumeration of the main objectives that the project aims to achieve.
- Scope and Functionalities: Description of the main functionalities offered by the project and its scope of operation.
- Initial Configurations: Steps required to set up the development or production environment.
- Installation Instructions: Detailed procedures for installing the project in different environments.
- Docker Configuration: Specifications on how to configure and use Docker for the project.
- Folder Structure: Description of the organization of the project directories.
- Project Architecture: Explanation of the architecture used, including design patterns and technical decisions.
- Development Flow: Description of the development process adopted, including planning, coding, and review stages.
- Apache Camel Integration: Guide on integrating Apache Camel into the project, including configuration and usage.
- Contributors and Authors: Recognition of the contributors to the project.
- Contributions: Guidelines on how to contribute to the project, including code standards and pull request requirements, tips and best practices.
- Code of Conduct: Behavioral guidelines expected for the project community.
- OpenAPI Specification: Details about the OpenAPI specification used to document the API endpoints.
- API Documentation with Swagger: Information on how to access and use the interactive API documentation generated by Swagger.
- Javadoc Documentation: Information on the Javadoc documentation generated for the project.
- Endpoint Description: Details of the available API endpoints, including methods, parameters, and usage examples.
- Database Management.
- Testing Strategies: Approach and methods used to test the software, including unit, integration, and E2E tests.
- Testing Tools: Description of the testing tools used in the project and how to configure them.
- CI/CD Pipeline: Explanation of the continuous integration and delivery pipeline, detailing each stage and its function.
- Automations and Artifact Generation: Description of the automations incorporated into the CI/CD, including documentation generation and build artifacts.
- .gitignore, .editorconfig and project.properties: Utility of these files to maintain code consistency and quality.
- Maven Wrapper and application.properties: Explanation of how these files help standardize the development environment.
- .env File and Travis CI Settings: Use of these files to configure the environment and CI integrations.
- Code Standards and Security: Guidelines for maintaining code quality and security.
- Monitoring and Logging Practices: Recommended techniques for monitoring and logging in the project.
- Licensing: Information about the rights and restrictions associated with the use of the software.
- Terms of Use: Information about the terms and conditions for using the software.
- Future Plans: Discussion on functionalities and improvements considered for future versions of the project.
- Improvement Proposals: Space for the community to suggest and debate improvements and innovations.
- External Links and References: Additional resources and external documentation relevant to the project.
- Security Policy: Details on the supported versions, reporting vulnerabilities, and general security practices.