Junior — Middle
Share your experience with setting up and managing databases.
sobes.tech AI
Answer from AI
In my experience with databases, I have worked with both relational (e.g., MySQL, PostgreSQL) and NoSQL (MongoDB) databases. The main tasks included configuring connections from Java applications via JDBC, query optimization, index creation, and transaction management.
For database management, I used schema migration tools like Flyway or Liquibase, which allow controlling versioning of the database structure and simplify deployment.
Example of connecting to a database via JDBC:
String url = "jdbc:postgresql://localhost:5432/mydb";
String user = "user";
String password = "password";
try (Connection conn = DriverManager.getConnection(url, user, password)) {
// work with the database
} catch (SQLException e) {
e.printStackTrace();
}
It is also important to monitor the connection pool (e.g., HikariCP) for efficient resource management.