Skip to content

Commit

Permalink
refactor: add a time limit for the sample code
Browse files Browse the repository at this point in the history
  • Loading branch information
karenc-bq committed Mar 17, 2023
1 parent b64c4be commit d02e797
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
4 changes: 2 additions & 2 deletions examples/HibernateExample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ dependencies {
annotationProcessor 'org.projectlombok:lombok:1.18.24'
implementation 'org.hibernate:hibernate-core:6.1.3.Final'
implementation 'jakarta.persistence:jakarta.persistence-api:3.1.0'
runtimeOnly 'org.postgresql:postgresql:42.5.1'
runtimeOnly 'mysql:mysql-connector-java:8.0.30'
runtimeOnly 'org.postgresql:postgresql:42.5.4'
runtimeOnly 'mysql:mysql-connector-java:8.0.32'
implementation project(':aws-advanced-jdbc-wrapper')
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package software.amazon;

import java.time.Duration;
import java.time.Instant;
import org.hibernate.Hibernate;
import jakarta.persistence.EntityManager;
import jakarta.persistence.EntityManagerFactory;
Expand All @@ -28,9 +30,13 @@ public class JpaExample {
private static final EntityManagerFactory entityManagerFactory = Persistence.createEntityManagerFactory("Atlas");

public static void main(String[] args) {
final Instant start = Instant.now();
final Duration threshold = Duration.ofMinutes(5);

int i = 0;
try {
while (true) {
// Keep inserting data for 5 minutes.
while (Duration.between(start, Instant.now()).toMinutes() > threshold.toMinutes()) {
Address address = new Address();
address.setTown("Orangeville");
address.setStreet("Faulkner");
Expand Down
4 changes: 2 additions & 2 deletions examples/HikariExample/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
*/

dependencies {
implementation("org.postgresql:postgresql:42.5.0")
implementation("mysql:mysql-connector-java:8.0.31")
implementation("org.postgresql:postgresql:42.5.4")
implementation("mysql:mysql-connector-java:8.0.32")
implementation(project(":aws-advanced-jdbc-wrapper"))
implementation("com.zaxxer:HikariCP:4.0.3")
}

0 comments on commit d02e797

Please sign in to comment.