Home » JDBC » Page 2

Tag Archives: JDBC

Fully working prototypes with Spring Boot and H2

spring-interview-questions-answers

We do use a lot of h2 with spring especially for unit tests. However instead of unit tests we might want to have a fully functional prototype with data to display. H2 is the perfect candidate for that, it works great with spring, it has good syntax compatibility with most databases out there and it also provides you with a ...

Read More »

Java: Streaming a JDBC ResultSet as JSON

This post shows how you can convert a java.sql.ResultSet to JSON and stream it back to the caller. This is useful if you want to send a large dataset from a JDBC DataSource to a web application in JSON format. Streaming allows you to transfer the data, little by little, without having to load it all into the server’s memory. ...

Read More »

Session Management using Spring Session with JDBC DataStore

spring-interview-questions-answers

In web applications, user session management is very crucial for managing user state. In this article, we are going to learn about what are the approaches we have been following to manage user sessions in a clustered environment and how we can use Spring Session to implement it in a much simpler and more scalable way. Typically in production environments, we will ...

Read More »

JDBC Connections Cheat Sheet

java-interview-questions-answers

Abstract This is a quick reference for JDBC connections for common databases. I seem to have to lookup this information a lot, so I figured it be good to have a reference all in one place.           Derby <dependency> <groupId>org.apache.derby</groupId> <artifactId>derbyclient</artifactId> <version>10.11.1.1</version> <scope>test</scope> </dependency> <dependency> <groupId>org.apache.derby</groupId> <artifactId>derby</artifactId> <version>10.11.1.1</version> <scope>test</scope> </dependency> Embedded (in-memory) Class.forName("org.apache.derby.jdbc.EmbeddedDriver"); String connectionUrl = ...

Read More »

Using MySQL JDBC Driver With Spring Boot

In this article, I will show you how to connect a MySQL database with your Spring Boot application. Tools used in this article include: Spring Boot 1.5.6 Release MySQL 5.7.X Maven Java 8 Spring Data JPA 1 – Project Structure The project structure is a typical Maven structure. 2 – Project Dependencies Please note that the parent needs to declared. ...

Read More »

Understanding Connection Pooling

java-interview-questions-answers

1. Introduction Connection Pooling is a technique to boost application’s performance where N connections to the database are opened and managed in a pool. The application just asks for a connection, uses it and then drops it back to the pool. When the application demands for a connection, the ready connections are kept available to used in the pool. The pool manages ...

Read More »

SpringBoot : Working with JdbcTemplate

spring-interview-questions-answers

Spring provides a nice abstraction on top of JDBC API using JdbcTemplate and also provides great transaction management capabilities using annotation based approach. First let’s take a quick look at how we generally use Spring’s JdbcTemplate (without SpringBoot) by registering DataSource, TransactionManager and JdbcTemplate beans and optionally we can register DataSourceInitializer bean to initialize our database. @Configuration @ComponentScan @EnableTransactionManagement @PropertySource(value ...

Read More »

Easy Database Manipulation with Groovy and Gradle

Groovy:  The “Enterprise Hipster” Language Not everyone sees the Java programming language as sexy.  However, the Java virtual machine is a dominant force everywhere, from the most conservative enterprise to the most whimsical startup.  There are myriad alternative languages today that compile to Java bytecode.  There are JVM-based versions of Python, Ruby, and multiple implementations of JavaScript.  There are entirely new ...

Read More »