diff --git a/lesson-demo/pom.xml b/lesson-demo/pom.xml
index 80b50add..cc65bf59 100644
--- a/lesson-demo/pom.xml
+++ b/lesson-demo/pom.xml
@@ -10,5 +10,18 @@
4.0.0
lesson-demo
-
+
+
+
+ org.postgresql
+ postgresql
+ 42.7.3
+
+
+ org.hibernate
+ hibernate-hikaricp
+ 5.4.10.Final
+
+
+
\ No newline at end of file
diff --git a/lesson-demo/src/main/java/com/bobocode/DemoApp.java b/lesson-demo/src/main/java/com/bobocode/DemoApp.java
index 21d5205b..c2015c00 100644
--- a/lesson-demo/src/main/java/com/bobocode/DemoApp.java
+++ b/lesson-demo/src/main/java/com/bobocode/DemoApp.java
@@ -1,7 +1,34 @@
package com.bobocode;
+import com.zaxxer.hikari.HikariDataSource;
+import lombok.SneakyThrows;
+import org.postgresql.ds.PGSimpleDataSource;
+
+import javax.sql.DataSource;
+
public class DemoApp {
+ @SneakyThrows
public static void main(String[] args) {
-
+ DataSource dataSource = initDb();
+ var start = System.nanoTime();
+
+ for (int i = 0; i < 20; i++) {
+ try (var connection = dataSource.getConnection()) {
+ try (var selectStatement = connection.createStatement()) {
+ selectStatement.executeQuery("select random()"); // just to call the DB
+ }
+ }
+ }
+
+ var end = System.nanoTime();
+ System.out.println((end - start) / 1000_000 + "ms");
+ }
+
+ private static DataSource initDb() { // todo: refactor to use a custom pooled data source
+ var dataSource = new PGSimpleDataSource();
+ dataSource.setURL("jdbc:postgresql://0.tcp.eu.ngrok.io:11708/postgres");
+ dataSource.setUser("bobouser");
+ dataSource.setPassword("bobopass");
+ return dataSource;
}
}