Junior — Middle
Did you use a database in your last project?
sobes.tech AI
Answer from AI
Yes, in my last Java project, I used a database to store information about users and their actions. Specifically, a relational DBMS (for example, PostgreSQL) was used. To interact with the database, I used JDBC and the ORM framework Hibernate, which allowed for convenient query execution and transaction management.
An example of a simple query using JDBC:
String query = "SELECT * FROM users WHERE id = ?";
PreparedStatement stmt = connection.prepareStatement(query);
stmt.setInt(1, userId);
ResultSet rs = stmt.executeQuery();
if (rs.next()) {
String username = rs.getString("username");
// data processing
}
Using a database was key to ensuring data integrity and quick access to data.