~/devreads

#jdbc

25 posts

18 Jun 2024

vladmihalcea 1 min read

Introduction In this article, we are going to see how the Hibernate JAVA_TIME_USE_DIRECT_JDBC setting works and what JDBC Driver supports this feature. This setting can be set programmatically, as illustrated by the following Spring Java-based configuration: Or you can set it declaratively in the Spring Boot application.properties configuration file like this: Domain Model To test how the Hibernate JAVA_TIME_USE_DIRECT_JDBC setting…

hibernatejdbclocaldatetimeoffsetdatetimesetting

7 Feb 2024

vladmihalcea 1 min read

Introduction In this article, we are going to see how we can use the Hibernate StatelessSession in order to enable JDBC Batching for INSERT, UPDATE, and DELETE statements. While the StatelessSession has been available for more than 20 years, until Hibernate 6, its usefulness was rather limited since it lacked support for batching, as well as other cool features, such…

hibernatebatchjdbcstatelesssession

13 Dec 2023

lukaseder 1 min read

Do you need to add a JDBC driver to your application, and don’t know its Maven coordinates? This blog post lists the most popular drivers from the jOOQ integration tests. Look up the latest versions directly on https://central.sonatype.com/ with parameters g:groupId a:artifactId, for example, the H2 database and driver: https://central.sonatype.com/search?q=g%3Acom.h2database+a%3Ah2 The list only includes drivers … Continue reading Maven Coordinates…

javasqljdbcjdbc driversmaven central

1 Dec 2023

26 Jul 2023

vladmihalcea 1 min read

Introduction In this article, we are going to see how we can do JDBC profiling using the VisualVM tool to find slow-running SQL queries or discover N+1 query issues. VisualVM VisualVM is an OSS tool that allows us to inspect the JVM and the Java applications running inside the Java Virtual Machine. You can download VisualVM from this link and…

javahigh performancejdbcn+1performance tuning

25 Apr 2023

lukaseder 1 min read

Microsoft T-SQL supports a language feature called table-valued parameter (TVP), which is a parameter of a table type that can be passed to a stored procedure or function. For example, you may write: This function takes a table-valued parameter (TVP), and produces a result set containing the cross product of the parameter table with itself. … Continue reading How to…

jooq-in-usecode generationcode generatorjavajdbc

8 Dec 2022

lukaseder 1 min read

A frequently encountered doubt people have when using jOOQ is to decide when a “complex” query should be written using jOOQ API vs. when it should be implemented using native SQL. The jOOQ manual is full of side by side examples of the same query, e.g. Using jOOQ: Using native SQL: In the native SQL … Continue reading When to…

jooq-in-usejdbcjdbctemplatejdbijooq

23 Aug 2022

lukaseder 1 min read

Probably the hardest thing to standardise in SQL is RETURNING data from DML statements. In this article, we’ll look at various ways of doing that with jOOQ, in many of jOOQ’s supported dialects, and with JDBC directly. How to do it with jOOQ Assuming the usual table from the sakila database: jOOQ took syntactic inspiration … Continue reading The Many…

sqldata change delta tablegenerated keysjdbcjooq

28 Jul 2022

lukaseder 1 min read

jOOQ is mainly known for its powerful type safe, embedded, dynamic SQL capabilities that are made available through code generation. However, a secondary use case of code generation is to use it for stored procedures (possibly exclusively for stored procedures). Stored procedures are powerful ways of moving complex data processing logic to the server. This … Continue reading The Best…

jooq-in-usecode generationjdbcjooqoracle

28 Apr 2022

lukaseder 1 min read

Since jOOQ 3.4, we have an API that simplifies transactional logic on top of JDBC in jOOQ, and starting from jOOQ 3.17 and #13502, an equivalent API will also be made available on top of R2DBC, for reactive applications. As with everything jOOQ, transactions are implemented using explicit, API based logic. The implicit logic implemented … Continue reading Nested Transactions…

jooq-developmentjakarta eejavajdbcjooq

20 Jul 2021

lukaseder 1 min read

jOOQ 3.15 shipped with a ton of new features, the most important ones being: MULTISET support (type safe, nested collections) Reactive SQL support via R2DBC A very useful, lesser known new feature is “ad-hoc data type conversion”. Data type converters and bindings have been around in jOOQ for a long time. Their goal is to … Continue reading Ad-hoc Data…

jooq-in-usebindingconverterjdbcjooq

15 Feb 2021

lukaseder 1 min read

I’ve run across a fun little trick to simulate latency in your development environments when testing some SQL queries. Possible use-cases including to validate that backend latency won’t bring down your frontend, or that your UX is still bearable, etc. The solution is PostgreSQL and Hibernate specific, though to doesn’t have to be. Besides, it … Continue reading Simulating Latency…

sqlexecutelistenerjdbcjooqlatency

15 Dec 2017

lukaseder 1 min read

When working with Oracle stored procedures, it is not uncommon to have debug log information available from DBMS_OUTPUT commands. For instance, if we have a procedure like this: The procedure works just the same, regardless if we’re reading the output from the DBMS_OUTPUT call. It is there purely for logging purposes. Now, if we call … Continue reading How to…

javajooq-developmentsqldbms outputjdbc

13 Jul 2017

lukaseder 1 min read

You know JDBC, right? It’s that really easy, concise API that we love to use to work with virtually any database, relational or not. It has essentially three types that you need to care about: Connection Statement (and its subtypes) ResultSet All the other types some sort of utilities. Now, with the above three, we … Continue reading How I…

javajdbcjooqsql serverstatement batches

8 Feb 2017

lukaseder 1 min read

Earlier this week, I’ve blogged about how to execute SQL batches with JDBC and jOOQ. This was useful for the MySQL, SQL Server, and Sybase users among you. Today, we’ll discuss a slightly more difficult task, how to fetch Oracle 12c implicit cursors – which are essentially the same thing. What’s an implicit cursor? Oracle … Continue reading How to…

jooq-developmentsqlbatchimplicit cursorsjdbc

6 Feb 2017

lukaseder 1 min read

Some databases (in particular MySQL and T-SQL databases like SQL Server and Sybase) support a very nice feature: They allow for running a “batch” of statements in a single statement. For instance, in SQL Server, you can do something like this: This is a batch of 4 statements, and it can be executed as a … Continue reading How to…

jooq-in-usesqlbatchbatch statementsjdbc

5 Jan 2017

lukaseder 1 min read

In a recent consulting gig, I was analysing a client’s connection pool issue in a productive system, where during some peak loads, all the Java processes involving database interactions just started queueing up until nothing really worked anymore. No exceptions, though, and when the peak load was gone in the evening, everything returned back to … Continue reading How to…

javaconnection pooldatasourcejdbcjooq

24 Sept 2015

lukaseder 1 min read

We’re very happy to announce a guest post by Marco Behler, who has been blogging about jOOQ in the past. Marco started out in programming (reverse-engineering, actually) and now mainly programmes on the JVM in his day-to-day work. He also always had a sweet tooth for strategy and marketing. Marco Behler GmbH is the result … Continue reading It is…

javasqlconnection poolinghibernatejdbc

27 Apr 2015

lukaseder 1 min read

LOBs are a PITA in all databases, as well as in JDBC. Handling them correctly takes a couple of lines of code, and you can be sure that you’ll get it wrong eventually. Because you have to think of a couple of things: Foremost, LOBs are heavy resources that need special lifecycle management. Once you’ve … Continue reading Let’s Review…

javasqlblobclobjdbc

9 Apr 2015

lukaseder 1 min read

You’re not into the functional mood yet? Then the title might not resonate with you – but the article will! Trust me. Essentially, we want this: +------+------+------+ | col1 | col2 | col3 | +------+------+------+ | A | B | C | row 1 | D | E | F | row 2 | G … Continue reading How to…

javajava 8jdbcjooqresultset

26 Mar 2015

lukaseder 1 min read

Some queries shouldn’t hit the database all the time. When you query for master data (such as system settings, languages, translations, etc.), for instance, you may want to avoid sending the same silly query (and the results) over the wire all the time. For example: Most databases maintain buffer caches to accelerate these queries, so … Continue reading Hack up…

javajava 8sqlcachejdbc

2 Dec 2014

lukaseder 1 min read

According to a recent survey by ZeroTurnaround’s RebelLabs, Maven is still the leading Java build platform. The current market share distribution, according to RebelLabs is: Maven with 64% Ant + Ivy with 16.5% Gradle with 11% Yet, at the same time, Maven is often criticised for being a bit obscure and intrusive. Compared to runner-ups … Continue reading How to…

javabintraycommercial artefactsgradlejdbc

4 Nov 2014

lukaseder 1 min read

A procedural language combined with SQL can do miracles in terms of productiveness, performance and expressivity. In this article, we’ll see later on, how we can achieve the same with SQL (and PL/SQL) in Java, using jOOQ, which offers much more functionality than Oracle’s own now desupported JPublisher. But first, a little bit of history… … Continue reading Access PL/SQL…

javajooq-in-usesqljdbcojdbc

5 May 2014

lukaseder 1 min read

Every now and then, I miss SQL’s three-valued BOOLEAN semantics in Java. In SQL, we have: TRUE FALSE UNKNOWN (also known as NULL) Every now and then, I find myself in a situation where I wish I could also express this UNKNOWN or UNINITIALISED semantics in Java, when plain true and false aren’t enough. Implementing … Continue reading Three-State Booleans…

javajava 8booleanjdbcjoo

7 Mar 2014

lukaseder 1 min read

At Data Geekery, we love Java. And as we’re really into jOOQ’s fluent API and query DSL, we’re absolutely thrilled about what Java 8 will bring to our ecosystem. We have blogged a couple of times about some nice Java 8 goodies, and now we feel it’s time to start a new blog series, the… … Continue reading Java 8…

javajava 8jdbcjoo-lambdajoo