Add JMH data access benchmark app
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
package com.benchmark.util;
|
||||
|
||||
import com.benchmark.model.User;
|
||||
|
||||
import java.sql.*;
|
||||
|
||||
public class DbUtil {
|
||||
|
||||
public static void createSchema(Connection conn) throws SQLException {
|
||||
try (Statement stmt = conn.createStatement()) {
|
||||
stmt.execute("""
|
||||
CREATE TABLE IF NOT EXISTS users (
|
||||
id INTEGER PRIMARY KEY,
|
||||
name TEXT NOT NULL,
|
||||
email TEXT NOT NULL,
|
||||
age INTEGER NOT NULL,
|
||||
created_at INTEGER NOT NULL
|
||||
)
|
||||
""");
|
||||
}
|
||||
}
|
||||
|
||||
public static User mapRow(ResultSet rs) throws SQLException {
|
||||
return new User(
|
||||
rs.getLong("id"),
|
||||
rs.getString("name"),
|
||||
rs.getString("email"),
|
||||
rs.getInt("age"),
|
||||
rs.getLong("created_at")
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user