spring dao

Spring Dao - a Spring JDBC update example

Spring JDBC FAQ: Can you provide an example of a SQL UPDATE query used with Spring JDBC, i.e., Spring Dao class and methods?

Here's some example Java code from a Spring Dao class where I use Spring JDBC and the JDBCTemplate update method to run a SQL UPDATE statement. In short, if you can get access to the Spring JDBCTemplate, this code shows a simple example of how to execute a SQL UPDATE statement.

Spring Dao/JDBC tip - a great way to test your Spring DAO code

The Spring Framework gives you a great way to test your Spring JDBC (Spring DAO) code. Just use a special Spring JDBC class with a very long name, and you can test your Spring JDBC code against a real database.

Some people don't like this approach, but I think it's invaluable for (a) testing your SQL syntax when you first create it, and (b) making sure your SQL syntax is still valid after database changes occur.

Spring Dao - Spring JDBC DELETE examples

Spring JDBC DELETE FAQ: Can you provide some examples of using SQL DELETE queries using Spring JDBC (Spring Dao classes and methods)?

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 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 (Spring DAO)

A Spring JDBC SELECT and INSERT example: Here's the source code for a complete Spring DAO class from a project that I'm currently working on (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".

Spring Dao: a Spring JDBC DELETE example

Spring JDBC Example/Question: How do I perform a SQL DELETE query (statement) using JDBC and the Spring Framework?

Here's a simple Java method that I created to perform a SQL DELETE using Spring JDBC techniques: