jdbc

recent blog posts related to java and jdbc, including databases like mysql and postgresql

A Java DB2 JDBC Driver class and URL example

Here's a quick post to help anyone that needs a quick Driver and URL reference when using DB2 with Java and JDBC.

If all you need is a reference to the DB2 JDBC Driver and URL connection string syntax, this basic information should work:

A Java JDBC SQL Server Driver class and URL example

Here's a quick post to help anyone that needs a quick JDBC Driver and URL reference when using Microsoft SQL Server with Java and JDBC.

The basic SQL Server JDBC Driver and URL information you need is shown here:

Java MySQL JDBC Driver class and URL example

Here's a quick JDBC MySQL post to help anyone that needs a quick JDBC Driver and URL reference when using MySQL with Java.

The basic MySQL JDBC Driver and URL information you need is shown here:

Java JDBC Postgresql Driver class and URL example

Here's a quick post to help anyone that needs a quick JDBC Driver and URL reference when using Postgresql (Postgres) with Java (and JDBC).

The basic Postgresql JDBC Driver and URL information you need is shown here:

JDBC connection string examples

Some days we all need something simple, like the example syntax for a JDBC connection string (URL) for a particular database.

To that end, here are some example Java JDBC connection string examples for various databases, including MySQL, Postgres, SQL Server, and DB2.

Spring JDBC - How to retrieve the auto-generated database key after an INSERT

Spring JDBC FAQ: How do I retrieve the auto-generated database key for a serial field (also known as an auto_increment field in MySQL) after I perform a SQL INSERT using Spring JDBC?

Spring Dao - Spring JDBC DELETE examples

Here are a few Spring Dao examples, specifically JDBC/SQL DELETE examples.

Spring JDBC delete example #1: Delete a record by the primary key

In this first Spring Dao/JDBC DELETE example, I pass in an id parameter, which represents the primary key in my hosts database table. This JDBC/SQL statement deletes the record from that table that matches that id field.

A Spring JDBC SELECT and INSERT example

Here's a complete Spring DAO class from a project that I'm currently working on (creating a Java-based web interface to the open source Nagios project) that shows how to use a few Spring JDBC methods, including both a SELECT example and a simple INSERT example.

I'll add more examples to this site later (and with more introduction/description), but for now I'm just going to drop this Java class sample out here and hope that it helps you "Learn Spring JDBC by example".

Java JDBC example - connect to a Postgres database

I don't know if this Java sample program will help anyone, but I thought I'd share it here. It's a variation of a program I use to connect to a JDBC database (in this case a Postgresql database) whenever I need to look at some information. In this particular case I wrote the program because I didn't have access to the psql command-line tool, so I created this Java program, compiled it, and ran it to see what I wanted to see.

A Java PreparedStatement example with a SELECT statement and LIKE clause

Here's a quick example of how to use a JDBC PreparedStatement with an SQL SELECT query when accessing a database. To make it a little more complicated I added a LIKE clause to the SELECT statement. So, this is really an example of a PreparedStatement that uses a SELECT query that uses a LIKE clause.

Syndicate content