Return-Path: Delivered-To: apmail-db-derby-user-archive@www.apache.org Received: (qmail 75915 invoked from network); 17 Jul 2007 14:56:42 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 17 Jul 2007 14:56:42 -0000 Received: (qmail 36100 invoked by uid 500); 17 Jul 2007 14:56:31 -0000 Delivered-To: apmail-db-derby-user-archive@db.apache.org Received: (qmail 36079 invoked by uid 500); 17 Jul 2007 14:56:31 -0000 Mailing-List: contact derby-user-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Reply-To: "Derby Discussion" Delivered-To: mailing list derby-user@db.apache.org Received: (qmail 36046 invoked by uid 99); 17 Jul 2007 14:56:30 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 17 Jul 2007 07:56:30 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: domain of lists@nabble.com designates 216.139.236.158 as permitted sender) Received: from [216.139.236.158] (HELO kuber.nabble.com) (216.139.236.158) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 17 Jul 2007 07:56:25 -0700 Received: from isper.nabble.com ([192.168.236.156]) by kuber.nabble.com with esmtp (Exim 4.63) (envelope-from ) id 1IAoT7-0007bH-6k for derby-user@db.apache.org; Tue, 17 Jul 2007 07:56:05 -0700 Message-ID: <11650724.post@talk.nabble.com> Date: Tue, 17 Jul 2007 07:56:05 -0700 (PDT) From: sieg To: derby-user@db.apache.org Subject: Wanted: Working example of JDBC4 Annotations. MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Nabble-From: siegfried@heintze.com X-Virus-Checked: Checked by ClamAV on apache.org I'm trying to run the sample code in "A Tutorial Java 6 New Features" by Budi Kurniawan page 167. The code for the book is available at http://books.brainysoftware.com/download/jdk6Samples.zip. Chapter 8 is the database chapter. Neither the java command line javac nor the java6 compiler used by eclipse can find the class java.sql.DataSet. What do I have to do to make to compile the following code? Better yet, does someone have some sample JDBC4 code that demonstrates using annotations for SQL queries (insert, delete, select, update etc...) that compiles and runs? I did some google searching and found some JDBC4 tutorials, but the code fragments did not include the import statements! I was told that the only low cost database that includes a JDBC4 driver is IBM's Apache Derby. Is this true? Thanks, Siegfried Here is some sample code from the above zip file (I added the bash procedure in the comments). package query; import java.sql.Connection; import java.sql.DataSet; import java.sql.DriverManager; import java.sql.SQLException; /* * Begin commands to execute this file using Java with bash * export DERBY_HOME=/cygdrive/c/dev/derby/10.2.2.0 * /cygdrive/c/dev/derby/10.2.2.0/bin/ij < rows = qo.getAllRoles(); for (Role role : rows) { System.out.println(role); } // Create new Role object if (! rows.isReadOnly()) { System.out.println("\nCreate new role"); Role r = new Role(); r.role_id = 12345; r.name = "Supervisor"; r.description = "Do monitoring job"; boolean insertResult = rows.insert(r); rows.sync(connection); System.out.println("\tInserted: " + insertResult); } // Retrieve Role by name System.out.println("\nGet role by name:"); DataSet rows2 = qo.getRoleByName("Supervisor"); Role role = rows2.get(0); System.out.println(role); if (role != null) { // Modify Role System.out.println("\nModify current role:"); role.description = "Do supervising job"; boolean modifyResult = rows2.modify(role); rows2.sync(connection); System.out.println("\tModified: " + modifyResult); } } catch (SQLException e) { for (Throwable t : e) { t.printStackTrace(); } } finally { // Close connection try { connection.close(); } catch (SQLException e) { e.printStackTrace(); } } } } import java.sql.BaseQuery; import java.sql.DataSet; import java.sql.Select; public interface UserQueries extends BaseQuery { // Select all users @Select(sql = "SELECT userId, firstName, lastName FROM Users", readOnly=false, connected=false, tableName="Users") DataSet getAllUsers(); // Select user by name */ @Select(sql = "SELECT userId, firstName, lastName FROM Users " + "WHERE userName=?", readOnly=false, connected=false, tableName = "Users") DataSet getUserByName(String userName); // Delete user @Update("DELETE Users WHERE firstName={firstName} " + "AND lastName={lastName}") int deleteUser(String firstName, String lastName); } class User { public String userId; public String firstName; public String lastName; } -- View this message in context: http://www.nabble.com/Wanted%3A-Working-example-of-JDBC4-Annotations.-tf4097303.html#a11650724 Sent from the Apache Derby Users mailing list archive at Nabble.com.