SupportWriter space ↗
REFERENCE LIBRARY

References from other publishers

Republished articles with source attribution. This collection is separate from Diary Coding’s original guides and does not display ads.

Read original guides → · Editorial policy

FOR YOUR CURIOSITY

Latest notes.

JDBC / NOTES</>↗
JDBC14 Jan 2026

How do I execute a simple SQL query with Statement?

Executing a simple SQL query using a Statement object in JDBC follows a straightforward pattern: establish a connection, create the statement, execute the query, and process the results. Here is a clean example of how to perform a SELECT query: Simple SQL Query Example package org.kodejava.jdbc; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import […]

Wayan · 2 min read
JDBC / NOTES</>↗
JDBC14 Jan 2026

How do I close JDBC resources properly?

Properly closing JDBC resources is crucial to prevent memory leaks and database connection exhaustion. In modern Java, the absolute best way to do this is by using the try-with-resources statement. The Best Practice: Try-with-Resources Introduced in Java 7, this approach automatically closes any resource that implements java.lang.AutoCloseable (which Connection, Statement, and ResultSet all do) at […]

Wayan · 3 min read
JNDI / NOTES</>↗
JNDI13 Jan 2026

How do I use DataSource instead of DriverManager?

Switching from DriverManager to DataSource is a best practice in modern Java applications because it supports connection pooling, is more configurable, and decouples your code from the specific database driver implementation. While DriverManager creates a physical connection every time you call getConnection(), a DataSource (specifically a pooling one) maintains a set of open connections that […]

Wayan · 3 min read
JDBC / NOTES</>↗
JDBC13 Jan 2026

How do I create a database connection with DriverManager?

Creating a database connection with DriverManager is the standard way to establish a session with a database in JDBC. 1. The Essential Formula To get a connection, you call DriverManager.getConnection() using a Connection URL, a username, and a password. Connection connection = DriverManager.getConnection(url, username, password); 2. Implementation Example In modern Java (JDBC 4.0+), you don’t […]

Wayan · 2 min read
JDBC / NOTES</>↗
JDBC12 Jan 2026

How do I load a JDBC driver in modern Java?

In modern Java (specifically JDBC 4.0 and later), you generally do not need to write code to load the driver. The DriverManager uses the Service Provider Interface (SPI) to automatically discover and load any JDBC drivers present on your classpath. 1. The Modern Way: Automatic Discovery As long as the driver JAR is on your […]

Wayan · 2 min read
JDBC / NOTES</>↗
JDBC12 Jan 2026

How do I connect to SQL Server using JDBC?

To connect to Microsoft SQL Server using JDBC, you’ll need the Microsoft JDBC Driver for SQL Server. Using Maven, you can add the dependency and use the DriverManager to establish a connection. Here is the step-by-step process: 1. Add the Dependency Add the following dependency to your pom.xml file: <dependency> <groupId>com.microsoft.sqlserver</groupId> <artifactId>mssql-jdbc</artifactId> <version>12.8.1.jre11</version> <!– Check […]

Wayan · 2 min read
✳

Knowledge grows when shared.

Stay curious. There is always something new to learn.

Explore notes ↗
Putu Adi Guna Permana
ABOUT THE AUTHOR

Dr (C). Ir. Putu Adi Guna Permana, S.Kom., M.Kom., IPM., ASEAN Eng.

Writer and founder of Diary Coding — sharing notes, tutorials, and experiences about programming for anyone who wants to keep learning.