Senior
What databases have you worked with?
sobes.tech AI
Answer from AI
In my practice, I have worked with various databases, including relational and NoSQL solutions. Among the relational ones are PostgreSQL and MySQL, where I used SQL queries, indexes, transactions, and performance optimization. I also have experience with Oracle and Microsoft SQL Server.
From NoSQL databases — MongoDB for document storage, Redis for caching and quick data access, and Cassandra for distributed storage with high availability.
An example of connecting to PostgreSQL in Java using JDBC:
String url = "jdbc:postgresql://localhost:5432/mydb";
String user = "user";
String password = "password";
try (Connection conn = DriverManager.getConnection(url, user, password)) {
PreparedStatement ps = conn.prepareStatement("SELECT * FROM users WHERE id = ?");
ps.setInt(1, 1);
ResultSet rs = ps.executeQuery();
while (rs.next()) {
System.out.println(rs.getString("username"));
}
}