You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by th...@apache.org on 2017/07/07 02:06:23 UTC
[01/58] [abbrv] commons-dbutils git commit: Changed the package names
so dbutils and dbutils2 won't conflict if both loaded
Repository: commons-dbutils
Updated Branches:
refs/heads/2_0 [created] 8de35c7e2
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/test/java/org/apache/commons/dbutils2/wrappers/SqlNullCheckedResultSetTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils2/wrappers/SqlNullCheckedResultSetTest.java b/src/test/java/org/apache/commons/dbutils2/wrappers/SqlNullCheckedResultSetTest.java
new file mode 100644
index 0000000..406d298
--- /dev/null
+++ b/src/test/java/org/apache/commons/dbutils2/wrappers/SqlNullCheckedResultSetTest.java
@@ -0,0 +1,1021 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.dbutils2.wrappers;
+
+import java.io.ByteArrayInputStream;
+import java.io.CharArrayReader;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.Reader;
+import java.io.Writer;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.math.BigDecimal;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.sql.Blob;
+import java.sql.Clob;
+import java.sql.Ref;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Time;
+import java.sql.Timestamp;
+import java.util.Arrays;
+import java.util.Calendar;
+import java.util.Map;
+
+import org.apache.commons.dbutils2.BaseTestCase;
+import org.apache.commons.dbutils2.ProxyFactory;
+import org.apache.commons.dbutils2.wrappers.SqlNullCheckedResultSet;
+
+/**
+ * Test cases for <code>SqlNullCheckedResultSet</code> class.
+ */
+public class SqlNullCheckedResultSetTest extends BaseTestCase {
+
+ private SqlNullCheckedResultSet rs2 = null;
+
+ /**
+ * Sets up instance variables required by this test case.
+ */
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+
+ rs2 =
+ new SqlNullCheckedResultSet(
+ ProxyFactory.instance().createResultSet(
+ new SqlNullUncheckedMockResultSet()));
+
+ rs = ProxyFactory.instance().createResultSet(rs2); // Override superclass field
+ }
+
+ /**
+ * Tests the getAsciiStream implementation.
+ */
+ public void testGetAsciiStream() throws SQLException {
+
+ assertNull(rs.getAsciiStream(1));
+ assertTrue(rs.wasNull());
+ assertNull(rs.getAsciiStream("column"));
+ assertTrue(rs.wasNull());
+ // Set what gets returned to something other than the default
+ InputStream stream = new ByteArrayInputStream(new byte[0]);
+ rs2.setNullAsciiStream(stream);
+ assertNotNull(rs.getAsciiStream(1));
+ assertEquals(stream, rs.getAsciiStream(1));
+ assertNotNull(rs.getAsciiStream("column"));
+ assertEquals(stream, rs.getAsciiStream("column"));
+
+ }
+
+ /**
+ * Tests the getBigDecimal implementation.
+ */
+ public void testGetBigDecimal() throws SQLException {
+
+ assertNull(rs.getBigDecimal(1));
+ assertTrue(rs.wasNull());
+ assertNull(rs.getBigDecimal("column"));
+ assertTrue(rs.wasNull());
+ // Set what gets returned to something other than the default
+ BigDecimal bd = new BigDecimal(5.0);
+ rs2.setNullBigDecimal(bd);
+ assertNotNull(rs.getBigDecimal(1));
+ assertEquals(bd, rs.getBigDecimal(1));
+ assertNotNull(rs.getBigDecimal("column"));
+ assertEquals(bd, rs.getBigDecimal("column"));
+
+ }
+
+ /**
+ * Tests the getBinaryStream implementation.
+ */
+ public void testGetBinaryStream() throws SQLException {
+
+ assertNull(rs.getBinaryStream(1));
+ assertTrue(rs.wasNull());
+ assertNull(rs.getBinaryStream("column"));
+ assertTrue(rs.wasNull());
+ // Set what gets returned to something other than the default
+ InputStream stream = new ByteArrayInputStream(new byte[0]);
+ rs2.setNullBinaryStream(stream);
+ assertNotNull(rs.getBinaryStream(1));
+ assertEquals(stream, rs.getBinaryStream(1));
+ assertNotNull(rs.getBinaryStream("column"));
+ assertEquals(stream, rs.getBinaryStream("column"));
+
+ }
+
+ /**
+ * Tests the getBlob implementation.
+ */
+ public void testGetBlob() throws SQLException {
+
+ assertNull(rs.getBlob(1));
+ assertTrue(rs.wasNull());
+ assertNull(rs.getBlob("column"));
+ assertTrue(rs.wasNull());
+ // Set what gets returned to something other than the default
+ Blob blob = new SqlNullCheckedResultSetMockBlob();
+ rs2.setNullBlob(blob);
+ assertNotNull(rs.getBlob(1));
+ assertEquals(blob, rs.getBlob(1));
+ assertNotNull(rs.getBlob("column"));
+ assertEquals(blob, rs.getBlob("column"));
+
+ }
+
+ /**
+ * Tests the getBoolean implementation.
+ */
+ public void testGetBoolean() throws SQLException {
+
+ assertEquals(false, rs.getBoolean(1));
+ assertTrue(rs.wasNull());
+ assertEquals(false, rs.getBoolean("column"));
+ assertTrue(rs.wasNull());
+ // Set what gets returned to something other than the default
+ rs2.setNullBoolean(true);
+ assertEquals(true, rs.getBoolean(1));
+ assertEquals(true, rs.getBoolean("column"));
+
+ }
+
+ /**
+ * Tests the getByte implementation.
+ */
+ public void testGetByte() throws SQLException {
+
+ assertEquals((byte) 0, rs.getByte(1));
+ assertTrue(rs.wasNull());
+ assertEquals((byte) 0, rs.getByte("column"));
+ assertTrue(rs.wasNull());
+ // Set what gets returned to something other than the default
+ byte b = (byte) 10;
+ rs2.setNullByte(b);
+ assertEquals(b, rs.getByte(1));
+ assertEquals(b, rs.getByte("column"));
+
+ }
+
+ /**
+ * Tests the getByte implementation.
+ */
+ public void testGetBytes() throws SQLException {
+
+ assertNull(rs.getBytes(1));
+ assertTrue(rs.wasNull());
+ assertNull(rs.getBytes("column"));
+ assertTrue(rs.wasNull());
+ // Set what gets returned to something other than the default
+ byte[] b = new byte[5];
+ for (int i = 0; i < 5; i++) {
+ b[0] = (byte) i;
+ }
+ rs2.setNullBytes(b);
+ assertNotNull(rs.getBytes(1));
+ assertArrayEquals(b, rs.getBytes(1));
+ assertNotNull(rs.getBytes("column"));
+ assertArrayEquals(b, rs.getBytes("column"));
+
+ }
+
+ private static void assertArrayEquals(byte[] expected, byte[] actual) {
+ if (expected == actual) return;
+ if (expected.length != actual.length) {
+ failNotEquals(null, Arrays.toString(expected), Arrays.toString(actual));
+ }
+ for (int i = 0; i < expected.length; i++) {
+ byte expectedItem = expected[i];
+ byte actualItem = actual[i];
+ assertEquals("Array not equal at index " + i, expectedItem, actualItem);
+ }
+ }
+
+ /**
+ * Tests the getCharacterStream implementation.
+ */
+ public void testGetCharacterStream() throws SQLException {
+
+ assertNull(rs.getCharacterStream(1));
+ assertTrue(rs.wasNull());
+ assertNull(rs.getCharacterStream("column"));
+ assertTrue(rs.wasNull());
+ // Set what gets returned to something other than the default
+ Reader reader = new CharArrayReader("this is a string".toCharArray());
+ rs2.setNullCharacterStream(reader);
+ assertNotNull(rs.getCharacterStream(1));
+ assertEquals(reader, rs.getCharacterStream(1));
+ assertNotNull(rs.getCharacterStream("column"));
+ assertEquals(reader, rs.getCharacterStream("column"));
+
+ }
+
+ /**
+ * Tests the getClob implementation.
+ */
+ public void testGetClob() throws SQLException {
+
+ assertNull(rs.getClob(1));
+ assertTrue(rs.wasNull());
+ assertNull(rs.getClob("column"));
+ assertTrue(rs.wasNull());
+ // Set what gets returned to something other than the default
+ Clob clob = new SqlNullCheckedResultSetMockClob();
+ rs2.setNullClob(clob);
+ assertNotNull(rs.getClob(1));
+ assertEquals(clob, rs.getClob(1));
+ assertNotNull(rs.getClob("column"));
+ assertEquals(clob, rs.getClob("column"));
+
+ }
+
+ /**
+ * Tests the getDate implementation.
+ */
+ public void testGetDate() throws SQLException {
+
+ assertNull(rs.getDate(1));
+ assertTrue(rs.wasNull());
+ assertNull(rs.getDate("column"));
+ assertTrue(rs.wasNull());
+ assertNull(rs.getDate(1, Calendar.getInstance()));
+ assertTrue(rs.wasNull());
+ assertNull(rs.getDate("column", Calendar.getInstance()));
+ assertTrue(rs.wasNull());
+ // Set what gets returned to something other than the default
+ java.sql.Date date = new java.sql.Date(new java.util.Date().getTime());
+ rs2.setNullDate(date);
+ assertNotNull(rs.getDate(1));
+ assertEquals(date, rs.getDate(1));
+ assertNotNull(rs.getDate("column"));
+ assertEquals(date, rs.getDate("column"));
+ assertNotNull(rs.getDate(1, Calendar.getInstance()));
+ assertEquals(date, rs.getDate(1, Calendar.getInstance()));
+ assertNotNull(rs.getDate("column", Calendar.getInstance()));
+ assertEquals(date, rs.getDate("column", Calendar.getInstance()));
+
+ }
+
+ /**
+ * Tests the getDouble implementation.
+ */
+ public void testGetDouble() throws SQLException {
+
+ assertEquals(0.0, rs.getDouble(1), 0.0);
+ assertTrue(rs.wasNull());
+ assertEquals(0.0, rs.getDouble("column"), 0.0);
+ assertTrue(rs.wasNull());
+ // Set what gets returned to something other than the default
+ double d = 10.0;
+ rs2.setNullDouble(d);
+ assertEquals(d, rs.getDouble(1), 0.0);
+ assertEquals(d, rs.getDouble("column"), 0.0);
+
+ }
+
+ /**
+ * Tests the getFloat implementation.
+ */
+ public void testGetFloat() throws SQLException {
+ assertEquals(0, rs.getFloat(1), 0.0);
+ assertTrue(rs.wasNull());
+ assertEquals(0, rs.getFloat("column"), 0.0);
+ assertTrue(rs.wasNull());
+ // Set what gets returned to something other than the default
+ float f = 10;
+ rs2.setNullFloat(f);
+ assertEquals(f, rs.getFloat(1), 0.0);
+ assertEquals(f, rs.getFloat("column"), 0.0);
+ }
+
+ /**
+ * Tests the getInt implementation.
+ */
+ public void testGetInt() throws SQLException {
+ assertEquals(0, rs.getInt(1));
+ assertTrue(rs.wasNull());
+ assertEquals(0, rs.getInt("column"));
+ assertTrue(rs.wasNull());
+ // Set what gets returned to something other than the default
+ int i = 10;
+ rs2.setNullInt(i);
+ assertEquals(i, rs.getInt(1));
+ assertEquals(i, rs.getInt("column"));
+ }
+
+ /**
+ * Tests the getLong implementation.
+ */
+ public void testGetLong() throws SQLException {
+ assertEquals(0, rs.getLong(1));
+ assertTrue(rs.wasNull());
+ assertEquals(0, rs.getLong("column"));
+ assertTrue(rs.wasNull());
+ // Set what gets returned to something other than the default
+ long l = 10;
+ rs2.setNullLong(l);
+ assertEquals(l, rs.getLong(1));
+ assertEquals(l, rs.getLong("column"));
+ }
+
+ /**
+ * Tests the getObject implementation.
+ */
+ public void testGetObject() throws SQLException {
+
+ assertNull(rs.getObject(1));
+ assertTrue(rs.wasNull());
+ assertNull(rs.getObject("column"));
+ assertTrue(rs.wasNull());
+ assertNull(rs.getObject(1, (Map<String, Class<?>>) null));
+ assertTrue(rs.wasNull());
+ assertNull(rs.getObject("column", (Map<String, Class<?>>) null));
+ assertTrue(rs.wasNull());
+ // Set what gets returned to something other than the default
+ Object o = new Object();
+ rs2.setNullObject(o);
+ assertNotNull(rs.getObject(1));
+ assertEquals(o, rs.getObject(1));
+ assertNotNull(rs.getObject("column"));
+ assertEquals(o, rs.getObject("column"));
+ assertNotNull(rs.getObject(1, (Map<String, Class<?>>) null));
+ assertEquals(o, rs.getObject(1, (Map<String, Class<?>>) null));
+ assertNotNull(rs.getObject("column", (Map<String, Class<?>>) null));
+ assertEquals(o, rs.getObject("column", (Map<String, Class<?>>) null));
+
+ }
+
+ /**
+ * Tests the getRef implementation.
+ */
+ public void testGetRef() throws SQLException {
+
+ assertNull(rs.getRef(1));
+ assertTrue(rs.wasNull());
+ assertNull(rs.getRef("column"));
+ assertTrue(rs.wasNull());
+ // Set what gets returned to something other than the default
+ Ref ref = new SqlNullCheckedResultSetMockRef();
+ rs2.setNullRef(ref);
+ assertNotNull(rs.getRef(1));
+ assertEquals(ref, rs.getRef(1));
+ assertNotNull(rs.getRef("column"));
+ assertEquals(ref, rs.getRef("column"));
+
+ }
+
+ /**
+ * Tests the getShort implementation.
+ */
+ public void testGetShort() throws SQLException {
+
+ assertEquals((short) 0, rs.getShort(1));
+ assertTrue(rs.wasNull());
+ assertEquals((short) 0, rs.getShort("column"));
+ assertTrue(rs.wasNull());
+ // Set what gets returned to something other than the default
+ short s = (short) 10;
+ rs2.setNullShort(s);
+ assertEquals(s, rs.getShort(1));
+ assertEquals(s, rs.getShort("column"));
+ }
+
+ /**
+ * Tests the getString implementation.
+ */
+ public void testGetString() throws SQLException {
+ assertEquals(null, rs.getString(1));
+ assertTrue(rs.wasNull());
+ assertEquals(null, rs.getString("column"));
+ assertTrue(rs.wasNull());
+ // Set what gets returned to something other than the default
+ String s = "hello, world";
+ rs2.setNullString(s);
+ assertEquals(s, rs.getString(1));
+ assertEquals(s, rs.getString("column"));
+ }
+
+ /**
+ * Tests the getTime implementation.
+ */
+ public void testGetTime() throws SQLException {
+
+ assertNull(rs.getTime(1));
+ assertTrue(rs.wasNull());
+ assertNull(rs.getTime("column"));
+ assertTrue(rs.wasNull());
+ assertNull(rs.getTime(1, Calendar.getInstance()));
+ assertTrue(rs.wasNull());
+ assertNull(rs.getTime("column", Calendar.getInstance()));
+ assertTrue(rs.wasNull());
+ // Set what gets returned to something other than the default
+ Time time = new Time(new java.util.Date().getTime());
+ rs2.setNullTime(time);
+ assertNotNull(rs.getTime(1));
+ assertEquals(time, rs.getTime(1));
+ assertNotNull(rs.getTime("column"));
+ assertEquals(time, rs.getTime("column"));
+ assertNotNull(rs.getTime(1, Calendar.getInstance()));
+ assertEquals(time, rs.getTime(1, Calendar.getInstance()));
+ assertNotNull(rs.getTime("column", Calendar.getInstance()));
+ assertEquals(time, rs.getTime("column", Calendar.getInstance()));
+
+ }
+
+ /**
+ * Tests the getTimestamp implementation.
+ */
+ public void testGetTimestamp() throws SQLException {
+
+ assertNull(rs.getTimestamp(1));
+ assertTrue(rs.wasNull());
+ assertNull(rs.getTimestamp("column"));
+ assertTrue(rs.wasNull());
+ assertNull(rs.getTimestamp(1, Calendar.getInstance()));
+ assertTrue(rs.wasNull());
+ assertNull(rs.getTimestamp("column", Calendar.getInstance()));
+ assertTrue(rs.wasNull());
+ // Set what gets returned to something other than the default
+ Timestamp ts = new Timestamp(new java.util.Date().getTime());
+ rs2.setNullTimestamp(ts);
+ assertNotNull(rs.getTimestamp(1));
+ assertEquals(ts, rs.getTimestamp(1));
+ assertNotNull(rs.getTimestamp("column"));
+ assertEquals(ts, rs.getTimestamp("column"));
+ assertNotNull(rs.getTimestamp(1, Calendar.getInstance()));
+ assertEquals(ts, rs.getTimestamp(1, Calendar.getInstance()));
+ assertNotNull(rs.getTimestamp("column", Calendar.getInstance()));
+ assertEquals(ts, rs.getTimestamp("column", Calendar.getInstance()));
+ }
+
+ /**
+ * Tests the getURL and setNullURL implementations.
+ *
+ * Uses reflection to allow for building under JDK 1.3.
+ */
+ public void testURL() throws SQLException, MalformedURLException,
+ IllegalAccessException, IllegalArgumentException,
+ java.lang.reflect.InvocationTargetException
+ {
+ Method getUrlInt = null;
+ Method getUrlString = null;
+ try {
+ getUrlInt = ResultSet.class.getMethod("getURL",
+ new Class[] { Integer.TYPE } );
+ getUrlString = ResultSet.class.getMethod("getURL",
+ new Class[] { String.class } );
+ } catch(NoSuchMethodException e) {
+ // ignore
+ } catch(SecurityException e) {
+ // ignore
+ }
+ if (getUrlInt != null && getUrlString != null) {
+ assertEquals(null, getUrlInt.invoke(rs,
+ new Object[] { Integer.valueOf(1) } ) );
+ assertTrue(rs.wasNull());
+ assertEquals(null, getUrlString.invoke(rs,
+ new Object[] { "column" } ) );
+ assertTrue(rs.wasNull());
+ // Set what gets returned to something other than the default
+ URL u = new URL("http://www.apache.org");
+ rs2.setNullURL(u);
+ assertEquals(u, getUrlInt.invoke(rs,
+ new Object[] { Integer.valueOf(1) } ) );
+ assertEquals(u, getUrlString.invoke(rs,
+ new Object[] { "column" } ) );
+ }
+ }
+
+ /**
+ * Tests the setNullAsciiStream implementation.
+ */
+ public void testSetNullAsciiStream() throws SQLException {
+
+ assertNull(rs2.getNullAsciiStream());
+ // Set what gets returned to something other than the default
+ InputStream stream = new ByteArrayInputStream(new byte[0]);
+ rs2.setNullAsciiStream(stream);
+ assertNotNull(rs.getAsciiStream(1));
+ assertEquals(stream, rs.getAsciiStream(1));
+ assertNotNull(rs.getAsciiStream("column"));
+ assertEquals(stream, rs.getAsciiStream("column"));
+
+ }
+
+ /**
+ * Tests the setNullBigDecimal implementation.
+ */
+ public void testSetNullBigDecimal() throws SQLException {
+
+ assertNull(rs2.getNullBigDecimal());
+ // Set what gets returned to something other than the default
+ BigDecimal bd = new BigDecimal(5.0);
+ rs2.setNullBigDecimal(bd);
+ assertNotNull(rs.getBigDecimal(1));
+ assertEquals(bd, rs.getBigDecimal(1));
+ assertNotNull(rs.getBigDecimal("column"));
+ assertEquals(bd, rs.getBigDecimal("column"));
+
+ }
+
+ /**
+ * Tests the setNullBinaryStream implementation.
+ */
+ public void testSetNullBinaryStream() throws SQLException {
+
+ assertNull(rs2.getNullBinaryStream());
+ // Set what gets returned to something other than the default
+ InputStream stream = new ByteArrayInputStream(new byte[0]);
+ rs2.setNullBinaryStream(stream);
+ assertNotNull(rs.getBinaryStream(1));
+ assertEquals(stream, rs.getBinaryStream(1));
+ assertNotNull(rs.getBinaryStream("column"));
+ assertEquals(stream, rs.getBinaryStream("column"));
+
+ }
+
+ /**
+ * Tests the setNullBlob implementation.
+ */
+ public void testSetNullBlob() throws SQLException {
+
+ assertNull(rs2.getNullBlob());
+ // Set what gets returned to something other than the default
+ Blob blob = new SqlNullCheckedResultSetMockBlob();
+ rs2.setNullBlob(blob);
+ assertNotNull(rs.getBlob(1));
+ assertEquals(blob, rs.getBlob(1));
+ assertNotNull(rs.getBlob("column"));
+ assertEquals(blob, rs.getBlob("column"));
+
+ }
+
+ /**
+ * Tests the setNullBoolean implementation.
+ */
+ public void testSetNullBoolean() throws SQLException {
+
+ assertEquals(false, rs2.getNullBoolean());
+ // Set what gets returned to something other than the default
+ rs2.setNullBoolean(true);
+ assertEquals(true, rs.getBoolean(1));
+ assertEquals(true, rs.getBoolean("column"));
+
+ }
+
+ /**
+ * Tests the setNullByte implementation.
+ */
+ public void testSetNullByte() throws SQLException {
+
+ assertEquals((byte) 0, rs2.getNullByte());
+ // Set what gets returned to something other than the default
+ byte b = (byte) 10;
+ rs2.setNullByte(b);
+ assertEquals(b, rs.getByte(1));
+ assertEquals(b, rs.getByte("column"));
+
+ }
+
+ /**
+ * Tests the setNullByte implementation.
+ */
+ public void testSetNullBytes() throws SQLException {
+
+ assertNull(rs2.getNullBytes());
+ // Set what gets returned to something other than the default
+ byte[] b = new byte[5];
+ for (int i = 0; i < 5; i++) {
+ b[0] = (byte) i;
+ }
+ rs2.setNullBytes(b);
+ assertNotNull(rs.getBytes(1));
+ assertArrayEquals(b, rs.getBytes(1));
+ assertNotNull(rs.getBytes("column"));
+ assertArrayEquals(b, rs.getBytes("column"));
+
+ }
+
+ /**
+ * Tests the setNullCharacterStream implementation.
+ */
+ public void testSetNullCharacterStream() throws SQLException {
+
+ assertNull(rs2.getNullCharacterStream());
+ // Set what gets returned to something other than the default
+ Reader reader = new CharArrayReader("this is a string".toCharArray());
+ rs2.setNullCharacterStream(reader);
+ assertNotNull(rs.getCharacterStream(1));
+ assertEquals(reader, rs.getCharacterStream(1));
+ assertNotNull(rs.getCharacterStream("column"));
+ assertEquals(reader, rs.getCharacterStream("column"));
+
+ }
+
+ /**
+ * Tests the setNullClob implementation.
+ */
+ public void testSetNullClob() throws SQLException {
+
+ assertNull(rs2.getNullClob());
+ // Set what gets returned to something other than the default
+ Clob clob = new SqlNullCheckedResultSetMockClob();
+ rs2.setNullClob(clob);
+ assertNotNull(rs.getClob(1));
+ assertEquals(clob, rs.getClob(1));
+ assertNotNull(rs.getClob("column"));
+ assertEquals(clob, rs.getClob("column"));
+
+ }
+
+ /**
+ * Tests the setNullDate implementation.
+ */
+ public void testSetNullDate() throws SQLException {
+
+ assertNull(rs2.getNullDate());
+ // Set what gets returned to something other than the default
+ java.sql.Date date = new java.sql.Date(new java.util.Date().getTime());
+ rs2.setNullDate(date);
+ assertNotNull(rs.getDate(1));
+ assertEquals(date, rs.getDate(1));
+ assertNotNull(rs.getDate("column"));
+ assertEquals(date, rs.getDate("column"));
+ assertNotNull(rs.getDate(1, Calendar.getInstance()));
+ assertEquals(date, rs.getDate(1, Calendar.getInstance()));
+ assertNotNull(rs.getDate("column", Calendar.getInstance()));
+ assertEquals(date, rs.getDate("column", Calendar.getInstance()));
+
+ }
+
+ /**
+ * Tests the setNullDouble implementation.
+ */
+ public void testSetNullDouble() throws SQLException {
+ assertEquals(0.0, rs2.getNullDouble(), 0.0);
+ // Set what gets returned to something other than the default
+ double d = 10.0;
+ rs2.setNullDouble(d);
+ assertEquals(d, rs.getDouble(1), 0.0);
+ assertEquals(d, rs.getDouble("column"), 0.0);
+ }
+
+ /**
+ * Tests the setNullFloat implementation.
+ */
+ public void testSetNullFloat() throws SQLException {
+ assertEquals((float) 0.0, rs2.getNullFloat(), 0.0);
+ // Set what gets returned to something other than the default
+ float f = (float) 10.0;
+ rs2.setNullFloat(f);
+ assertEquals(f, rs.getFloat(1), 0.0);
+ assertEquals(f, rs.getFloat("column"), 0.0);
+ }
+
+ /**
+ * Tests the setNullInt implementation.
+ */
+ public void testSetNullInt() throws SQLException {
+ assertEquals(0, rs2.getNullInt());
+ assertEquals(0, rs.getInt(1));
+ assertTrue(rs.wasNull());
+ assertEquals(0, rs.getInt("column"));
+ assertTrue(rs.wasNull());
+ // Set what gets returned to something other than the default
+ int i = 10;
+ rs2.setNullInt(i);
+ assertEquals(i, rs.getInt(1));
+ assertEquals(i, rs.getInt("column"));
+ }
+
+ /**
+ * Tests the setNullLong implementation.
+ */
+ public void testSetNullLong() throws SQLException {
+ assertEquals(0, rs2.getNullLong());
+ // Set what gets returned to something other than the default
+ long l = 10;
+ rs2.setNullLong(l);
+ assertEquals(l, rs.getLong(1));
+ assertEquals(l, rs.getLong("column"));
+ }
+
+ /**
+ * Tests the setNullObject implementation.
+ */
+ public void testSetNullObject() throws SQLException {
+ assertNull(rs2.getNullObject());
+ // Set what gets returned to something other than the default
+ Object o = new Object();
+ rs2.setNullObject(o);
+ assertNotNull(rs.getObject(1));
+ assertEquals(o, rs.getObject(1));
+ assertNotNull(rs.getObject("column"));
+ assertEquals(o, rs.getObject("column"));
+ assertNotNull(rs.getObject(1, (Map<String, Class<?>>) null));
+ assertEquals(o, rs.getObject(1, (Map<String, Class<?>>) null));
+ assertNotNull(rs.getObject("column", (Map<String, Class<?>>) null));
+ assertEquals(o, rs.getObject("column", (Map<String, Class<?>>) null));
+ }
+
+ /**
+ * Tests the setNullShort implementation.
+ */
+ public void testSetNullShort() throws SQLException {
+
+ assertEquals((short) 0, rs2.getNullShort());
+ // Set what gets returned to something other than the default
+ short s = (short) 10;
+ rs2.setNullShort(s);
+ assertEquals(s, rs.getShort(1));
+ assertEquals(s, rs.getShort("column"));
+
+ }
+
+ /**
+ * Tests the setNullString implementation.
+ */
+ public void testSetNullString() throws SQLException {
+ assertEquals(null, rs2.getNullString());
+ // Set what gets returned to something other than the default
+ String s = "hello, world";
+ rs2.setNullString(s);
+ assertEquals(s, rs.getString(1));
+ assertEquals(s, rs.getString("column"));
+ }
+
+ /**
+ * Tests the setNullRef implementation.
+ */
+ public void testSetNullRef() throws SQLException {
+ assertNull(rs2.getNullRef());
+ // Set what gets returned to something other than the default
+ Ref ref = new SqlNullCheckedResultSetMockRef();
+ rs2.setNullRef(ref);
+ assertNotNull(rs.getRef(1));
+ assertEquals(ref, rs.getRef(1));
+ assertNotNull(rs.getRef("column"));
+ assertEquals(ref, rs.getRef("column"));
+ }
+
+ /**
+ * Tests the setNullTime implementation.
+ */
+ public void testSetNullTime() throws SQLException {
+ assertEquals(null, rs2.getNullTime());
+ // Set what gets returned to something other than the default
+ Time time = new Time(new java.util.Date().getTime());
+ rs2.setNullTime(time);
+ assertNotNull(rs.getTime(1));
+ assertEquals(time, rs.getTime(1));
+ assertNotNull(rs.getTime("column"));
+ assertEquals(time, rs.getTime("column"));
+ assertNotNull(rs.getTime(1, Calendar.getInstance()));
+ assertEquals(time, rs.getTime(1, Calendar.getInstance()));
+ assertNotNull(rs.getTime("column", Calendar.getInstance()));
+ assertEquals(time, rs.getTime("column", Calendar.getInstance()));
+ }
+
+ /**
+ * Tests the setNullTimestamp implementation.
+ */
+ public void testSetNullTimestamp() throws SQLException {
+ assertEquals(null, rs2.getNullTimestamp());
+ // Set what gets returned to something other than the default
+ Timestamp ts = new Timestamp(new java.util.Date().getTime());
+ rs2.setNullTimestamp(ts);
+ assertNotNull(rs.getTimestamp(1));
+ assertEquals(ts, rs.getTimestamp(1));
+ assertNotNull(rs.getTimestamp("column"));
+ assertEquals(ts, rs.getTimestamp("column"));
+ assertNotNull(rs.getTimestamp(1, Calendar.getInstance()));
+ assertEquals(ts, rs.getTimestamp(1, Calendar.getInstance()));
+ assertNotNull(rs.getTimestamp("column", Calendar.getInstance()));
+ assertEquals(ts, rs.getTimestamp("column", Calendar.getInstance()));
+ }
+
+}
+
+class SqlNullUncheckedMockResultSet implements InvocationHandler {
+
+ /**
+ * Always return false for booleans, 0 for numerics, and null for Objects.
+ * @see java.lang.reflect.InvocationHandler#invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
+ */
+ @Override
+ public Object invoke(Object proxy, Method method, Object[] args)
+ throws Throwable {
+
+ Class<?> returnType = method.getReturnType();
+
+ if (method.getName().equals("wasNull")) {
+ return Boolean.TRUE;
+
+ } else if (returnType.equals(Boolean.TYPE)) {
+ return Boolean.FALSE;
+
+ } else if (returnType.equals(Integer.TYPE)) {
+ return Integer.valueOf(0);
+
+ } else if (returnType.equals(Short.TYPE)) {
+ return Short.valueOf((short) 0);
+
+ } else if (returnType.equals(Double.TYPE)) {
+ return new Double(0);
+
+ } else if (returnType.equals(Long.TYPE)) {
+ return Long.valueOf(0);
+
+ } else if (returnType.equals(Byte.TYPE)) {
+ return Byte.valueOf((byte) 0);
+
+ } else if (returnType.equals(Float.TYPE)) {
+ return new Float(0);
+
+ } else {
+ return null;
+ }
+ }
+}
+
+class SqlNullCheckedResultSetMockBlob implements Blob {
+
+ @Override
+ public InputStream getBinaryStream() throws SQLException {
+ return new ByteArrayInputStream(new byte[0]);
+ }
+
+ @Override
+ public byte[] getBytes(long param, int param1) throws SQLException {
+ return new byte[0];
+ }
+
+ @Override
+ public long length() throws SQLException {
+ return 0;
+ }
+
+ @Override
+ public long position(byte[] values, long param) throws SQLException {
+ return 0;
+ }
+
+ @Override
+ public long position(Blob blob, long param) throws SQLException {
+ return 0;
+ }
+
+ @Override
+ public void truncate(long len) throws SQLException {
+
+ }
+
+ @Override
+ public int setBytes(long pos, byte[] bytes) throws SQLException {
+ return 0;
+ }
+
+ @Override
+ public int setBytes(long pos, byte[] bytes, int offset, int len)
+ throws SQLException {
+ return 0;
+ }
+
+ @Override
+ public OutputStream setBinaryStream(long pos) throws SQLException {
+ return null;
+ }
+
+ /**
+ * @throws SQLException
+ */
+ @Override
+ public void free() throws SQLException {
+
+ }
+
+ /**
+ * @throws SQLException
+ */
+ @Override
+ public InputStream getBinaryStream(long pos, long length) throws SQLException {
+ return null;
+ }
+
+}
+
+class SqlNullCheckedResultSetMockClob implements Clob {
+
+ @Override
+ public InputStream getAsciiStream() throws SQLException {
+ return null;
+ }
+
+ @Override
+ public Reader getCharacterStream() throws SQLException {
+ return null;
+ }
+
+ @Override
+ public String getSubString(long param, int param1) throws SQLException {
+ return "";
+ }
+
+ @Override
+ public long length() throws SQLException {
+ return 0;
+ }
+
+ @Override
+ public long position(Clob clob, long param) throws SQLException {
+ return 0;
+ }
+
+ @Override
+ public long position(String str, long param) throws SQLException {
+ return 0;
+ }
+
+ @Override
+ public void truncate(long len) throws SQLException {
+
+ }
+
+ @Override
+ public OutputStream setAsciiStream(long pos) throws SQLException {
+ return null;
+ }
+
+ @Override
+ public Writer setCharacterStream(long pos) throws SQLException {
+ return null;
+ }
+
+ @Override
+ public int setString(long pos, String str) throws SQLException {
+ return 0;
+ }
+
+ @Override
+ public int setString(long pos, String str, int offset, int len)
+ throws SQLException {
+ return 0;
+ }
+
+ /**
+ * @throws SQLException
+ */
+ @Override
+ public void free() throws SQLException {
+
+ }
+
+ /**
+ * @throws SQLException
+ */
+ @Override
+ public Reader getCharacterStream(long pos, long length) throws SQLException {
+ return null;
+ }
+
+}
+
+class SqlNullCheckedResultSetMockRef implements Ref {
+
+ @Override
+ public String getBaseTypeName() throws SQLException {
+ return "";
+ }
+
+ @Override
+ public Object getObject() throws SQLException {
+ return null;
+ }
+
+ @Override
+ public void setObject(Object value) throws SQLException {
+
+ }
+
+ @Override
+ public Object getObject(Map<String,Class<?>> map) throws SQLException {
+ return null;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/test/java/org/apache/commons/dbutils2/wrappers/StringTrimmedResultSetTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils2/wrappers/StringTrimmedResultSetTest.java b/src/test/java/org/apache/commons/dbutils2/wrappers/StringTrimmedResultSetTest.java
new file mode 100644
index 0000000..c5de076
--- /dev/null
+++ b/src/test/java/org/apache/commons/dbutils2/wrappers/StringTrimmedResultSetTest.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.dbutils2.wrappers;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+import org.apache.commons.dbutils2.BaseTestCase;
+import org.apache.commons.dbutils2.MockResultSet;
+import org.apache.commons.dbutils2.ProxyFactory;
+import org.apache.commons.dbutils2.wrappers.SqlNullCheckedResultSet;
+import org.apache.commons.dbutils2.wrappers.StringTrimmedResultSet;
+
+/**
+ * StringTrimmedResultSetTest
+ */
+public class StringTrimmedResultSetTest extends BaseTestCase {
+
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+ this.rs = StringTrimmedResultSet.wrap(this.rs);
+ }
+
+ public void testGetString() throws SQLException {
+ this.rs.next();
+ assertEquals("notInBean", rs.getString(4));
+ }
+
+ public void testGetObject() throws SQLException {
+ this.rs.next();
+ assertEquals("notInBean", rs.getObject(4));
+ }
+
+ /**
+ * Make sure 2 wrappers work together.
+ * @throws SQLException if a database access error occurs
+ */
+ public void testMultipleWrappers() throws Exception {
+ // Create a ResultSet with data
+ Object[][] rows = new Object[][] { { null }
+ };
+ ResultSet rs = MockResultSet.create(metaData, rows);
+
+ // Wrap the ResultSet with a null checked version
+ SqlNullCheckedResultSet ncrs = new SqlNullCheckedResultSet(rs);
+ ncrs.setNullString(" trim this ");
+ rs = ProxyFactory.instance().createResultSet(ncrs);
+
+ // Wrap the wrapper with a string trimmed version
+ rs = StringTrimmedResultSet.wrap(rs);
+
+ rs.next();
+ assertEquals("trim this", rs.getString(1));
+ }
+
+}
[22/58] [abbrv] commons-dbutils git commit: Tab police
Posted by th...@apache.org.
Tab police
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/dbutils/branches/2_0@1457566 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/commons-dbutils/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-dbutils/commit/9928367c
Tree: http://git-wip-us.apache.org/repos/asf/commons-dbutils/tree/9928367c
Diff: http://git-wip-us.apache.org/repos/asf/commons-dbutils/diff/9928367c
Branch: refs/heads/2_0
Commit: 9928367cf87c258518fc673ac178643d81f09db6
Parents: df2e2f3
Author: Sebastian Bazley <se...@apache.org>
Authored: Sun Mar 17 21:10:58 2013 +0000
Committer: Sebastian Bazley <se...@apache.org>
Committed: Sun Mar 17 21:10:58 2013 +0000
----------------------------------------------------------------------
src/site/xdoc/building.xml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/9928367c/src/site/xdoc/building.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/building.xml b/src/site/xdoc/building.xml
index 94eb1fc..084af2d 100644
--- a/src/site/xdoc/building.xml
+++ b/src/site/xdoc/building.xml
@@ -47,8 +47,8 @@
The result will be in "target/docs".
</p>
<p>
- Further details can be found in the
- <a href="http://commons.apache.org/building.html">commons build instructions</a>.
+ Further details can be found in the
+ <a href="http://commons.apache.org/building.html">commons build instructions</a>.
</p>
</section>
<!-- ================================================== -->
[32/58] [abbrv] commons-dbutils git commit: Update test dependencies
to latest versions
Posted by th...@apache.org.
Update test dependencies to latest versions
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/dbutils/branches/2_0@1481326 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/commons-dbutils/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-dbutils/commit/1761b745
Tree: http://git-wip-us.apache.org/repos/asf/commons-dbutils/tree/1761b745
Diff: http://git-wip-us.apache.org/repos/asf/commons-dbutils/diff/1761b745
Branch: refs/heads/2_0
Commit: 1761b745c121cba503bdd552397b621a94179dab
Parents: fe043e7
Author: Sebastian Bazley <se...@apache.org>
Authored: Sat May 11 13:38:11 2013 +0000
Committer: Sebastian Bazley <se...@apache.org>
Committed: Sat May 11 13:38:11 2013 +0000
----------------------------------------------------------------------
pom.xml | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/1761b745/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 096f6a0..4ba01d4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -195,19 +195,19 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <version>4.10</version>
+ <version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
- <version>1.9.0</version>
+ <version>1.9.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
- <version>1.1</version>
+ <version>1.3</version>
<scope>test</scope>
</dependency>
</dependencies>
[28/58] [abbrv] commons-dbutils git commit: Raw types
Posted by th...@apache.org.
Raw types
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/dbutils/branches/2_0@1481202 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/commons-dbutils/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-dbutils/commit/b4a51022
Tree: http://git-wip-us.apache.org/repos/asf/commons-dbutils/tree/b4a51022
Diff: http://git-wip-us.apache.org/repos/asf/commons-dbutils/diff/b4a51022
Branch: refs/heads/2_0
Commit: b4a510222c6e1811843a5041633962aa43c3bd21
Parents: 9784827
Author: Sebastian Bazley <se...@apache.org>
Authored: Fri May 10 21:47:35 2013 +0000
Committer: Sebastian Bazley <se...@apache.org>
Committed: Fri May 10 21:47:35 2013 +0000
----------------------------------------------------------------------
.../org/apache/commons/dbutils2/handlers/ArrayHandlerTest.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/b4a51022/src/test/java/org/apache/commons/dbutils2/handlers/ArrayHandlerTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils2/handlers/ArrayHandlerTest.java b/src/test/java/org/apache/commons/dbutils2/handlers/ArrayHandlerTest.java
index b893b89..847a5e5 100644
--- a/src/test/java/org/apache/commons/dbutils2/handlers/ArrayHandlerTest.java
+++ b/src/test/java/org/apache/commons/dbutils2/handlers/ArrayHandlerTest.java
@@ -28,7 +28,7 @@ import org.apache.commons.dbutils2.handlers.ArrayHandler;
public class ArrayHandlerTest extends BaseTestCase {
public void testHandle() throws SQLException {
- ResultSetHandler<Object[]> h = new ArrayHandler();
+ ResultSetHandler<Object[]> h = new ArrayHandler<Object>();
Object[] results = h.handle(this.rs);
assertNotNull(results);
@@ -39,7 +39,7 @@ public class ArrayHandlerTest extends BaseTestCase {
}
public void testEmptyResultSetHandle() throws SQLException {
- ResultSetHandler<Object[]> h = new ArrayHandler();
+ ResultSetHandler<Object[]> h = new ArrayHandler<Object>();
Object[] results = h.handle(this.emptyResultSet);
assertNull(results);
[57/58] [abbrv] commons-dbutils git commit: Update tests
Posted by th...@apache.org.
Update tests
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/dbutils/branches/2_0@1483134 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/commons-dbutils/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-dbutils/commit/44eafd62
Tree: http://git-wip-us.apache.org/repos/asf/commons-dbutils/tree/44eafd62
Diff: http://git-wip-us.apache.org/repos/asf/commons-dbutils/diff/44eafd62
Branch: refs/heads/2_0
Commit: 44eafd62ee55bdc0fcb64a8b72dba9ba669a6719
Parents: 4aca205
Author: Sebastian Bazley <se...@apache.org>
Authored: Thu May 16 00:50:05 2013 +0000
Committer: Sebastian Bazley <se...@apache.org>
Committed: Thu May 16 00:50:05 2013 +0000
----------------------------------------------------------------------
.../java/org/apache/commons/dbutils2/DbUtilsTest.java | 12 ++++++++++++
1 file changed, 12 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/44eafd62/src/test/java/org/apache/commons/dbutils2/DbUtilsTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils2/DbUtilsTest.java b/src/test/java/org/apache/commons/dbutils2/DbUtilsTest.java
index 3623689..7c00f90 100644
--- a/src/test/java/org/apache/commons/dbutils2/DbUtilsTest.java
+++ b/src/test/java/org/apache/commons/dbutils2/DbUtilsTest.java
@@ -16,6 +16,7 @@
*/
package org.apache.commons.dbutils2;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
@@ -270,4 +271,15 @@ public class DbUtilsTest {
verify(mockConnection).close();
}
+ @Test(expected=NullPointerException.class)
+ public void loadDriverNull() throws Exception {
+ DbUtils.loadDriver(null);
+ }
+
+ @Test
+ public void loadDriver() throws Exception {
+ assertFalse(DbUtils.loadDriver(""));
+ }
+
+ //TODO need test for getParentLogger
}
[37/58] [abbrv] commons-dbutils git commit: Updated JavaDocs to
provide a better description of the class
Posted by th...@apache.org.
Updated JavaDocs to provide a better description of the class
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/dbutils/branches/2_0@1482040 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/commons-dbutils/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-dbutils/commit/487aff91
Tree: http://git-wip-us.apache.org/repos/asf/commons-dbutils/tree/487aff91
Diff: http://git-wip-us.apache.org/repos/asf/commons-dbutils/diff/487aff91
Branch: refs/heads/2_0
Commit: 487aff917e71d343c82e799f1d18361d2e4985f5
Parents: 392c9fb
Author: Bill Speirs <ws...@apache.org>
Authored: Mon May 13 19:26:36 2013 +0000
Committer: Bill Speirs <ws...@apache.org>
Committed: Mon May 13 19:26:36 2013 +0000
----------------------------------------------------------------------
.../java/org/apache/commons/dbutils2/GenerousBeanProcessor.java | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/487aff91/src/main/java/org/apache/commons/dbutils2/GenerousBeanProcessor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/GenerousBeanProcessor.java b/src/main/java/org/apache/commons/dbutils2/GenerousBeanProcessor.java
index 3b4fb45..67e4962 100644
--- a/src/main/java/org/apache/commons/dbutils2/GenerousBeanProcessor.java
+++ b/src/main/java/org/apache/commons/dbutils2/GenerousBeanProcessor.java
@@ -24,8 +24,7 @@ import java.util.Arrays;
/**
- * Provides generous name matching (e.g. underscore-aware) from DB
- * columns to Java Bean properties.
+ * Provides generous name matching between DB columns and Java Bean properties by matching with and without underscores.
*/
public class GenerousBeanProcessor extends BeanProcessor {
[24/58] [abbrv] commons-dbutils git commit: Add missing svn:eol-style
properties
Posted by th...@apache.org.
Add missing svn:eol-style properties
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/dbutils/branches/2_0@1457567 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/commons-dbutils/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-dbutils/commit/d2ce0836
Tree: http://git-wip-us.apache.org/repos/asf/commons-dbutils/tree/d2ce0836
Diff: http://git-wip-us.apache.org/repos/asf/commons-dbutils/diff/d2ce0836
Branch: refs/heads/2_0
Commit: d2ce08361fb0c760d55e3d97737d27c396c9e8ff
Parents: 9928367
Author: Sebastian Bazley <se...@apache.org>
Authored: Sun Mar 17 21:29:20 2013 +0000
Committer: Sebastian Bazley <se...@apache.org>
Committed: Sun Mar 17 21:29:20 2013 +0000
----------------------------------------------------------------------
.../commons/dbutils2/AbstractExecutor.java | 646 +++++++++----------
.../apache/commons/dbutils2/BatchExecutor.java | 248 +++----
.../commons/dbutils2/GenerousBeanProcessor.java | 142 ++--
.../apache/commons/dbutils2/InsertExecutor.java | 228 +++----
.../apache/commons/dbutils2/QueryExecutor.java | 178 ++---
.../apache/commons/dbutils2/UpdateExecutor.java | 138 ++--
.../commons/dbutils2/AbstractExecutorTest.java | 250 +++----
.../commons/dbutils2/BatchExecutorTest.java | 138 ++--
.../dbutils2/GenerousBeanProcessorTest.java | 232 +++----
.../commons/dbutils2/InsertExecutorTest.java | 188 +++---
.../commons/dbutils2/QueryExecutorTest.java | 188 +++---
.../commons/dbutils2/UpdateExecutorTest.java | 154 ++---
12 files changed, 1365 insertions(+), 1365 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/d2ce0836/src/main/java/org/apache/commons/dbutils2/AbstractExecutor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/AbstractExecutor.java b/src/main/java/org/apache/commons/dbutils2/AbstractExecutor.java
index db15bab..25a9ab8 100644
--- a/src/main/java/org/apache/commons/dbutils2/AbstractExecutor.java
+++ b/src/main/java/org/apache/commons/dbutils2/AbstractExecutor.java
@@ -1,323 +1,323 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.dbutils2;
-
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.sql.Types;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * Abstract class for executing a query, insert, update, or batch.
- *
- * @since 2.0
- * @author William Speirs <ws...@apache.org>
- */
-abstract class AbstractExecutor<T extends AbstractExecutor<T>> {
-
- private static final String COLON = ":"; // TODO: change this to any character
-
- private final Connection conn;
- private final String sql;
- private final PreparedStatement stmt;
-
- private final Map<String, List<Integer>> paramPosMap;
- private final Map<String, Object> paramValueMap;
- private Integer currentPosition = Integer.valueOf(0);
-
- public AbstractExecutor(final Connection conn, final String sql) throws SQLException {
- this.conn = conn;
- this.sql = sql;
- this.paramPosMap = new HashMap<String, List<Integer>>();
- this.paramValueMap = new HashMap<String, Object>();
-
- final Pattern paramPattern = Pattern.compile("(:\\w+)");
- final Matcher matcher = paramPattern.matcher(sql);
-
- // go through finding params
- while (matcher.find()) {
- insertParamPosition(matcher.group().replace(COLON, ""));
- }
-
- // replace all of the :names with ?, and create a prepared statement
- stmt = conn.prepareStatement(sql.replaceAll(":\\w+", "\\?"));
- }
-
- /**
- * Helper method to insert params and the current position into the map.
- * @param param the SQL param.
- */
- private void insertParamPosition(final String param) {
- List<Integer> posList = paramPosMap.get(param);
-
- // create a new list if we need to
- if (posList == null) {
- posList = new ArrayList<Integer>();
- paramPosMap.put(param, posList);
- }
-
- // increment first, so we match SQL numbering
- posList.add(++currentPosition);
- }
-
- /**
- * Gets the SQL statement that was passed into the constructor.
- * @return the SQL statement passed into the constructor.
- */
- protected String getSql() {
- return sql;
- }
-
- /**
- * Returns the underlying prepared statement.
- * @return the underlying prepared statement.
- */
- protected PreparedStatement getStatement() {
- return stmt;
- }
-
- /**
- * Returns the underlying connection.
- * @return the underlying connection.
- */
- protected Connection getConnection() {
- return conn;
- }
-
- /**
- * Throws an exception if there are unmapped params.
- * @throws SQLException if there are unmapped params.
- */
- protected void throwIfUnmappedParams() throws SQLException {
- if (paramPosMap.size() != 0) {
- final Set<String> unmappedParams = paramPosMap.keySet();
- final StringBuilder sb = new StringBuilder("There are unbound parameters: ");
-
- for (String param:unmappedParams) {
- sb.append(param);
- sb.append(", ");
- }
-
- // remove the last comma
- sb.delete(sb.length() - 2, sb.length());
-
- // throw our exception
- throw new SQLException(sb.toString());
- }
- }
-
- /**
- * Binds a named parameter to a value.
- *
- * @param name the name of the parameter in the SQL statement.
- * @param value the value of the parameter in the SQL statement.
- * @return this execution object to provide the fluent style.
- * @throws SQLException thrown if the parameter is not found, already bound, or there is an issue binding it.
- */
- public T bind(final String name, final Object value) throws SQLException {
- return bind(name, value, true);
- }
-
- /**
- * Binds null to a parameter.
- * Types.VARCHAR is used as the type's parameter.
- * This usually works, but fails with some Oracle and MS SQL drivers.
- * @param name the name of the parameter.
- * @return this execution object to provide the fluent style.
- * @throws SQLException throw if the parameter is not found, already bound, or there is an issue binding null.
- */
- public T bindNull(final String name) throws SQLException {
- return bindNull(name, Types.VARCHAR, true);
- }
-
- /**
- * Binds null to a parameter, specifying the parameter's type.
- * @param name the name of the parameter.
- * @param sqlType the type of the parameter.
- * @return this execution object to provide the fluent style.
- * @throws SQLException throw if the parameter is not found, already bound, or there is an issue binding null.
- */
- public T bindNull(final String name, final int sqlType) throws SQLException {
- return bindNull(name, sqlType, true);
- }
-
- /**
- * Given a param name and sqlType, binds a null to that parameter.
- * @param name the name of the parameter.
- * @param sqlType the type of the parameter.
- * @param removeFromPosMap if the param should be removed from the pos map.
- * @return this
- * @throws SQLException if there is an SQLException during binding.
- */
- protected T bindNull(String name, int sqlType, boolean removeFromPosMap) throws SQLException {
- name = name.replace(COLON, ""); // so we can take ":name" or "name"
-
- final List<Integer> pos = removeFromPosMap ? paramPosMap.remove(name) : paramPosMap.get(name);
-
- if (pos == null) {
- throw new SQLException(name + " is not found in the SQL statement");
- }
-
- // go through and bind all of the positions for this name
- for (Integer p:pos) {
- stmt.setNull(p.intValue(), sqlType);
- }
-
- // add the param and value to our map
- paramValueMap.put(name, null);
-
- // suppressed because the casting will always work here
- @SuppressWarnings("unchecked")
- final T ret = (T) this;
-
- return ret;
- }
-
- /**
- * Binds value to name, but does not do the bookkeeping.
- * @param name the parameter name.
- * @param value the value.
- * @param removeFromPosMap if the param should be removed from the pos map.
- * @return this
- * @throws SQLException if there is an SQLException during binding.
- */
- protected T bind(String name, final Object value, boolean removeFromPosMap) throws SQLException {
- name = name.replace(COLON, ""); // so we can take ":name" or "name"
-
- final List<Integer> pos = removeFromPosMap ? paramPosMap.remove(name) : paramPosMap.get(name);
-
- if (pos == null) {
- throw new SQLException(name + " is not found in the SQL statement");
- }
-
- // go through and bind all of the positions for this name
- for (Integer p:pos) {
- // TODO: need to figure out how to bind NULL
- stmt.setObject(p.intValue(), value);
- }
-
- // add the param and value to our map
- paramValueMap.put(name, value);
-
- // suppressed because the casting will always work here
- @SuppressWarnings("unchecked")
- final T ret = (T) this;
-
- return ret;
- }
-
- /**
- * Used for batch calls so we can clear the map after the addBatch call.
- */
- protected void clearValueMap() {
- paramValueMap.clear();
- }
-
- /**
- * Throws a new exception with a more informative error message.
- *
- * @param cause The original exception that will be chained to the new
- * exception when it's rethrown.
- *
- * @throws SQLException if a database access error occurs
- */
- protected void rethrow(SQLException cause) throws SQLException {
- String causeMessage = cause.getMessage();
-
- if (causeMessage == null) {
- causeMessage = "";
- }
-
- final StringBuffer msg = new StringBuffer(causeMessage);
-
- msg.append(" Query: ");
- msg.append(sql);
- msg.append(" Parameters: ");
-
- // loop through adding the parameter to value mappings
- for (Map.Entry<String, Object> param:paramValueMap.entrySet()) {
- msg.append(param.getKey());
- msg.append("=");
- msg.append(param.getValue());
- msg.append(" ");
- }
-
- final SQLException e = new SQLException(msg.toString(), cause.getSQLState(), cause.getErrorCode());
- e.setNextException(cause);
-
- throw e;
- }
-
- /**
- * Wrap the <code>ResultSet</code> in a decorator before processing it. This
- * implementation returns the <code>ResultSet</code> it is given without any
- * decoration.
- *
- * @param rs The <code>ResultSet</code> to decorate; never <code>null</code>.
- * @return The <code>ResultSet</code> wrapped in some decorator.
- */
- protected ResultSet wrap(ResultSet rs) {
- return rs;
- }
-
- /**
- * Close a <code>Connection</code>. This implementation avoids closing if
- * null and does <strong>not</strong> suppress any exceptions. Subclasses
- * can override to provide special handling like logging.
- *
- * @param conn Connection to close
- * @throws SQLException if a database access error occurs
- */
- protected void close(Connection conn) throws SQLException {
- DbUtils.close(conn);
- }
-
- /**
- * Close a <code>Statement</code>. This implementation avoids closing if
- * null and does <strong>not</strong> suppress any exceptions. Subclasses
- * can override to provide special handling like logging.
- *
- * @param stmt Statement to close
- * @throws SQLException if a database access error occurs
- */
- protected void close(Statement stmt) throws SQLException {
- DbUtils.close(stmt);
- }
-
- /**
- * Close a <code>ResultSet</code>. This implementation avoids closing if
- * null and does <strong>not</strong> suppress any exceptions. Subclasses
- * can override to provide special handling like logging.
- *
- * @param rs ResultSet to close
- * @throws SQLException if a database access error occurs
- */
- protected void close(ResultSet rs) throws SQLException {
- DbUtils.close(rs);
- }
-
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.dbutils2;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.sql.Types;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * Abstract class for executing a query, insert, update, or batch.
+ *
+ * @since 2.0
+ * @author William Speirs <ws...@apache.org>
+ */
+abstract class AbstractExecutor<T extends AbstractExecutor<T>> {
+
+ private static final String COLON = ":"; // TODO: change this to any character
+
+ private final Connection conn;
+ private final String sql;
+ private final PreparedStatement stmt;
+
+ private final Map<String, List<Integer>> paramPosMap;
+ private final Map<String, Object> paramValueMap;
+ private Integer currentPosition = Integer.valueOf(0);
+
+ public AbstractExecutor(final Connection conn, final String sql) throws SQLException {
+ this.conn = conn;
+ this.sql = sql;
+ this.paramPosMap = new HashMap<String, List<Integer>>();
+ this.paramValueMap = new HashMap<String, Object>();
+
+ final Pattern paramPattern = Pattern.compile("(:\\w+)");
+ final Matcher matcher = paramPattern.matcher(sql);
+
+ // go through finding params
+ while (matcher.find()) {
+ insertParamPosition(matcher.group().replace(COLON, ""));
+ }
+
+ // replace all of the :names with ?, and create a prepared statement
+ stmt = conn.prepareStatement(sql.replaceAll(":\\w+", "\\?"));
+ }
+
+ /**
+ * Helper method to insert params and the current position into the map.
+ * @param param the SQL param.
+ */
+ private void insertParamPosition(final String param) {
+ List<Integer> posList = paramPosMap.get(param);
+
+ // create a new list if we need to
+ if (posList == null) {
+ posList = new ArrayList<Integer>();
+ paramPosMap.put(param, posList);
+ }
+
+ // increment first, so we match SQL numbering
+ posList.add(++currentPosition);
+ }
+
+ /**
+ * Gets the SQL statement that was passed into the constructor.
+ * @return the SQL statement passed into the constructor.
+ */
+ protected String getSql() {
+ return sql;
+ }
+
+ /**
+ * Returns the underlying prepared statement.
+ * @return the underlying prepared statement.
+ */
+ protected PreparedStatement getStatement() {
+ return stmt;
+ }
+
+ /**
+ * Returns the underlying connection.
+ * @return the underlying connection.
+ */
+ protected Connection getConnection() {
+ return conn;
+ }
+
+ /**
+ * Throws an exception if there are unmapped params.
+ * @throws SQLException if there are unmapped params.
+ */
+ protected void throwIfUnmappedParams() throws SQLException {
+ if (paramPosMap.size() != 0) {
+ final Set<String> unmappedParams = paramPosMap.keySet();
+ final StringBuilder sb = new StringBuilder("There are unbound parameters: ");
+
+ for (String param:unmappedParams) {
+ sb.append(param);
+ sb.append(", ");
+ }
+
+ // remove the last comma
+ sb.delete(sb.length() - 2, sb.length());
+
+ // throw our exception
+ throw new SQLException(sb.toString());
+ }
+ }
+
+ /**
+ * Binds a named parameter to a value.
+ *
+ * @param name the name of the parameter in the SQL statement.
+ * @param value the value of the parameter in the SQL statement.
+ * @return this execution object to provide the fluent style.
+ * @throws SQLException thrown if the parameter is not found, already bound, or there is an issue binding it.
+ */
+ public T bind(final String name, final Object value) throws SQLException {
+ return bind(name, value, true);
+ }
+
+ /**
+ * Binds null to a parameter.
+ * Types.VARCHAR is used as the type's parameter.
+ * This usually works, but fails with some Oracle and MS SQL drivers.
+ * @param name the name of the parameter.
+ * @return this execution object to provide the fluent style.
+ * @throws SQLException throw if the parameter is not found, already bound, or there is an issue binding null.
+ */
+ public T bindNull(final String name) throws SQLException {
+ return bindNull(name, Types.VARCHAR, true);
+ }
+
+ /**
+ * Binds null to a parameter, specifying the parameter's type.
+ * @param name the name of the parameter.
+ * @param sqlType the type of the parameter.
+ * @return this execution object to provide the fluent style.
+ * @throws SQLException throw if the parameter is not found, already bound, or there is an issue binding null.
+ */
+ public T bindNull(final String name, final int sqlType) throws SQLException {
+ return bindNull(name, sqlType, true);
+ }
+
+ /**
+ * Given a param name and sqlType, binds a null to that parameter.
+ * @param name the name of the parameter.
+ * @param sqlType the type of the parameter.
+ * @param removeFromPosMap if the param should be removed from the pos map.
+ * @return this
+ * @throws SQLException if there is an SQLException during binding.
+ */
+ protected T bindNull(String name, int sqlType, boolean removeFromPosMap) throws SQLException {
+ name = name.replace(COLON, ""); // so we can take ":name" or "name"
+
+ final List<Integer> pos = removeFromPosMap ? paramPosMap.remove(name) : paramPosMap.get(name);
+
+ if (pos == null) {
+ throw new SQLException(name + " is not found in the SQL statement");
+ }
+
+ // go through and bind all of the positions for this name
+ for (Integer p:pos) {
+ stmt.setNull(p.intValue(), sqlType);
+ }
+
+ // add the param and value to our map
+ paramValueMap.put(name, null);
+
+ // suppressed because the casting will always work here
+ @SuppressWarnings("unchecked")
+ final T ret = (T) this;
+
+ return ret;
+ }
+
+ /**
+ * Binds value to name, but does not do the bookkeeping.
+ * @param name the parameter name.
+ * @param value the value.
+ * @param removeFromPosMap if the param should be removed from the pos map.
+ * @return this
+ * @throws SQLException if there is an SQLException during binding.
+ */
+ protected T bind(String name, final Object value, boolean removeFromPosMap) throws SQLException {
+ name = name.replace(COLON, ""); // so we can take ":name" or "name"
+
+ final List<Integer> pos = removeFromPosMap ? paramPosMap.remove(name) : paramPosMap.get(name);
+
+ if (pos == null) {
+ throw new SQLException(name + " is not found in the SQL statement");
+ }
+
+ // go through and bind all of the positions for this name
+ for (Integer p:pos) {
+ // TODO: need to figure out how to bind NULL
+ stmt.setObject(p.intValue(), value);
+ }
+
+ // add the param and value to our map
+ paramValueMap.put(name, value);
+
+ // suppressed because the casting will always work here
+ @SuppressWarnings("unchecked")
+ final T ret = (T) this;
+
+ return ret;
+ }
+
+ /**
+ * Used for batch calls so we can clear the map after the addBatch call.
+ */
+ protected void clearValueMap() {
+ paramValueMap.clear();
+ }
+
+ /**
+ * Throws a new exception with a more informative error message.
+ *
+ * @param cause The original exception that will be chained to the new
+ * exception when it's rethrown.
+ *
+ * @throws SQLException if a database access error occurs
+ */
+ protected void rethrow(SQLException cause) throws SQLException {
+ String causeMessage = cause.getMessage();
+
+ if (causeMessage == null) {
+ causeMessage = "";
+ }
+
+ final StringBuffer msg = new StringBuffer(causeMessage);
+
+ msg.append(" Query: ");
+ msg.append(sql);
+ msg.append(" Parameters: ");
+
+ // loop through adding the parameter to value mappings
+ for (Map.Entry<String, Object> param:paramValueMap.entrySet()) {
+ msg.append(param.getKey());
+ msg.append("=");
+ msg.append(param.getValue());
+ msg.append(" ");
+ }
+
+ final SQLException e = new SQLException(msg.toString(), cause.getSQLState(), cause.getErrorCode());
+ e.setNextException(cause);
+
+ throw e;
+ }
+
+ /**
+ * Wrap the <code>ResultSet</code> in a decorator before processing it. This
+ * implementation returns the <code>ResultSet</code> it is given without any
+ * decoration.
+ *
+ * @param rs The <code>ResultSet</code> to decorate; never <code>null</code>.
+ * @return The <code>ResultSet</code> wrapped in some decorator.
+ */
+ protected ResultSet wrap(ResultSet rs) {
+ return rs;
+ }
+
+ /**
+ * Close a <code>Connection</code>. This implementation avoids closing if
+ * null and does <strong>not</strong> suppress any exceptions. Subclasses
+ * can override to provide special handling like logging.
+ *
+ * @param conn Connection to close
+ * @throws SQLException if a database access error occurs
+ */
+ protected void close(Connection conn) throws SQLException {
+ DbUtils.close(conn);
+ }
+
+ /**
+ * Close a <code>Statement</code>. This implementation avoids closing if
+ * null and does <strong>not</strong> suppress any exceptions. Subclasses
+ * can override to provide special handling like logging.
+ *
+ * @param stmt Statement to close
+ * @throws SQLException if a database access error occurs
+ */
+ protected void close(Statement stmt) throws SQLException {
+ DbUtils.close(stmt);
+ }
+
+ /**
+ * Close a <code>ResultSet</code>. This implementation avoids closing if
+ * null and does <strong>not</strong> suppress any exceptions. Subclasses
+ * can override to provide special handling like logging.
+ *
+ * @param rs ResultSet to close
+ * @throws SQLException if a database access error occurs
+ */
+ protected void close(ResultSet rs) throws SQLException {
+ DbUtils.close(rs);
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/d2ce0836/src/main/java/org/apache/commons/dbutils2/BatchExecutor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/BatchExecutor.java b/src/main/java/org/apache/commons/dbutils2/BatchExecutor.java
index 64f1679..d25d435 100644
--- a/src/main/java/org/apache/commons/dbutils2/BatchExecutor.java
+++ b/src/main/java/org/apache/commons/dbutils2/BatchExecutor.java
@@ -1,124 +1,124 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.dbutils2;
-
-import java.sql.Connection;
-import java.sql.SQLException;
-import java.sql.Types;
-
-/**
- * This class provides the ability to execute a batch of statements.
- *
- * It is really just a facade to an array of UpdateExecutors.
- *
- * @since 2.0
- * @author William Speirs <ws...@apache.org>
- */
-public class BatchExecutor extends AbstractExecutor<BatchExecutor> {
-
- private final boolean closeConn;
-
- /**
- * Constructs a BatchExecutor given a connection and SQL statement.
- * @param conn The connection to use during execution.
- * @param sql The SQL statement.
- * @param closeConnection If the connection should be closed or not.
- * @throws SQLException thrown if there is an error during execution.
- */
- BatchExecutor(final Connection conn, final String sql, final boolean closeConnection) throws SQLException {
- super(conn, sql);
- this.closeConn = closeConnection;
- }
-
- /**
- * Binds a parameter name to a value for a given statement.
- * @param name the name of the parameter.
- * @param value the value to bind to the parameter.
- * @return this object.
- * @throws SQLException thrown if the statement number does not exist, or any other SQLException.
- * @see org.apache.commons.dbutils2.UpdateExecutor#bind(String, Object)
- */
- @Override
- public BatchExecutor bind(final String name, final Object value) throws SQLException {
- return bind(name, value, false);
- }
-
- /**
- * Binds null to a parameter.
- * Types.VARCHAR is used as the type's parameter.
- * This usually works, but fails with some Oracle and MS SQL drivers.
- * @param name the name of the parameter.
- * @return this execution object to provide the fluent style.
- * @throws SQLException throw if the parameter is not found, already bound, or there is an issue binding null.
- */
- @Override
- public BatchExecutor bindNull(final String name) throws SQLException {
- return bindNull(name, Types.VARCHAR, false);
- }
-
- /**
- * Binds null to a parameter, specifying the parameter's type.
- * @param name the name of the parameter.
- * @param sqlType the type of the parameter.
- * @return this execution object to provide the fluent style.
- * @throws SQLException throw if the parameter is not found, already bound, or there is an issue binding null.
- */
- @Override
- public BatchExecutor bindNull(final String name, final int sqlType) throws SQLException {
- return bindNull(name, sqlType, false);
- }
-
- /**
- * Adds the statement to the batch after binding all of the parameters.
- * @return this object.
- * @throws SQLException if a SQLException is thrown during the addBatch() call.
- * @see java.sql.PreparedStatement#addBatch()
- */
- public BatchExecutor addBatch() throws SQLException {
- try {
- getStatement().addBatch();
- clearValueMap();
- } catch (SQLException e) {
- rethrow(e);
- }
-
- return this;
- }
-
- /**
- * Calls batch after checking the parameters to ensure nothing is null.
- * @return an array containing the number of rows updated for each statement.
- * @throws SQLException If there are database or parameter errors.
- * @see org.apache.commons.dbutils2.UpdateExecutor#execute()
- */
- public int[] execute() throws SQLException {
- try {
- return getStatement().executeBatch();
- } catch (SQLException e) {
- rethrow(e);
- } finally {
- close(getStatement());
- if (closeConn) {
- close(getConnection());
- }
- }
-
- // we get here only if something is thrown
- return null;
- }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.dbutils2;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.sql.Types;
+
+/**
+ * This class provides the ability to execute a batch of statements.
+ *
+ * It is really just a facade to an array of UpdateExecutors.
+ *
+ * @since 2.0
+ * @author William Speirs <ws...@apache.org>
+ */
+public class BatchExecutor extends AbstractExecutor<BatchExecutor> {
+
+ private final boolean closeConn;
+
+ /**
+ * Constructs a BatchExecutor given a connection and SQL statement.
+ * @param conn The connection to use during execution.
+ * @param sql The SQL statement.
+ * @param closeConnection If the connection should be closed or not.
+ * @throws SQLException thrown if there is an error during execution.
+ */
+ BatchExecutor(final Connection conn, final String sql, final boolean closeConnection) throws SQLException {
+ super(conn, sql);
+ this.closeConn = closeConnection;
+ }
+
+ /**
+ * Binds a parameter name to a value for a given statement.
+ * @param name the name of the parameter.
+ * @param value the value to bind to the parameter.
+ * @return this object.
+ * @throws SQLException thrown if the statement number does not exist, or any other SQLException.
+ * @see org.apache.commons.dbutils2.UpdateExecutor#bind(String, Object)
+ */
+ @Override
+ public BatchExecutor bind(final String name, final Object value) throws SQLException {
+ return bind(name, value, false);
+ }
+
+ /**
+ * Binds null to a parameter.
+ * Types.VARCHAR is used as the type's parameter.
+ * This usually works, but fails with some Oracle and MS SQL drivers.
+ * @param name the name of the parameter.
+ * @return this execution object to provide the fluent style.
+ * @throws SQLException throw if the parameter is not found, already bound, or there is an issue binding null.
+ */
+ @Override
+ public BatchExecutor bindNull(final String name) throws SQLException {
+ return bindNull(name, Types.VARCHAR, false);
+ }
+
+ /**
+ * Binds null to a parameter, specifying the parameter's type.
+ * @param name the name of the parameter.
+ * @param sqlType the type of the parameter.
+ * @return this execution object to provide the fluent style.
+ * @throws SQLException throw if the parameter is not found, already bound, or there is an issue binding null.
+ */
+ @Override
+ public BatchExecutor bindNull(final String name, final int sqlType) throws SQLException {
+ return bindNull(name, sqlType, false);
+ }
+
+ /**
+ * Adds the statement to the batch after binding all of the parameters.
+ * @return this object.
+ * @throws SQLException if a SQLException is thrown during the addBatch() call.
+ * @see java.sql.PreparedStatement#addBatch()
+ */
+ public BatchExecutor addBatch() throws SQLException {
+ try {
+ getStatement().addBatch();
+ clearValueMap();
+ } catch (SQLException e) {
+ rethrow(e);
+ }
+
+ return this;
+ }
+
+ /**
+ * Calls batch after checking the parameters to ensure nothing is null.
+ * @return an array containing the number of rows updated for each statement.
+ * @throws SQLException If there are database or parameter errors.
+ * @see org.apache.commons.dbutils2.UpdateExecutor#execute()
+ */
+ public int[] execute() throws SQLException {
+ try {
+ return getStatement().executeBatch();
+ } catch (SQLException e) {
+ rethrow(e);
+ } finally {
+ close(getStatement());
+ if (closeConn) {
+ close(getConnection());
+ }
+ }
+
+ // we get here only if something is thrown
+ return null;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/d2ce0836/src/main/java/org/apache/commons/dbutils2/GenerousBeanProcessor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/GenerousBeanProcessor.java b/src/main/java/org/apache/commons/dbutils2/GenerousBeanProcessor.java
index 0904da8..3b4fb45 100644
--- a/src/main/java/org/apache/commons/dbutils2/GenerousBeanProcessor.java
+++ b/src/main/java/org/apache/commons/dbutils2/GenerousBeanProcessor.java
@@ -1,71 +1,71 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.dbutils2;
-
-
-import java.beans.PropertyDescriptor;
-import java.sql.ResultSetMetaData;
-import java.sql.SQLException;
-import java.util.Arrays;
-
-
-/**
- * Provides generous name matching (e.g. underscore-aware) from DB
- * columns to Java Bean properties.
- */
-public class GenerousBeanProcessor extends BeanProcessor {
-
- /**
- * Default constructor.
- */
- public GenerousBeanProcessor() {
- super();
- }
-
- @Override
- protected int[] mapColumnsToProperties(final ResultSetMetaData rsmd,
- final PropertyDescriptor[] props) throws SQLException {
-
- final int cols = rsmd.getColumnCount();
- final int[] columnToProperty = new int[cols + 1];
- Arrays.fill(columnToProperty, PROPERTY_NOT_FOUND);
-
- for (int col = 1; col <= cols; col++) {
- String columnName = rsmd.getColumnLabel(col);
-
- if (null == columnName || 0 == columnName.length()) {
- columnName = rsmd.getColumnName(col);
- }
-
- final String generousColumnName = columnName.replace("_", "");
-
- for (int i = 0; i < props.length; i++) {
- final String propName = props[i].getName();
-
- // see if either the column name, or the generous one matches
- if (columnName.equalsIgnoreCase(propName) ||
- generousColumnName.equalsIgnoreCase(propName)) {
- columnToProperty[col] = i;
- break;
- }
- }
- }
-
- return columnToProperty;
- }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.dbutils2;
+
+
+import java.beans.PropertyDescriptor;
+import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
+import java.util.Arrays;
+
+
+/**
+ * Provides generous name matching (e.g. underscore-aware) from DB
+ * columns to Java Bean properties.
+ */
+public class GenerousBeanProcessor extends BeanProcessor {
+
+ /**
+ * Default constructor.
+ */
+ public GenerousBeanProcessor() {
+ super();
+ }
+
+ @Override
+ protected int[] mapColumnsToProperties(final ResultSetMetaData rsmd,
+ final PropertyDescriptor[] props) throws SQLException {
+
+ final int cols = rsmd.getColumnCount();
+ final int[] columnToProperty = new int[cols + 1];
+ Arrays.fill(columnToProperty, PROPERTY_NOT_FOUND);
+
+ for (int col = 1; col <= cols; col++) {
+ String columnName = rsmd.getColumnLabel(col);
+
+ if (null == columnName || 0 == columnName.length()) {
+ columnName = rsmd.getColumnName(col);
+ }
+
+ final String generousColumnName = columnName.replace("_", "");
+
+ for (int i = 0; i < props.length; i++) {
+ final String propName = props[i].getName();
+
+ // see if either the column name, or the generous one matches
+ if (columnName.equalsIgnoreCase(propName) ||
+ generousColumnName.equalsIgnoreCase(propName)) {
+ columnToProperty[col] = i;
+ break;
+ }
+ }
+ }
+
+ return columnToProperty;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/d2ce0836/src/main/java/org/apache/commons/dbutils2/InsertExecutor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/InsertExecutor.java b/src/main/java/org/apache/commons/dbutils2/InsertExecutor.java
index 9b5cecb..73c1b30 100644
--- a/src/main/java/org/apache/commons/dbutils2/InsertExecutor.java
+++ b/src/main/java/org/apache/commons/dbutils2/InsertExecutor.java
@@ -1,114 +1,114 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.dbutils2;
-
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-
-/**
- * Fluent class for executing inserts.
- *
- * @since 2.0
- * @author William Speirs <ws...@apache.org>
- */
-public class InsertExecutor extends AbstractExecutor<InsertExecutor> {
-
- private final boolean closeConn;
-
- /**
- * Constructs an InsertExecutor given a connection and SQL statement.
- * @param conn The connection to use during execution.
- * @param sql The SQL statement.
- * @param closeConnection If the connection should be closed or not.
- * @throws SQLException thrown if there is an error during execution.
- */
- InsertExecutor(final Connection conn, final String sql, final boolean closeConnection) throws SQLException {
- super(conn, sql);
- this.closeConn = closeConnection;
- }
-
- /**
- * Executes the given INSERT SQL statement.
- *
- * @param <T> the type returned by the ResultSetHandler.
- * @param handler The handler used to create the result object from
- * the <code>ResultSet</code> of auto-generated keys.
- *
- * @return An object generated by the handler.
- * @throws SQLException If there are database or parameter errors.
- */
- public <T> T execute(ResultSetHandler<T> handler) throws SQLException {
- // throw an exception if there are unmapped parameters
- this.throwIfUnmappedParams();
-
- // make sure our handler is not null
- if (handler == null) {
- if (closeConn) {
- close(getConnection());
- }
- throw new SQLException("Null ResultSetHandler");
- }
-
- try {
- // execute the update
- getStatement().executeUpdate();
-
- // get the result set
- final ResultSet resultSet = getStatement().getGeneratedKeys();
-
- // run the handler over the results and return them
- return handler.handle(resultSet);
- } catch (SQLException e) {
- this.rethrow(e);
- } finally {
- close(getStatement());
- if (closeConn) {
- close(getConnection());
- }
- }
-
- // we get here only if something is thrown
- return null;
- }
-
- /**
- * Executes the given INSERT SQL statement.
- * @return the number of rows updated.
- * @throws SQLException If there are database or parameter errors.
- */
- public int execute() throws SQLException {
- // throw an exception if there are unmapped parameters
- this.throwIfUnmappedParams();
-
- try {
- // execute the insert
- return getStatement().executeUpdate();
- } catch (SQLException e) {
- this.rethrow(e);
- } finally {
- close(getStatement());
- if (closeConn) {
- close(getConnection());
- }
- }
-
- return 0; // only get here on an error
- }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.dbutils2;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+
+/**
+ * Fluent class for executing inserts.
+ *
+ * @since 2.0
+ * @author William Speirs <ws...@apache.org>
+ */
+public class InsertExecutor extends AbstractExecutor<InsertExecutor> {
+
+ private final boolean closeConn;
+
+ /**
+ * Constructs an InsertExecutor given a connection and SQL statement.
+ * @param conn The connection to use during execution.
+ * @param sql The SQL statement.
+ * @param closeConnection If the connection should be closed or not.
+ * @throws SQLException thrown if there is an error during execution.
+ */
+ InsertExecutor(final Connection conn, final String sql, final boolean closeConnection) throws SQLException {
+ super(conn, sql);
+ this.closeConn = closeConnection;
+ }
+
+ /**
+ * Executes the given INSERT SQL statement.
+ *
+ * @param <T> the type returned by the ResultSetHandler.
+ * @param handler The handler used to create the result object from
+ * the <code>ResultSet</code> of auto-generated keys.
+ *
+ * @return An object generated by the handler.
+ * @throws SQLException If there are database or parameter errors.
+ */
+ public <T> T execute(ResultSetHandler<T> handler) throws SQLException {
+ // throw an exception if there are unmapped parameters
+ this.throwIfUnmappedParams();
+
+ // make sure our handler is not null
+ if (handler == null) {
+ if (closeConn) {
+ close(getConnection());
+ }
+ throw new SQLException("Null ResultSetHandler");
+ }
+
+ try {
+ // execute the update
+ getStatement().executeUpdate();
+
+ // get the result set
+ final ResultSet resultSet = getStatement().getGeneratedKeys();
+
+ // run the handler over the results and return them
+ return handler.handle(resultSet);
+ } catch (SQLException e) {
+ this.rethrow(e);
+ } finally {
+ close(getStatement());
+ if (closeConn) {
+ close(getConnection());
+ }
+ }
+
+ // we get here only if something is thrown
+ return null;
+ }
+
+ /**
+ * Executes the given INSERT SQL statement.
+ * @return the number of rows updated.
+ * @throws SQLException If there are database or parameter errors.
+ */
+ public int execute() throws SQLException {
+ // throw an exception if there are unmapped parameters
+ this.throwIfUnmappedParams();
+
+ try {
+ // execute the insert
+ return getStatement().executeUpdate();
+ } catch (SQLException e) {
+ this.rethrow(e);
+ } finally {
+ close(getStatement());
+ if (closeConn) {
+ close(getConnection());
+ }
+ }
+
+ return 0; // only get here on an error
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/d2ce0836/src/main/java/org/apache/commons/dbutils2/QueryExecutor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/QueryExecutor.java b/src/main/java/org/apache/commons/dbutils2/QueryExecutor.java
index 11bd8aa..0b29dc3 100644
--- a/src/main/java/org/apache/commons/dbutils2/QueryExecutor.java
+++ b/src/main/java/org/apache/commons/dbutils2/QueryExecutor.java
@@ -1,89 +1,89 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.dbutils2;
-
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-/**
- * Fluent class for executing a query.
- *
- * @since 2.0
- * @author William Speirs <ws...@apache.org>
- */
-class QueryExecutor extends AbstractExecutor<QueryExecutor> {
-
- private final boolean closeConn;
-
- /**
- * Constructs a QueryExecutor given a connection and SQL statement.
- * @param conn The connection to use during execution.
- * @param sql The SQL statement.
- * @param closeConnection If the connection should be closed or not.
- * @throws SQLException thrown if there is an error during execution.
- */
- QueryExecutor(final Connection conn, final String sql, final boolean closeConnection) throws SQLException {
- super(conn, sql);
- this.closeConn = closeConnection;
- }
-
- /**
- * Calls query after checking the parameters to ensure nothing is null.
- *
- * @param handler The handler that converts the results into an object.
- *
- * @return The results of the query.
- * @throws SQLException If there are database or parameter errors.
- */
- public <T> T execute(ResultSetHandler<T> handler) throws SQLException {
- // throw an exception if there are unmapped parameters
- this.throwIfUnmappedParams();
-
- // make sure our handler is not null
- if (handler == null) {
- if (closeConn) {
- close(getConnection());
- }
- throw new SQLException("Null ResultSetHandler");
- }
-
- ResultSet resultSet = null;
-
- try {
- // execute the query, wrapping it
- resultSet = this.wrap(getStatement().executeQuery());
- // execute the handler
- return handler.handle(resultSet);
- } catch (SQLException e) {
- // rethrow our exception printing more information
- this.rethrow(e);
- } finally {
- try {
- close(resultSet);
- } finally {
- close(getStatement());
- if (closeConn) {
- close(getConnection());
- }
- }
- }
-
- // we get here only if something is thrown
- return null;
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.dbutils2;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+/**
+ * Fluent class for executing a query.
+ *
+ * @since 2.0
+ * @author William Speirs <ws...@apache.org>
+ */
+class QueryExecutor extends AbstractExecutor<QueryExecutor> {
+
+ private final boolean closeConn;
+
+ /**
+ * Constructs a QueryExecutor given a connection and SQL statement.
+ * @param conn The connection to use during execution.
+ * @param sql The SQL statement.
+ * @param closeConnection If the connection should be closed or not.
+ * @throws SQLException thrown if there is an error during execution.
+ */
+ QueryExecutor(final Connection conn, final String sql, final boolean closeConnection) throws SQLException {
+ super(conn, sql);
+ this.closeConn = closeConnection;
+ }
+
+ /**
+ * Calls query after checking the parameters to ensure nothing is null.
+ *
+ * @param handler The handler that converts the results into an object.
+ *
+ * @return The results of the query.
+ * @throws SQLException If there are database or parameter errors.
+ */
+ public <T> T execute(ResultSetHandler<T> handler) throws SQLException {
+ // throw an exception if there are unmapped parameters
+ this.throwIfUnmappedParams();
+
+ // make sure our handler is not null
+ if (handler == null) {
+ if (closeConn) {
+ close(getConnection());
+ }
+ throw new SQLException("Null ResultSetHandler");
+ }
+
+ ResultSet resultSet = null;
+
+ try {
+ // execute the query, wrapping it
+ resultSet = this.wrap(getStatement().executeQuery());
+ // execute the handler
+ return handler.handle(resultSet);
+ } catch (SQLException e) {
+ // rethrow our exception printing more information
+ this.rethrow(e);
+ } finally {
+ try {
+ close(resultSet);
+ } finally {
+ close(getStatement());
+ if (closeConn) {
+ close(getConnection());
+ }
+ }
+ }
+
+ // we get here only if something is thrown
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/d2ce0836/src/main/java/org/apache/commons/dbutils2/UpdateExecutor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/UpdateExecutor.java b/src/main/java/org/apache/commons/dbutils2/UpdateExecutor.java
index 882aa65..580736b 100644
--- a/src/main/java/org/apache/commons/dbutils2/UpdateExecutor.java
+++ b/src/main/java/org/apache/commons/dbutils2/UpdateExecutor.java
@@ -1,69 +1,69 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.dbutils2;
-
-import java.sql.Connection;
-import java.sql.SQLException;
-
-/**
- * Fluent class for executing updates.
- *
- * @since 2.0
- * @author William Speirs <ws...@apache.org>
- */
-public class UpdateExecutor extends AbstractExecutor<UpdateExecutor> {
-
- private final boolean closeConn;
-
- /**
- * Constructs an UpdateExecutor given a connection and SQL statement.
- * @param conn The connection to use during execution.
- * @param sql The SQL statement.
- * @param closeConnection If the connection should be closed or not.
- * @throws SQLException thrown if there is an error during execution.
- */
- UpdateExecutor(final Connection conn, final String sql, final boolean closeConnection) throws SQLException {
- super(conn, sql);
- this.closeConn = closeConnection;
- }
-
- /**
- * Calls update after checking the parameters to ensure nothing is null.
- * @return The number of rows updated.
- * @throws SQLException If there are database or parameter errors.
- */
- public int execute() throws SQLException {
- // throw an exception if there are unmapped parameters
- this.throwIfUnmappedParams();
-
- try {
- return getStatement().executeUpdate();
- } catch (SQLException e) {
- this.rethrow(e);
-
- } finally {
- close(getStatement());
- if (closeConn) {
- close(getConnection());
- }
- }
-
- // we get here only if something is thrown
- return 0;
- }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.dbutils2;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+
+/**
+ * Fluent class for executing updates.
+ *
+ * @since 2.0
+ * @author William Speirs <ws...@apache.org>
+ */
+public class UpdateExecutor extends AbstractExecutor<UpdateExecutor> {
+
+ private final boolean closeConn;
+
+ /**
+ * Constructs an UpdateExecutor given a connection and SQL statement.
+ * @param conn The connection to use during execution.
+ * @param sql The SQL statement.
+ * @param closeConnection If the connection should be closed or not.
+ * @throws SQLException thrown if there is an error during execution.
+ */
+ UpdateExecutor(final Connection conn, final String sql, final boolean closeConnection) throws SQLException {
+ super(conn, sql);
+ this.closeConn = closeConnection;
+ }
+
+ /**
+ * Calls update after checking the parameters to ensure nothing is null.
+ * @return The number of rows updated.
+ * @throws SQLException If there are database or parameter errors.
+ */
+ public int execute() throws SQLException {
+ // throw an exception if there are unmapped parameters
+ this.throwIfUnmappedParams();
+
+ try {
+ return getStatement().executeUpdate();
+ } catch (SQLException e) {
+ this.rethrow(e);
+
+ } finally {
+ close(getStatement());
+ if (closeConn) {
+ close(getConnection());
+ }
+ }
+
+ // we get here only if something is thrown
+ return 0;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/d2ce0836/src/test/java/org/apache/commons/dbutils2/AbstractExecutorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils2/AbstractExecutorTest.java b/src/test/java/org/apache/commons/dbutils2/AbstractExecutorTest.java
index 1d7c270..ff8e6d1 100644
--- a/src/test/java/org/apache/commons/dbutils2/AbstractExecutorTest.java
+++ b/src/test/java/org/apache/commons/dbutils2/AbstractExecutorTest.java
@@ -1,125 +1,125 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.dbutils2;
-
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.SQLException;
-import java.sql.Types;
-
-import org.apache.commons.dbutils2.AbstractExecutor;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-
-
-public class AbstractExecutorTest {
-
- @SuppressWarnings("rawtypes") // don't care about this in the unit test
- private AbstractExecutor executor;
-
- @Mock private Connection conn;
- @Mock private PreparedStatement stmt;
-
- @Before
- public void setup() throws SQLException {
- MockitoAnnotations.initMocks(this);
-
- when(conn.prepareStatement(any(String.class))).thenReturn(stmt);
- }
-
- @SuppressWarnings("rawtypes")
- public void createExecutor(String sql) throws SQLException {
- executor = new AbstractExecutor(conn, sql) { };
- }
-
- @Test
- public void testGoodSql() throws SQLException {
- createExecutor("select * from blah :first = first and :last=last and phone=:phone");
-
- verify(conn, times(1)).prepareStatement("select * from blah ? = first and ?=last and phone=?");
-
- executor.bind("first", "first_name")
- .bind(":last", "last_name")
- .bind("phone", Integer.valueOf(12345));
-
- verify(stmt, times(1)).setObject(1, "first_name");
- verify(stmt, times(1)).setObject(2, "last_name");
- verify(stmt, times(1)).setObject(eq(3), eq(Integer.valueOf(12345)));
-
- executor.throwIfUnmappedParams();
- }
-
- @SuppressWarnings("boxing") // test code
- @Test
- public void testNoParamsSql() throws SQLException {
- createExecutor("select * from blah");
-
- verify(conn, times(1)).prepareStatement("select * from blah");
- verify(stmt, times(0)).setObject(any(Integer.class), any(Object.class));
-
- executor.throwIfUnmappedParams();
- }
-
- @Test(expected=SQLException.class)
- public void testMissingParamSql() throws SQLException {
- createExecutor("select * from blah :first = first and :last=last");
-
- verify(conn, times(1)).prepareStatement("select * from blah ? = first and ?=last");
-
- executor.bind("first", "first_name")
- .bind(":last", "last_name")
- .bind("phone", Integer.valueOf(12345)); // should throw
-
- verify(stmt, times(1)).setObject(1, "first_name");
- verify(stmt, times(1)).setObject(2, "last_name");
- verify(stmt, times(1)).setObject(eq(3), eq(Integer.valueOf(12345)));
- }
-
- @Test(expected=SQLException.class)
- public void testDoubleBind() throws SQLException {
- createExecutor("select * from blah :first = first and :last=last");
-
- verify(conn, times(1)).prepareStatement("select * from blah ? = first and ?=last");
-
- executor.bind("first", "first_name")
- .bind(":last", "last_name")
- .bind(":last", "last_name");
-
- verify(stmt, times(1)).setObject(1, "first_name");
- verify(stmt, times(1)).setObject(2, "last_name");
- }
-
- @Test
- public void testNullBind() throws SQLException {
- createExecutor("select * from blah :first = first and :last=last");
-
- verify(conn, times(1)).prepareStatement("select * from blah ? = first and ?=last");
-
- executor.bindNull("first")
- .bindNull(":last", Types.NULL);
-
- verify(stmt, times(1)).setNull(1, Types.VARCHAR);
- verify(stmt, times(1)).setNull(2, Types.NULL);
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.dbutils2;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.sql.Types;
+
+import org.apache.commons.dbutils2.AbstractExecutor;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+
+public class AbstractExecutorTest {
+
+ @SuppressWarnings("rawtypes") // don't care about this in the unit test
+ private AbstractExecutor executor;
+
+ @Mock private Connection conn;
+ @Mock private PreparedStatement stmt;
+
+ @Before
+ public void setup() throws SQLException {
+ MockitoAnnotations.initMocks(this);
+
+ when(conn.prepareStatement(any(String.class))).thenReturn(stmt);
+ }
+
+ @SuppressWarnings("rawtypes")
+ public void createExecutor(String sql) throws SQLException {
+ executor = new AbstractExecutor(conn, sql) { };
+ }
+
+ @Test
+ public void testGoodSql() throws SQLException {
+ createExecutor("select * from blah :first = first and :last=last and phone=:phone");
+
+ verify(conn, times(1)).prepareStatement("select * from blah ? = first and ?=last and phone=?");
+
+ executor.bind("first", "first_name")
+ .bind(":last", "last_name")
+ .bind("phone", Integer.valueOf(12345));
+
+ verify(stmt, times(1)).setObject(1, "first_name");
+ verify(stmt, times(1)).setObject(2, "last_name");
+ verify(stmt, times(1)).setObject(eq(3), eq(Integer.valueOf(12345)));
+
+ executor.throwIfUnmappedParams();
+ }
+
+ @SuppressWarnings("boxing") // test code
+ @Test
+ public void testNoParamsSql() throws SQLException {
+ createExecutor("select * from blah");
+
+ verify(conn, times(1)).prepareStatement("select * from blah");
+ verify(stmt, times(0)).setObject(any(Integer.class), any(Object.class));
+
+ executor.throwIfUnmappedParams();
+ }
+
+ @Test(expected=SQLException.class)
+ public void testMissingParamSql() throws SQLException {
+ createExecutor("select * from blah :first = first and :last=last");
+
+ verify(conn, times(1)).prepareStatement("select * from blah ? = first and ?=last");
+
+ executor.bind("first", "first_name")
+ .bind(":last", "last_name")
+ .bind("phone", Integer.valueOf(12345)); // should throw
+
+ verify(stmt, times(1)).setObject(1, "first_name");
+ verify(stmt, times(1)).setObject(2, "last_name");
+ verify(stmt, times(1)).setObject(eq(3), eq(Integer.valueOf(12345)));
+ }
+
+ @Test(expected=SQLException.class)
+ public void testDoubleBind() throws SQLException {
+ createExecutor("select * from blah :first = first and :last=last");
+
+ verify(conn, times(1)).prepareStatement("select * from blah ? = first and ?=last");
+
+ executor.bind("first", "first_name")
+ .bind(":last", "last_name")
+ .bind(":last", "last_name");
+
+ verify(stmt, times(1)).setObject(1, "first_name");
+ verify(stmt, times(1)).setObject(2, "last_name");
+ }
+
+ @Test
+ public void testNullBind() throws SQLException {
+ createExecutor("select * from blah :first = first and :last=last");
+
+ verify(conn, times(1)).prepareStatement("select * from blah ? = first and ?=last");
+
+ executor.bindNull("first")
+ .bindNull(":last", Types.NULL);
+
+ verify(stmt, times(1)).setNull(1, Types.VARCHAR);
+ verify(stmt, times(1)).setNull(2, Types.NULL);
+ }
+}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/d2ce0836/src/test/java/org/apache/commons/dbutils2/BatchExecutorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils2/BatchExecutorTest.java b/src/test/java/org/apache/commons/dbutils2/BatchExecutorTest.java
index a049bc7..1ad3cd2 100644
--- a/src/test/java/org/apache/commons/dbutils2/BatchExecutorTest.java
+++ b/src/test/java/org/apache/commons/dbutils2/BatchExecutorTest.java
@@ -1,69 +1,69 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.dbutils2;
-
-import static org.junit.Assert.*;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.SQLException;
-
-import org.apache.commons.dbutils2.BatchExecutor;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-
-
-public class BatchExecutorTest {
-
- private BatchExecutor executor;
-
- @Mock private Connection conn;
- @Mock private PreparedStatement stmt;
-
- @Before
- public void setup() throws SQLException {
- MockitoAnnotations.initMocks(this);
-
- when(conn.prepareStatement(any(String.class))).thenReturn(stmt);
- when(stmt.executeBatch()).thenReturn(new int[] { 2, 3, 4 });
- }
-
- protected void createExecutor(String sql) throws Exception {
- executor = new BatchExecutor(conn, sql, true);
- }
-
- @Test
- public void testGoodSQL() throws Exception {
- createExecutor("insert into blah");
-
- executor.addBatch();
- int[] ret = executor.execute();
-
- assertEquals(3, ret.length);
- assertEquals(2, ret[0]);
- assertEquals(3, ret[1]);
- assertEquals(4, ret[2]);
- verify(conn, times(1)).close();
- verify(stmt, times(1)).close();
- }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.dbutils2;
+
+import static org.junit.Assert.*;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+
+import org.apache.commons.dbutils2.BatchExecutor;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+
+public class BatchExecutorTest {
+
+ private BatchExecutor executor;
+
+ @Mock private Connection conn;
+ @Mock private PreparedStatement stmt;
+
+ @Before
+ public void setup() throws SQLException {
+ MockitoAnnotations.initMocks(this);
+
+ when(conn.prepareStatement(any(String.class))).thenReturn(stmt);
+ when(stmt.executeBatch()).thenReturn(new int[] { 2, 3, 4 });
+ }
+
+ protected void createExecutor(String sql) throws Exception {
+ executor = new BatchExecutor(conn, sql, true);
+ }
+
+ @Test
+ public void testGoodSQL() throws Exception {
+ createExecutor("insert into blah");
+
+ executor.addBatch();
+ int[] ret = executor.execute();
+
+ assertEquals(3, ret.length);
+ assertEquals(2, ret[0]);
+ assertEquals(3, ret[1]);
+ assertEquals(4, ret[2]);
+ verify(conn, times(1)).close();
+ verify(stmt, times(1)).close();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/d2ce0836/src/test/java/org/apache/commons/dbutils2/GenerousBeanProcessorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils2/GenerousBeanProcessorTest.java b/src/test/java/org/apache/commons/dbutils2/GenerousBeanProcessorTest.java
index c31bcdd..4b96e39 100644
--- a/src/test/java/org/apache/commons/dbutils2/GenerousBeanProcessorTest.java
+++ b/src/test/java/org/apache/commons/dbutils2/GenerousBeanProcessorTest.java
@@ -1,116 +1,116 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.dbutils2;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.Mockito.when;
-import java.beans.PropertyDescriptor;
-import java.sql.ResultSetMetaData;
-
-import org.apache.commons.dbutils2.GenerousBeanProcessor;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-
-
-@SuppressWarnings("boxing") // test code
-public class GenerousBeanProcessorTest {
-
- GenerousBeanProcessor processor = new GenerousBeanProcessor();
- @Mock ResultSetMetaData metaData;
- PropertyDescriptor[] propDescriptors;
-
- @Before
- public void setUp() throws Exception {
- MockitoAnnotations.initMocks(this);
-
- propDescriptors = new PropertyDescriptor[3];
-
- propDescriptors[0] = new PropertyDescriptor("one", TestBean.class);
- propDescriptors[1] = new PropertyDescriptor("two", TestBean.class);
- propDescriptors[2] = new PropertyDescriptor("three", TestBean.class);
- }
-
- @Test
- public void testMapColumnsToPropertiesWithOutUnderscores() throws Exception {
- when(metaData.getColumnCount()).thenReturn(3);
-
- when(metaData.getColumnLabel(1)).thenReturn("three");
- when(metaData.getColumnLabel(2)).thenReturn("one");
- when(metaData.getColumnLabel(3)).thenReturn("two");
-
- int[] ret = processor.mapColumnsToProperties(metaData, propDescriptors);
-
- assertNotNull(ret);
- assertEquals(4, ret.length);
- assertEquals(-1, ret[0]);
- assertEquals(2, ret[1]);
- assertEquals(0, ret[2]);
- assertEquals(1, ret[3]);
- }
-
- @Test
- public void testMapColumnsToPropertiesWithUnderscores() throws Exception {
- when(metaData.getColumnCount()).thenReturn(3);
-
- when(metaData.getColumnLabel(1)).thenReturn("t_h_r_e_e");
- when(metaData.getColumnLabel(2)).thenReturn("o_n_e");
- when(metaData.getColumnLabel(3)).thenReturn("t_w_o");
-
- int[] ret = processor.mapColumnsToProperties(metaData, propDescriptors);
-
- assertNotNull(ret);
- assertEquals(4, ret.length);
- assertEquals(-1, ret[0]);
- assertEquals(2, ret[1]);
- assertEquals(0, ret[2]);
- assertEquals(1, ret[3]);
- }
-
- static class TestBean {
- private String one;
- private int two;
- private long three;
-
- public String getOne() {
- return one;
- }
-
- public void setOne(String one) {
- this.one = one;
- }
-
- public int getTwo() {
- return two;
- }
-
- public void setTwo(int two) {
- this.two = two;
- }
-
- public long getThree() {
- return three;
- }
-
- public void setThree(long three) {
- this.three = three;
- }
- }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.dbutils2;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Mockito.when;
+import java.beans.PropertyDescriptor;
+import java.sql.ResultSetMetaData;
+
+import org.apache.commons.dbutils2.GenerousBeanProcessor;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+
+@SuppressWarnings("boxing") // test code
+public class GenerousBeanProcessorTest {
+
+ GenerousBeanProcessor processor = new GenerousBeanProcessor();
+ @Mock ResultSetMetaData metaData;
+ PropertyDescriptor[] propDescriptors;
+
+ @Before
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+
+ propDescriptors = new PropertyDescriptor[3];
+
+ propDescriptors[0] = new PropertyDescriptor("one", TestBean.class);
+ propDescriptors[1] = new PropertyDescriptor("two", TestBean.class);
+ propDescriptors[2] = new PropertyDescriptor("three", TestBean.class);
+ }
+
+ @Test
+ public void testMapColumnsToPropertiesWithOutUnderscores() throws Exception {
+ when(metaData.getColumnCount()).thenReturn(3);
+
+ when(metaData.getColumnLabel(1)).thenReturn("three");
+ when(metaData.getColumnLabel(2)).thenReturn("one");
+ when(metaData.getColumnLabel(3)).thenReturn("two");
+
+ int[] ret = processor.mapColumnsToProperties(metaData, propDescriptors);
+
+ assertNotNull(ret);
+ assertEquals(4, ret.length);
+ assertEquals(-1, ret[0]);
+ assertEquals(2, ret[1]);
+ assertEquals(0, ret[2]);
+ assertEquals(1, ret[3]);
+ }
+
+ @Test
+ public void testMapColumnsToPropertiesWithUnderscores() throws Exception {
+ when(metaData.getColumnCount()).thenReturn(3);
+
+ when(metaData.getColumnLabel(1)).thenReturn("t_h_r_e_e");
+ when(metaData.getColumnLabel(2)).thenReturn("o_n_e");
+ when(metaData.getColumnLabel(3)).thenReturn("t_w_o");
+
+ int[] ret = processor.mapColumnsToProperties(metaData, propDescriptors);
+
+ assertNotNull(ret);
+ assertEquals(4, ret.length);
+ assertEquals(-1, ret[0]);
+ assertEquals(2, ret[1]);
+ assertEquals(0, ret[2]);
+ assertEquals(1, ret[3]);
+ }
+
+ static class TestBean {
+ private String one;
+ private int two;
+ private long three;
+
+ public String getOne() {
+ return one;
+ }
+
+ public void setOne(String one) {
+ this.one = one;
+ }
+
+ public int getTwo() {
+ return two;
+ }
+
+ public void setTwo(int two) {
+ this.two = two;
+ }
+
+ public long getThree() {
+ return three;
+ }
+
+ public void setThree(long three) {
+ this.three = three;
+ }
+ }
+
+}
[48/58] [abbrv] commons-dbutils git commit: Explicit boxing
Posted by th...@apache.org.
Explicit boxing
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/dbutils/branches/2_0@1482107 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/commons-dbutils/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-dbutils/commit/144fad9f
Tree: http://git-wip-us.apache.org/repos/asf/commons-dbutils/tree/144fad9f
Diff: http://git-wip-us.apache.org/repos/asf/commons-dbutils/diff/144fad9f
Branch: refs/heads/2_0
Commit: 144fad9f2995c064843b6e780e62bfab79923450
Parents: d25102b
Author: Sebastian Bazley <se...@apache.org>
Authored: Mon May 13 21:05:08 2013 +0000
Committer: Sebastian Bazley <se...@apache.org>
Committed: Mon May 13 21:05:08 2013 +0000
----------------------------------------------------------------------
src/main/java/org/apache/commons/dbutils2/AsyncExecutor.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/144fad9f/src/main/java/org/apache/commons/dbutils2/AsyncExecutor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/AsyncExecutor.java b/src/main/java/org/apache/commons/dbutils2/AsyncExecutor.java
index d1ff22b..8fe2f1c 100644
--- a/src/main/java/org/apache/commons/dbutils2/AsyncExecutor.java
+++ b/src/main/java/org/apache/commons/dbutils2/AsyncExecutor.java
@@ -89,7 +89,7 @@ public class AsyncExecutor {
@Override
public Integer call() throws Exception {
- return executor.execute();
+ return Integer.valueOf(executor.execute());
}
});
@@ -127,7 +127,7 @@ public class AsyncExecutor {
@Override
public Integer call() throws Exception {
- return executor.execute();
+ return Integer.valueOf(executor.execute());
}
});
[43/58] [abbrv] commons-dbutils git commit: Removed the explicit
default constructor
Posted by th...@apache.org.
Removed the explicit default constructor
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/dbutils/branches/2_0@1482095 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/commons-dbutils/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-dbutils/commit/a45782ef
Tree: http://git-wip-us.apache.org/repos/asf/commons-dbutils/tree/a45782ef
Diff: http://git-wip-us.apache.org/repos/asf/commons-dbutils/diff/a45782ef
Branch: refs/heads/2_0
Commit: a45782ef3067778a6681933c5ea6a3c56d9ee78d
Parents: 2fd9b9d
Author: Emmanuel Bourg <eb...@apache.org>
Authored: Mon May 13 20:46:48 2013 +0000
Committer: Emmanuel Bourg <eb...@apache.org>
Committed: Mon May 13 20:46:48 2013 +0000
----------------------------------------------------------------------
.../org/apache/commons/dbutils2/GenerousBeanProcessor.java | 7 -------
1 file changed, 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/a45782ef/src/main/java/org/apache/commons/dbutils2/GenerousBeanProcessor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/GenerousBeanProcessor.java b/src/main/java/org/apache/commons/dbutils2/GenerousBeanProcessor.java
index 67e4962..3c03765 100644
--- a/src/main/java/org/apache/commons/dbutils2/GenerousBeanProcessor.java
+++ b/src/main/java/org/apache/commons/dbutils2/GenerousBeanProcessor.java
@@ -28,13 +28,6 @@ import java.util.Arrays;
*/
public class GenerousBeanProcessor extends BeanProcessor {
- /**
- * Default constructor.
- */
- public GenerousBeanProcessor() {
- super();
- }
-
@Override
protected int[] mapColumnsToProperties(final ResultSetMetaData rsmd,
final PropertyDescriptor[] props) throws SQLException {
[56/58] [abbrv] commons-dbutils git commit: DBUTILS-85 In
BeanProcessor#isCompatibleType,
can Integer.class.isInstance(value) be replaced by value instanceof Integer
(etc)? Simplified code by using instanceof.
Posted by th...@apache.org.
DBUTILS-85 In BeanProcessor#isCompatibleType, can Integer.class.isInstance(value) be replaced by value instanceof Integer (etc)?
Simplified code by using instanceof.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/dbutils/branches/2_0@1482487 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/commons-dbutils/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-dbutils/commit/4aca205a
Tree: http://git-wip-us.apache.org/repos/asf/commons-dbutils/tree/4aca205a
Diff: http://git-wip-us.apache.org/repos/asf/commons-dbutils/diff/4aca205a
Branch: refs/heads/2_0
Commit: 4aca205af58324f2cd049f543055865852b7ce5a
Parents: c5d4dd8
Author: Sebastian Bazley <se...@apache.org>
Authored: Tue May 14 17:47:47 2013 +0000
Committer: Sebastian Bazley <se...@apache.org>
Committed: Tue May 14 17:47:47 2013 +0000
----------------------------------------------------------------------
src/changes/changes.xml | 4 ++++
.../org/apache/commons/dbutils2/BeanProcessor.java | 16 ++++++++--------
2 files changed, 12 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/4aca205a/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 788596f..db34662 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -48,6 +48,10 @@ The <action> type attribute can be add,update,fix,remove.
This is the first release of the 2.x branch of the Commons DbUtils package, DbUtils2.
The motivation for creating DbUtils2 was two-fold: a number of deprecated methods in the original DbUtils, and the desire to support named parameters (DBUTILS-105).
">
+ <action dev="sebb" type="update" issue="DBUTILS-85">
+ In BeanProcessor#isCompatibleType, can Integer.class.isInstance(value) be replaced by value instanceof Integer (etc)?
+ Simplified code by using instanceof.
+ </action>
<action dev="sebb" type="fix" issue="DBUTILS-106">
DBUtils can't build using JDK 1.7 - DriverProxy needs to implement getParentLogger()
Add dynamic invocation.
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/4aca205a/src/main/java/org/apache/commons/dbutils2/BeanProcessor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/BeanProcessor.java b/src/main/java/org/apache/commons/dbutils2/BeanProcessor.java
index 6e621b5..41f747a 100644
--- a/src/main/java/org/apache/commons/dbutils2/BeanProcessor.java
+++ b/src/main/java/org/apache/commons/dbutils2/BeanProcessor.java
@@ -310,28 +310,28 @@ public class BeanProcessor {
if (value == null || type.isInstance(value)) {
return true;
- } else if (type.equals(Integer.TYPE) && Integer.class.isInstance(value)) {
+ } else if (type.equals(Integer.TYPE) && value instanceof Integer) {
return true;
- } else if (type.equals(Long.TYPE) && Long.class.isInstance(value)) {
+ } else if (type.equals(Long.TYPE) && value instanceof Long) {
return true;
- } else if (type.equals(Double.TYPE) && Double.class.isInstance(value)) {
+ } else if (type.equals(Double.TYPE) && value instanceof Double) {
return true;
- } else if (type.equals(Float.TYPE) && Float.class.isInstance(value)) {
+ } else if (type.equals(Float.TYPE) && value instanceof Float) {
return true;
- } else if (type.equals(Short.TYPE) && Short.class.isInstance(value)) {
+ } else if (type.equals(Short.TYPE) && value instanceof Short) {
return true;
- } else if (type.equals(Byte.TYPE) && Byte.class.isInstance(value)) {
+ } else if (type.equals(Byte.TYPE) && value instanceof Byte) {
return true;
- } else if (type.equals(Character.TYPE) && Character.class.isInstance(value)) {
+ } else if (type.equals(Character.TYPE) && value instanceof Character) {
return true;
- } else if (type.equals(Boolean.TYPE) && Boolean.class.isInstance(value)) {
+ } else if (type.equals(Boolean.TYPE) && value instanceof Boolean) {
return true;
}
[04/58] [abbrv] commons-dbutils git commit: Changed the package names
so dbutils and dbutils2 won't conflict if both loaded
Posted by th...@apache.org.
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/test/java/org/apache/commons/dbutils/BasicRowProcessorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils/BasicRowProcessorTest.java b/src/test/java/org/apache/commons/dbutils/BasicRowProcessorTest.java
deleted file mode 100644
index 75ac9dd..0000000
--- a/src/test/java/org/apache/commons/dbutils/BasicRowProcessorTest.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.dbutils;
-
-import java.sql.SQLException;
-import java.text.DateFormat;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-
-/**
- * Test the BasicRowProcessor class.
- */
-public class BasicRowProcessorTest extends BaseTestCase {
-
- private static final RowProcessor processor = new BasicRowProcessor();
-
- /**
- * Format that matches Date.toString().
- * Sun Mar 14 15:19:15 MST 2004
- */
- private static final DateFormat datef =
- new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.US);
-
- public void testToArray() throws SQLException {
-
- Object[] a = null;
- assertTrue(this.rs.next());
- a = processor.toArray(this.rs);
- assertEquals(COLS, a.length);
- assertEquals("1", a[0]);
- assertEquals("2", a[1]);
- assertEquals("3", a[2]);
-
- assertTrue(this.rs.next());
- a = processor.toArray(this.rs);
- assertEquals(COLS, a.length);
-
- assertEquals("4", a[0]);
- assertEquals("5", a[1]);
- assertEquals("6", a[2]);
-
- assertFalse(this.rs.next());
- }
-
- public void testToBean() throws SQLException, ParseException {
-
- TestBean row = null;
- assertTrue(this.rs.next());
- row = processor.toBean(this.rs, TestBean.class);
- assertEquals("1", row.getOne());
- assertEquals("2", row.getTwo());
- assertEquals("3", row.getThree());
- assertEquals("not set", row.getDoNotSet());
-
- assertTrue(this.rs.next());
- row = processor.toBean(this.rs, TestBean.class);
-
- assertEquals("4", row.getOne());
- assertEquals("5", row.getTwo());
- assertEquals("6", row.getThree());
- assertEquals("not set", row.getDoNotSet());
- assertEquals(3, row.getIntTest());
- assertEquals(Integer.valueOf(4), row.getIntegerTest());
- assertEquals(null, row.getNullObjectTest());
- assertEquals(0, row.getNullPrimitiveTest());
- // test date -> string handling
- assertNotNull(row.getNotDate());
- assertTrue(!"not a date".equals(row.getNotDate()));
- datef.parse(row.getNotDate());
-
- assertFalse(this.rs.next());
-
- }
-
- public void testToBeanList() throws SQLException, ParseException {
-
- List<TestBean> list = processor.toBeanList(this.rs, TestBean.class);
- assertNotNull(list);
- assertEquals(ROWS, list.size());
-
- TestBean b = list.get(0);
- assertEquals("1", b.getOne());
- assertEquals("2", b.getTwo());
- assertEquals("3", b.getThree());
- assertEquals("not set", b.getDoNotSet());
-
- b = list.get(1);
- assertEquals("4", b.getOne());
- assertEquals("5", b.getTwo());
- assertEquals("6", b.getThree());
- assertEquals("not set", b.getDoNotSet());
- assertEquals(3, b.getIntTest());
- assertEquals(Integer.valueOf(4), b.getIntegerTest());
- assertEquals(null, b.getNullObjectTest());
- assertEquals(0, b.getNullPrimitiveTest());
- // test date -> string handling
- assertNotNull(b.getNotDate());
- assertTrue(!"not a date".equals(b.getNotDate()));
- datef.parse(b.getNotDate());
- }
-
- public void testToMap() throws SQLException {
-
- assertTrue(this.rs.next());
- Map<String, Object> m = processor.toMap(this.rs);
- assertEquals(COLS, m.keySet().size());
- assertEquals("1", m.get("one"));
- assertEquals("2", m.get("TWO"));
- assertEquals("3", m.get("Three"));
-
- assertTrue(this.rs.next());
- m = processor.toMap(this.rs);
- assertEquals(COLS, m.keySet().size());
-
- assertEquals("4", m.get("One")); // case shouldn't matter
- assertEquals("5", m.get("two"));
- assertEquals("6", m.get("THREE"));
-
- assertFalse(this.rs.next());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/test/java/org/apache/commons/dbutils/BatchExecutorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils/BatchExecutorTest.java b/src/test/java/org/apache/commons/dbutils/BatchExecutorTest.java
deleted file mode 100644
index 3d2d7be..0000000
--- a/src/test/java/org/apache/commons/dbutils/BatchExecutorTest.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.dbutils;
-
-import static org.junit.Assert.*;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.SQLException;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-
-
-public class BatchExecutorTest {
-
- private BatchExecutor executor;
-
- @Mock private Connection conn;
- @Mock private PreparedStatement stmt;
-
- @Before
- public void setup() throws SQLException {
- MockitoAnnotations.initMocks(this);
-
- when(conn.prepareStatement(any(String.class))).thenReturn(stmt);
- when(stmt.executeBatch()).thenReturn(new int[] { 2, 3, 4 });
- }
-
- protected void createExecutor(String sql) throws Exception {
- executor = new BatchExecutor(conn, sql, true);
- }
-
- @Test
- public void testGoodSQL() throws Exception {
- createExecutor("insert into blah");
-
- executor.addBatch();
- int[] ret = executor.execute();
-
- assertEquals(3, ret.length);
- assertEquals(2, ret[0]);
- assertEquals(3, ret[1]);
- assertEquals(4, ret[2]);
- verify(conn, times(1)).close();
- verify(stmt, times(1)).close();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/test/java/org/apache/commons/dbutils/BeanProcessorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils/BeanProcessorTest.java b/src/test/java/org/apache/commons/dbutils/BeanProcessorTest.java
deleted file mode 100644
index c60ffad..0000000
--- a/src/test/java/org/apache/commons/dbutils/BeanProcessorTest.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.dbutils;
-
-import java.beans.Introspector;
-import java.beans.PropertyDescriptor;
-import java.sql.ResultSetMetaData;
-import java.sql.SQLException;
-import java.util.HashMap;
-import java.util.Map;
-
-public class BeanProcessorTest extends BaseTestCase {
-
- private static final BeanProcessor beanProc = new BeanProcessor();
-
- public void testProcess() throws SQLException {
- TestBean b = null;
- assertTrue(this.rs.next());
- b = beanProc.toBean(this.rs, TestBean.class);
- assertEquals(13.0, b.getColumnProcessorDoubleTest(), 0);
-
- assertTrue(this.rs.next());
- b = beanProc.toBean(this.rs, TestBean.class);
- assertEquals(13.0, b.getColumnProcessorDoubleTest(), 0);
-
- assertFalse(this.rs.next());
- }
-
- public static class MapColumnToPropertiesBean {
- private String one;
-
- private String two;
-
- private String three;
-
- private String four;
-
- public String getOne() {
- return one;
- }
-
- public void setOne(String one) {
- this.one = one;
- }
-
- public String getTwo() {
- return two;
- }
-
- public void setTwo(String two) {
- this.two = two;
- }
-
- public String getThree() {
- return three;
- }
-
- public void setThree(String three) {
- this.three = three;
- }
-
- public String getFour() {
- return four;
- }
-
- public void setFour(String four) {
- this.four = four;
- }
- }
-
- public void testMapColumnToProperties() throws Exception {
- String[] columnNames = { "test", "test", "three" };
- String[] columnLabels = { "one", "two", null };
- ResultSetMetaData rsmd = ProxyFactory.instance().createResultSetMetaData(
- new MockResultSetMetaData(columnNames, columnLabels));
- PropertyDescriptor[] props = Introspector.getBeanInfo(MapColumnToPropertiesBean.class).getPropertyDescriptors();
-
- int[] columns = beanProc.mapColumnsToProperties(rsmd, props);
- for (int i = 1; i < columns.length; i++) {
- assertTrue(columns[i] != BeanProcessor.PROPERTY_NOT_FOUND);
- }
- }
-
- public void testMapColumnToPropertiesWithOverrides() throws Exception {
- Map<String, String> columnToPropertyOverrides = new HashMap<String, String>();
- columnToPropertyOverrides.put("five", "four");
- BeanProcessor beanProc = new BeanProcessor(columnToPropertyOverrides);
- String[] columnNames = { "test", "test", "three", "five" };
- String[] columnLabels = { "one", "two", null, null };
- ResultSetMetaData rsmd = ProxyFactory.instance().createResultSetMetaData(
- new MockResultSetMetaData(columnNames, columnLabels));
- PropertyDescriptor[] props = Introspector.getBeanInfo(MapColumnToPropertiesBean.class).getPropertyDescriptors();
-
- int[] columns = beanProc.mapColumnsToProperties(rsmd, props);
- for (int i = 1; i < columns.length; i++) {
- assertTrue(columns[i] != BeanProcessor.PROPERTY_NOT_FOUND);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/test/java/org/apache/commons/dbutils/DbUtilsTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils/DbUtilsTest.java b/src/test/java/org/apache/commons/dbutils/DbUtilsTest.java
deleted file mode 100644
index 3d2a16e..0000000
--- a/src/test/java/org/apache/commons/dbutils/DbUtilsTest.java
+++ /dev/null
@@ -1,272 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.dbutils;
-
-import static org.junit.Assert.fail;
-import static org.mockito.Mockito.doThrow;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-
-import org.junit.Test;
-
-public class DbUtilsTest {
-
- @Test
- public void closeNullConnection() throws Exception {
- DbUtils.close((Connection) null);
- }
-
- @Test
- public void closeConnection() throws Exception {
- Connection mockCon = mock(Connection.class);
- DbUtils.close(mockCon);
- verify(mockCon).close();
- }
-
- @Test
- public void closeNullResultSet() throws Exception {
- DbUtils.close((ResultSet) null);
- }
-
- @Test
- public void closeResultSet() throws Exception {
- ResultSet mockResultSet = mock(ResultSet.class);
- DbUtils.close(mockResultSet);
- verify(mockResultSet).close();
- }
-
- @Test
- public void closeNullStatement() throws Exception {
- DbUtils.close((Statement) null);
- }
-
- @Test
- public void closeStatement() throws Exception {
- Statement mockStatement = mock(Statement.class);
- DbUtils.close(mockStatement);
- verify(mockStatement).close();
- }
-
- @Test
- public void closeQuietlyNullConnection() throws Exception {
- DbUtils.closeQuietly((Connection) null);
- }
-
- @Test
- public void closeQuietlyConnection() throws Exception {
- Connection mockConnection = mock(Connection.class);
- DbUtils.closeQuietly(mockConnection);
- verify(mockConnection).close();
- }
-
- @Test
- public void closeQuietlyConnectionThrowingException() throws Exception {
- Connection mockConnection = mock(Connection.class);
- doThrow(SQLException.class).when(mockConnection).close();
- DbUtils.closeQuietly(mockConnection);
- }
-
- @Test
- public void closeQuietlyNullResultSet() throws Exception {
- DbUtils.closeQuietly((ResultSet) null);
- }
-
- @Test
- public void closeQuietlyResultSet() throws Exception {
- ResultSet mockResultSet = mock(ResultSet.class);
- DbUtils.closeQuietly(mockResultSet);
- verify(mockResultSet).close();
- }
-
- @Test
- public void closeQuietlyResultSetThrowingException() throws Exception {
- ResultSet mockResultSet = mock(ResultSet.class);
- doThrow(SQLException.class).when(mockResultSet).close();
- DbUtils.closeQuietly(mockResultSet);
- }
-
- @Test
- public void closeQuietlyNullStatement() throws Exception {
- DbUtils.closeQuietly((Statement) null);
- }
-
- @Test
- public void closeQuietlyStatement() throws Exception {
- Statement mockStatement = mock(Statement.class);
- DbUtils.closeQuietly(mockStatement);
- verify(mockStatement).close();
- }
-
- @Test
- public void closeQuietlyStatementThrowingException() throws Exception {
- Statement mockStatement = mock(Statement.class);
- doThrow(SQLException.class).when(mockStatement).close();
- DbUtils.closeQuietly(mockStatement);
- }
-
- @Test
- public void closeQuietlyConnectionResultSetStatement() throws Exception {
- Connection mockConnection = mock(Connection.class);
- ResultSet mockResultSet = mock(ResultSet.class);
- Statement mockStatement = mock(Statement.class);
- DbUtils.closeQuietly(mockConnection, mockStatement, mockResultSet);
- verify(mockConnection).close();
- verify(mockResultSet).close();
- verify(mockStatement).close();
- }
-
- @Test
- public void closeQuietlyConnectionThrowingExceptionResultSetStatement() throws Exception {
- Connection mockConnection = mock(Connection.class);
- doThrow(SQLException.class).when(mockConnection).close();
- ResultSet mockResultSet = mock(ResultSet.class);
- Statement mockStatement = mock(Statement.class);
- DbUtils.closeQuietly(mockConnection, mockStatement, mockResultSet);
- verify(mockConnection).close();
- verify(mockResultSet).close();
- verify(mockStatement).close();
- }
-
- @Test
- public void closeQuietlyConnectionResultSetThrowingExceptionStatement() throws Exception {
- Connection mockConnection = mock(Connection.class);
- ResultSet mockResultSet = mock(ResultSet.class);
- doThrow(SQLException.class).when(mockResultSet).close();
- Statement mockStatement = mock(Statement.class);
- DbUtils.closeQuietly(mockConnection, mockStatement, mockResultSet);
- verify(mockConnection).close();
- verify(mockResultSet).close();
- verify(mockStatement).close();
- }
-
- @Test
- public void closeQuietlyConnectionResultSetStatementThrowingException() throws Exception {
- Connection mockConnection = mock(Connection.class);
- ResultSet mockResultSet = mock(ResultSet.class);
- Statement mockStatement = mock(Statement.class);
- doThrow(SQLException.class).when(mockStatement).close();
- DbUtils.closeQuietly(mockConnection, mockStatement, mockResultSet);
- verify(mockConnection).close();
- verify(mockResultSet).close();
- verify(mockStatement).close();
- }
-
- @Test
- public void commitAndClose() throws Exception {
- Connection mockConnection = mock(Connection.class);
- DbUtils.commitAndClose(mockConnection);
- verify(mockConnection).commit();
- verify(mockConnection).close();
- }
-
- @Test
- public void commitAndCloseWithException() throws Exception {
- Connection mockConnection = mock(Connection.class);
- doThrow(SQLException.class).when(mockConnection).commit();
- try {
- DbUtils.commitAndClose(mockConnection);
- fail("DbUtils.commitAndClose() swallowed SQLEception!");
- } catch (SQLException e) {
- // we expect this exception
- }
- verify(mockConnection).close();
- }
-
- @Test
- public void commitAndCloseQuietly() throws Exception {
- Connection mockConnection = mock(Connection.class);
- DbUtils.commitAndClose(mockConnection);
- verify(mockConnection).commit();
- verify(mockConnection).close();
- }
-
- @Test
- public void commitAndCloseQuietlyWithException() throws Exception {
- Connection mockConnection = mock(Connection.class);
- doThrow(SQLException.class).when(mockConnection).close();
- DbUtils.commitAndCloseQuietly(mockConnection);
- verify(mockConnection).commit();
- verify(mockConnection).close();
- }
-
- @Test
- public void rollbackNull() throws Exception {
- DbUtils.rollback(null);
- }
-
- @Test
- public void rollback() throws Exception {
- Connection mockConnection = mock(Connection.class);
- DbUtils.rollback(mockConnection);
- verify(mockConnection).rollback();
- }
-
- @Test
- public void rollbackAndCloseNull() throws Exception {
- DbUtils.rollbackAndClose(null);
- }
-
- @Test
- public void rollbackAndClose() throws Exception {
- Connection mockConnection = mock(Connection.class);
- DbUtils.rollbackAndClose(mockConnection);
- verify(mockConnection).rollback();
- verify(mockConnection).close();
- }
-
- @Test
- public void rollbackAndCloseWithException() throws Exception {
- Connection mockConnection = mock(Connection.class);
- doThrow(SQLException.class).when(mockConnection).rollback();
- try {
- DbUtils.rollbackAndClose(mockConnection);
- fail("DbUtils.rollbackAndClose() swallowed SQLException!");
- } catch (SQLException e) {
- // we expect this exeption
- }
- verify(mockConnection).rollback();
- verify(mockConnection).close();
- }
-
- @Test
- public void rollbackAndCloseQuietlyNull() throws Exception {
- DbUtils.rollbackAndCloseQuietly(null);
- }
-
- @Test
- public void rollbackAndCloseQuietly() throws Exception {
- Connection mockConnection = mock(Connection.class);
- DbUtils.rollbackAndCloseQuietly(mockConnection);
- verify(mockConnection).rollback();
- verify(mockConnection).close();
- }
-
- @Test
- public void rollbackAndCloseQuietlyWithException() throws Exception {
- Connection mockConnection = mock(Connection.class);
- doThrow(SQLException.class).when(mockConnection).rollback();
- DbUtils.rollbackAndCloseQuietly(mockConnection);
- verify(mockConnection).rollback();
- verify(mockConnection).close();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/test/java/org/apache/commons/dbutils/GenerousBeanProcessorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils/GenerousBeanProcessorTest.java b/src/test/java/org/apache/commons/dbutils/GenerousBeanProcessorTest.java
deleted file mode 100644
index 4d88fd7..0000000
--- a/src/test/java/org/apache/commons/dbutils/GenerousBeanProcessorTest.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.dbutils;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.Mockito.when;
-import java.beans.PropertyDescriptor;
-import java.sql.ResultSetMetaData;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-
-
-public class GenerousBeanProcessorTest {
-
- GenerousBeanProcessor processor = new GenerousBeanProcessor();
- @Mock ResultSetMetaData metaData;
- PropertyDescriptor[] propDescriptors;
-
- @Before
- public void setUp() throws Exception {
- MockitoAnnotations.initMocks(this);
-
- propDescriptors = new PropertyDescriptor[3];
-
- propDescriptors[0] = new PropertyDescriptor("one", TestBean.class);
- propDescriptors[1] = new PropertyDescriptor("two", TestBean.class);
- propDescriptors[2] = new PropertyDescriptor("three", TestBean.class);
- }
-
- @Test
- public void testMapColumnsToPropertiesWithOutUnderscores() throws Exception {
- when(metaData.getColumnCount()).thenReturn(3);
-
- when(metaData.getColumnLabel(1)).thenReturn("three");
- when(metaData.getColumnLabel(2)).thenReturn("one");
- when(metaData.getColumnLabel(3)).thenReturn("two");
-
- int[] ret = processor.mapColumnsToProperties(metaData, propDescriptors);
-
- assertNotNull(ret);
- assertEquals(4, ret.length);
- assertEquals(-1, ret[0]);
- assertEquals(2, ret[1]);
- assertEquals(0, ret[2]);
- assertEquals(1, ret[3]);
- }
-
- @Test
- public void testMapColumnsToPropertiesWithUnderscores() throws Exception {
- when(metaData.getColumnCount()).thenReturn(3);
-
- when(metaData.getColumnLabel(1)).thenReturn("t_h_r_e_e");
- when(metaData.getColumnLabel(2)).thenReturn("o_n_e");
- when(metaData.getColumnLabel(3)).thenReturn("t_w_o");
-
- int[] ret = processor.mapColumnsToProperties(metaData, propDescriptors);
-
- assertNotNull(ret);
- assertEquals(4, ret.length);
- assertEquals(-1, ret[0]);
- assertEquals(2, ret[1]);
- assertEquals(0, ret[2]);
- assertEquals(1, ret[3]);
- }
-
- static class TestBean {
- private String one;
- private int two;
- private long three;
-
- public String getOne() {
- return one;
- }
-
- public void setOne(String one) {
- this.one = one;
- }
-
- public int getTwo() {
- return two;
- }
-
- public void setTwo(int two) {
- this.two = two;
- }
-
- public long getThree() {
- return three;
- }
-
- public void setThree(long three) {
- this.three = three;
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/test/java/org/apache/commons/dbutils/InsertExecutorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils/InsertExecutorTest.java b/src/test/java/org/apache/commons/dbutils/InsertExecutorTest.java
deleted file mode 100644
index f96c546..0000000
--- a/src/test/java/org/apache/commons/dbutils/InsertExecutorTest.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.dbutils;
-
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-
-
-public class InsertExecutorTest {
-
- private InsertExecutor executor;
-
- @Mock private ResultSetHandler<Object> handler;
- @Mock private Connection conn;
- @Mock private PreparedStatement stmt;
- @Mock private ResultSet resultSet;
-
- @Before
- public void setup() throws SQLException {
- MockitoAnnotations.initMocks(this);
-
- when(conn.prepareStatement(any(String.class))).thenReturn(stmt);
- when(stmt.getGeneratedKeys()).thenReturn(resultSet);
- when(handler.handle(any(ResultSet.class))).thenReturn(new Object());
- }
-
- protected void createExecutor(String sql) throws Exception {
- executor = new InsertExecutor(conn, sql, true);
- }
-
- @Test
- public void testGoodSQL() throws Exception {
- createExecutor("insert into blah");
-
- Object ret = executor.execute(handler);
-
- assertNotNull(ret);
- verify(handler, times(1)).handle(resultSet);
- verify(conn, times(1)).close();
- verify(stmt, times(1)).close();
- }
-
- @Test(expected=SQLException.class)
- public void testUnmappedParams() throws Exception {
- createExecutor("insert into blah (:something)");
-
- Object ret = executor.execute(handler);
-
- assertNotNull(ret);
- verify(handler, times(1)).handle(resultSet);
- verify(conn, times(1)).close();
- verify(stmt, times(1)).close();
- }
-
- @Test(expected=SQLException.class)
- public void testNullHandler() throws Exception {
- createExecutor("insert into blah");
-
- Object ret = executor.execute(null);
-
- assertNotNull(ret);
- verify(handler, times(1)).handle(resultSet);
- verify(conn, times(1)).close();
- verify(stmt, times(1)).close();
- }
-}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/test/java/org/apache/commons/dbutils/MockResultSet.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils/MockResultSet.java b/src/test/java/org/apache/commons/dbutils/MockResultSet.java
deleted file mode 100644
index 39b8547..0000000
--- a/src/test/java/org/apache/commons/dbutils/MockResultSet.java
+++ /dev/null
@@ -1,363 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.dbutils;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.sql.ResultSet;
-import java.sql.ResultSetMetaData;
-import java.sql.SQLException;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * MockResultSet dynamically implements the ResultSet interface.
- */
-public class MockResultSet implements InvocationHandler {
-
- /**
- * Create a <code>MockResultSet</code> proxy object. This is equivalent to:
- * <pre>
- * ProxyFactory.instance().createResultSet(new MockResultSet(metaData, rows));
- * </pre>
- *
- * @param metaData
- * @param rows A null value indicates an empty <code>ResultSet</code>.
- */
- public static ResultSet create(ResultSetMetaData metaData,
- Object[][] rows) {
- return ProxyFactory.instance().createResultSet(
- new MockResultSet(metaData, rows));
- }
-
- private Object[] currentRow = null;
-
- private Iterator<Object[]> iter = null;
-
- private ResultSetMetaData metaData = null;
-
- private Boolean wasNull = Boolean.FALSE;
-
- /**
- * MockResultSet constructor.
- * @param metaData
- * @param rows A null value indicates an empty <code>ResultSet</code>.
- */
- public MockResultSet(ResultSetMetaData metaData, Object[][] rows) {
- super();
- this.metaData = metaData;
- if (rows == null) {
- List<Object[]> empty = Collections.emptyList();
- this.iter = empty.iterator();
- } else {
- this.iter = Arrays.asList(rows).iterator();
- }
- }
-
- /**
- * The get* methods can have an int column index or a String column name as
- * the parameter. This method handles both cases and returns the column
- * index that the client is trying to get at.
- * @param args
- * @return A column index.
- * @throws SQLException if a database access error occurs
- */
- private int columnIndex(Object[] args) throws SQLException {
-
- if (args[0] instanceof Integer) {
- return ((Integer) args[0]).intValue();
-
- } else if (args[0] instanceof String) {
- return this.columnNameToIndex((String) args[0]);
-
- } else {
- throw new SQLException(args[0] + " must be Integer or String");
- }
- }
-
- /**
- * Returns the column index for the given column name.
- * @return A 1 based index
- * @throws SQLException if the column name is invalid
- */
- private int columnNameToIndex(String columnName) throws SQLException {
- for (int i = 0; i < this.currentRow.length; i++) {
- int c = i + 1;
- if (this.metaData.getColumnName(c).equalsIgnoreCase(columnName)) {
- return c;
- }
- }
-
- throw new SQLException(columnName + " is not a valid column name.");
- }
-
- /**
- * Gets the boolean value at the given column index.
- * @param columnIndex A 1 based index.
- * @throws SQLException if a database access error occurs
- */
- protected Object getBoolean(int columnIndex) throws SQLException {
- Object obj = this.currentRow[columnIndex - 1];
- this.setWasNull(obj);
-
- try {
- return (obj == null)
- ? Boolean.FALSE
- : Boolean.valueOf(obj.toString());
-
- } catch (NumberFormatException e) {
- throw new SQLException(e.getMessage());
- }
- }
-
- /**
- * Gets the byte value at the given column index.
- * @param columnIndex A 1 based index.
- * @throws SQLException if a database access error occurs
- */
- protected Object getByte(int columnIndex) throws SQLException {
- Object obj = this.currentRow[columnIndex - 1];
- this.setWasNull(obj);
-
- try {
- return (obj == null)
- ? Byte.valueOf((byte) 0)
- : Byte.valueOf(obj.toString());
-
- } catch (NumberFormatException e) {
- throw new SQLException(e.getMessage());
- }
- }
-
- /**
- * Gets the double value at the given column index.
- * @param columnIndex A 1 based index.
- * @throws SQLException if a database access error occurs
- */
- protected Object getDouble(int columnIndex) throws SQLException {
- Object obj = this.currentRow[columnIndex - 1];
- this.setWasNull(obj);
-
- try {
- return (obj == null)
- ? new Double(0)
- : Double.valueOf(obj.toString());
-
- } catch (NumberFormatException e) {
- throw new SQLException(e.getMessage());
- }
- }
-
- /**
- * Gets the float value at the given column index.
- * @param columnIndex A 1 based index.
- * @throws SQLException if a database access error occurs
- */
- protected Object getFloat(int columnIndex) throws SQLException {
- Object obj = this.currentRow[columnIndex - 1];
- this.setWasNull(obj);
-
- try {
- return (obj == null) ? new Float(0) : Float.valueOf(obj.toString());
-
- } catch (NumberFormatException e) {
- throw new SQLException(e.getMessage());
- }
- }
-
- /**
- * Gets the int value at the given column index.
- * @param columnIndex A 1 based index.
- * @throws SQLException if a database access error occurs
- */
- protected Object getInt(int columnIndex) throws SQLException {
- Object obj = this.currentRow[columnIndex - 1];
- this.setWasNull(obj);
-
- try {
- return (obj == null)
- ? Integer.valueOf(0)
- : Integer.valueOf(obj.toString());
-
- } catch (NumberFormatException e) {
- throw new SQLException(e.getMessage());
- }
- }
-
- /**
- * Gets the long value at the given column index.
- * @param columnIndex A 1 based index.
- * @throws SQLException if a database access error occurs
- */
- protected Object getLong(int columnIndex) throws SQLException {
- Object obj = this.currentRow[columnIndex - 1];
- this.setWasNull(obj);
-
- try {
- return (obj == null) ? Long.valueOf(0) : Long.valueOf(obj.toString());
-
- } catch (NumberFormatException e) {
- throw new SQLException(e.getMessage());
- }
- }
-
- /**
- * @throws SQLException
- */
- protected ResultSetMetaData getMetaData() throws SQLException {
- return this.metaData;
- }
-
- /**
- * Gets the object at the given column index.
- * @param columnIndex A 1 based index.
- * @throws SQLException if a database access error occurs
- */
- protected Object getObject(int columnIndex) throws SQLException {
- Object obj = this.currentRow[columnIndex - 1];
- this.setWasNull(obj);
- return obj;
- }
-
- /**
- * Gets the short value at the given column index.
- * @param columnIndex A 1 based index.
- * @throws SQLException if a database access error occurs
- */
- protected Object getShort(int columnIndex) throws SQLException {
- Object obj = this.currentRow[columnIndex - 1];
- this.setWasNull(obj);
-
- try {
- return (obj == null)
- ? Short.valueOf((short) 0)
- : Short.valueOf(obj.toString());
-
- } catch (NumberFormatException e) {
- throw new SQLException(e.getMessage());
- }
- }
-
- /**
- * Gets the String at the given column index.
- * @param columnIndex A 1 based index.
- * @throws SQLException if a database access error occurs
- */
- protected String getString(int columnIndex) throws SQLException {
- Object obj = this.getObject(columnIndex);
- this.setWasNull(obj);
- return (obj == null) ? null : obj.toString();
- }
-
- @Override
- public Object invoke(Object proxy, Method method, Object[] args)
- throws Throwable {
-
- String methodName = method.getName();
-
- if (methodName.equals("getMetaData")) {
- return this.getMetaData();
-
- } else if (methodName.equals("next")) {
- return this.next();
-
- } else if (methodName.equals("previous")) {
-
- } else if (methodName.equals("close")) {
-
- } else if (methodName.equals("getBoolean")) {
- return this.getBoolean(columnIndex(args));
-
- } else if (methodName.equals("getByte")) {
- return this.getByte(columnIndex(args));
-
- } else if (methodName.equals("getDouble")) {
- return this.getDouble(columnIndex(args));
-
- } else if (methodName.equals("getFloat")) {
- return this.getFloat(columnIndex(args));
-
- } else if (methodName.equals("getInt")) {
- return this.getInt(columnIndex(args));
-
- } else if (methodName.equals("getLong")) {
- return this.getLong(columnIndex(args));
-
- } else if (methodName.equals("getObject")) {
- return this.getObject(columnIndex(args));
-
- } else if (methodName.equals("getShort")) {
- return this.getShort(columnIndex(args));
-
- } else if (methodName.equals("getString")) {
- return this.getString(columnIndex(args));
-
- } else if (methodName.equals("wasNull")) {
- return this.wasNull();
-
- } else if (methodName.equals("isLast")) {
- return this.isLast();
-
- } else if (methodName.equals("hashCode")) {
- return Integer.valueOf(System.identityHashCode(proxy));
-
- } else if (methodName.equals("toString")) {
- return "MockResultSet " + System.identityHashCode(proxy);
-
- } else if (methodName.equals("equals")) {
- return Boolean.valueOf(proxy == args[0]);
- }
-
- throw new UnsupportedOperationException("Unsupported method: " + methodName);
- }
-
- /**
- * @throws SQLException
- */
- protected Boolean isLast() throws SQLException {
- return this.iter.hasNext() ? Boolean.FALSE : Boolean.TRUE;
- }
-
- /**
- * @throws SQLException
- */
- protected Boolean next() throws SQLException {
- if (!this.iter.hasNext()) {
- return Boolean.FALSE;
- } else {
- this.currentRow = iter.next();
- return Boolean.TRUE;
- }
- }
-
- /**
- * Assigns this.wasNull a Boolean value based on the object passed in.
- * @param isNull
- */
- private void setWasNull(Object isNull) {
- this.wasNull = (isNull == null) ? Boolean.TRUE : Boolean.FALSE;
- }
-
- /**
- * @throws SQLException
- */
- protected Boolean wasNull() throws SQLException {
- return this.wasNull;
- }
-}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/test/java/org/apache/commons/dbutils/MockResultSetMetaData.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils/MockResultSetMetaData.java b/src/test/java/org/apache/commons/dbutils/MockResultSetMetaData.java
deleted file mode 100644
index 2e02807..0000000
--- a/src/test/java/org/apache/commons/dbutils/MockResultSetMetaData.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.dbutils;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.sql.ResultSetMetaData;
-
-/**
- * MockResultSetMetaData dynamically implements the ResultSetMetaData
- * interface.
- */
-public class MockResultSetMetaData implements InvocationHandler {
-
- private String[] columnNames = null;
- private String[] columnLabels = null;
-
- /**
- * Create a <code>MockResultSetMetaData</code> proxy object. This is
- * equivalent to:
- * <pre>
- * ProxyFactory.instance().createResultSetMetaData(new MockResultSetMetaData(columnNames));
- * </pre>
- *
- * @param columnNames
- * @return the proxy object
- */
- public static ResultSetMetaData create(String[] columnNames) {
- return ProxyFactory.instance().createResultSetMetaData(
- new MockResultSetMetaData(columnNames));
- }
-
- public MockResultSetMetaData(String[] columnNames) {
- super();
- this.columnNames = columnNames;
- this.columnLabels = new String[columnNames.length];
-
- }
-
- public MockResultSetMetaData(String[] columnNames, String[] columnLabels) {
- super();
- this.columnNames = columnNames;
- this.columnLabels = columnLabels;
-
- }
-
- @Override
- public Object invoke(Object proxy, Method method, Object[] args)
- throws Throwable {
-
- String methodName = method.getName();
-
- if (methodName.equals("getColumnCount")) {
- return Integer.valueOf(this.columnNames.length);
-
- } else if (
- methodName.equals("getColumnName")) {
-
- int col = ((Integer) args[0]).intValue() - 1;
- return this.columnNames[col];
-
- } else if (
- methodName.equals("getColumnLabel")) {
-
- int col = ((Integer) args[0]).intValue() - 1;
- return this.columnLabels[col];
-
- } else if (methodName.equals("hashCode")) {
- return Integer.valueOf(System.identityHashCode(proxy));
-
- } else if (methodName.equals("toString")) {
- return "MockResultSetMetaData " + System.identityHashCode(proxy);
-
- } else if (methodName.equals("equals")) {
- return Boolean.valueOf(proxy == args[0]);
-
- } else {
- throw new UnsupportedOperationException("Unsupported method: " + methodName);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/test/java/org/apache/commons/dbutils/ProxyFactoryTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils/ProxyFactoryTest.java b/src/test/java/org/apache/commons/dbutils/ProxyFactoryTest.java
deleted file mode 100644
index 9466e2f..0000000
--- a/src/test/java/org/apache/commons/dbutils/ProxyFactoryTest.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.dbutils;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-
-/**
- * ProxyFactoryTest performs simple type checking on proxy objects returned
- * from a ProxyFactory.
- */
-public class ProxyFactoryTest extends BaseTestCase {
-
- private static final InvocationHandler stub = new InvocationHandler() {
-
- @Override
- public Object invoke(Object proxy, Method method, Object[] args)
- throws Throwable {
-
- return null;
- }
- };
-
- public void testCreateConnection() {
- assertNotNull(ProxyFactory.instance().createConnection(stub));
- }
-
- public void testCreateDriver() {
- assertNotNull(ProxyFactory.instance().createDriver(stub));
- }
-
- public void testCreatePreparedStatement() {
- assertNotNull(ProxyFactory.instance().createPreparedStatement(stub));
- }
-
- public void testCreateResultSet() {
- assertNotNull(ProxyFactory.instance().createResultSet(stub));
- }
-
- public void testCreateResultSetMetaData() {
- assertNotNull(ProxyFactory.instance().createResultSetMetaData(stub));
- }
-
- public void testCreateStatement() {
- assertNotNull(ProxyFactory.instance().createStatement(stub));
- }
-
- public void testCreateCallableStatement() {
- assertNotNull(ProxyFactory.instance().createCallableStatement(stub));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/test/java/org/apache/commons/dbutils/QueryExecutorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils/QueryExecutorTest.java b/src/test/java/org/apache/commons/dbutils/QueryExecutorTest.java
deleted file mode 100644
index 487fed3..0000000
--- a/src/test/java/org/apache/commons/dbutils/QueryExecutorTest.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.dbutils;
-
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-
-
-public class QueryExecutorTest {
-
- private QueryExecutor executor;
-
- @Mock private ResultSetHandler<Object> handler;
- @Mock private Connection conn;
- @Mock private PreparedStatement stmt;
- @Mock private ResultSet resultSet;
-
- @Before
- public void setup() throws SQLException {
- MockitoAnnotations.initMocks(this);
-
- when(conn.prepareStatement(any(String.class))).thenReturn(stmt);
- when(stmt.executeQuery()).thenReturn(resultSet);
- when(handler.handle(any(ResultSet.class))).thenReturn(new Object());
- }
-
- protected void createExecutor(String sql) throws Exception {
- executor = new QueryExecutor(conn, sql, true);
- }
-
- @Test
- public void testGoodSQL() throws Exception {
- createExecutor("insert into blah");
-
- Object ret = executor.execute(handler);
-
- assertNotNull(ret);
- verify(handler, times(1)).handle(resultSet);
- verify(conn, times(1)).close();
- verify(stmt, times(1)).close();
- }
-
- @Test(expected=SQLException.class)
- public void testUnmappedParams() throws Exception {
- createExecutor("insert into blah (:something)");
-
- Object ret = executor.execute(handler);
-
- assertNotNull(ret);
- verify(handler, times(1)).handle(resultSet);
- verify(conn, times(1)).close();
- verify(stmt, times(1)).close();
- }
-
- @Test(expected=SQLException.class)
- public void testNullHandler() throws Exception {
- createExecutor("insert into blah");
-
- Object ret = executor.execute(null);
-
- assertNotNull(ret);
- verify(handler, times(1)).handle(resultSet);
- verify(conn, times(1)).close();
- verify(stmt, times(1)).close();
- }
-}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/test/java/org/apache/commons/dbutils/QueryLoaderTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils/QueryLoaderTest.java b/src/test/java/org/apache/commons/dbutils/QueryLoaderTest.java
deleted file mode 100644
index c4f42b6..0000000
--- a/src/test/java/org/apache/commons/dbutils/QueryLoaderTest.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.dbutils;
-
-import java.io.IOException;
-import java.util.Map;
-
-/**
- * QueryLoaderTest
- */
-public class QueryLoaderTest extends BaseTestCase {
-
- private static final String QUERIES =
- "/org/apache/commons/dbutils/TestQueries.properties";
-
- public void testLoad() throws IOException {
- try {
- QueryLoader loader = QueryLoader.instance();
- Map<String,String> q = loader.load(QUERIES);
- Map<String,String> q2 = loader.load(QUERIES);
- assertTrue(q == q2); // pointer comparison should return true
- assertEquals("SELECT * FROM SomeTable", q.get("test.query"));
-
- loader.unload(QUERIES);
- Map<String,String> q3 = loader.load(QUERIES);
- assertTrue(q != q3); // pointer comparison should return false
-
- } catch (IllegalArgumentException e) {
- // TODO Figure out why the Maven build can't find the properties
- // file. The tests run fine in Eclipse so just catch this
- // exception for now.
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/test/java/org/apache/commons/dbutils/QueryRunnerTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils/QueryRunnerTest.java b/src/test/java/org/apache/commons/dbutils/QueryRunnerTest.java
deleted file mode 100644
index 79e24cd..0000000
--- a/src/test/java/org/apache/commons/dbutils/QueryRunnerTest.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.dbutils;
-
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-import java.sql.Connection;
-import java.sql.SQLException;
-import javax.sql.DataSource;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-
-@SuppressWarnings("boxing") // test code
-public class QueryRunnerTest {
- QueryRunner runner;
-
- @Mock DataSource dataSource;
- @Mock Connection conn;
-
- @Before
- public void setUp() throws Exception {
- MockitoAnnotations.initMocks(this); // init the mocks
-
- when(dataSource.getConnection()).thenReturn(conn);
- runner = new QueryRunner(dataSource);
- }
-
- // batch tests
-
- @Test
- public void testBatchSQL() throws SQLException {
- assertNotNull(runner.batch("select * from blah where :first=first"));
- verify(dataSource, times(1)).getConnection();
- }
-
- @Test
- public void testBatchConnSQL() throws SQLException {
- assertNotNull(runner.batch(conn, "select * from blah where :first=first"));
- }
-
- @Test
- public void testBatchConnSQLBoolean() throws SQLException {
- assertNotNull(runner.batch(conn, true, "select * from blah where :first=first"));
- }
-
- @Test(expected=SQLException.class)
- public void testBatchNullConn() throws SQLException {
- assertNotNull(runner.batch(null, true, "select"));
- }
-
- @Test(expected=SQLException.class)
- public void testBatchNullSQL() throws SQLException {
- assertNotNull(runner.batch(conn, true, null));
- }
-
- // query tests
-
- @Test
- public void testQuerySQL() throws SQLException {
- assertNotNull(runner.query("select * from blah where :first=first"));
- verify(dataSource, times(1)).getConnection();
- }
-
- @Test
- public void testQueryConnSQL() throws SQLException {
- assertNotNull(runner.query(conn, "select * from blah where :first=first"));
- }
-
- @Test
- public void testQueryConnSQLBoolean() throws SQLException {
- assertNotNull(runner.query(conn, true, "select * from blah where :first=first"));
- }
-
- @Test(expected=SQLException.class)
- public void testQueryNullConn() throws SQLException {
- assertNotNull(runner.query(null, true, "select"));
- }
-
- @Test(expected=SQLException.class)
- public void testQueryNullSQL() throws SQLException {
- assertNotNull(runner.query(conn, true, null));
- }
-
- // insert tests
-
- @Test
- public void testInsertSQL() throws SQLException {
- assertNotNull(runner.insert("insert * from blah where :first=first"));
- verify(dataSource, times(1)).getConnection();
- }
-
- @Test
- public void testInsertConnSQL() throws SQLException {
- assertNotNull(runner.insert(conn, "insert * from blah where :first=first"));
- }
-
- @Test
- public void testInsertConnSQLBoolean() throws SQLException {
- assertNotNull(runner.insert(conn, true, "insert * from blah where :first=first"));
- }
-
- @Test(expected=SQLException.class)
- public void testInsertNullConn() throws SQLException {
- assertNotNull(runner.insert(null, true, "select"));
- }
-
- @Test(expected=SQLException.class)
- public void testInsertNullSQL() throws SQLException {
- assertNotNull(runner.insert(conn, true, null));
- }
-
- // update tests
-
- @Test
- public void testUpdateSQL() throws SQLException {
- assertNotNull(runner.update("select * from blah where :first=first"));
- verify(dataSource, times(1)).getConnection();
- }
-
- @Test
- public void testUpdateConnSQL() throws SQLException {
- assertNotNull(runner.update(conn, "select * from blah where :first=first"));
- }
-
- @Test
- public void testUpdateConnSQLBoolean() throws SQLException {
- assertNotNull(runner.update(conn, true, "select * from blah where :first=first"));
- }
-
- @Test(expected=SQLException.class)
- public void testUpdateNullConn() throws SQLException {
- assertNotNull(runner.update(null, true, "select"));
- }
-
- @Test(expected=SQLException.class)
- public void testUpdateNullSQL() throws SQLException {
- assertNotNull(runner.update(conn, true, null));
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/test/java/org/apache/commons/dbutils/ResultSetIteratorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils/ResultSetIteratorTest.java b/src/test/java/org/apache/commons/dbutils/ResultSetIteratorTest.java
deleted file mode 100644
index fbe0bbd..0000000
--- a/src/test/java/org/apache/commons/dbutils/ResultSetIteratorTest.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.dbutils;
-
-import java.util.Iterator;
-
-/**
- * ResultSetIteratorTest
- */
-public class ResultSetIteratorTest extends BaseTestCase {
-
- public void testNext() {
-
- Iterator<Object[]> iter = new ResultSetIterator(this.rs);
-
- Object[] row = null;
- assertTrue(iter.hasNext());
- row = iter.next();
- assertEquals(COLS, row.length);
- assertEquals("1", row[0]);
- assertEquals("2", row[1]);
- assertEquals("3", row[2]);
-
- assertTrue(iter.hasNext());
- row = iter.next();
- assertEquals(COLS, row.length);
-
- assertEquals("4", row[0]);
- assertEquals("5", row[1]);
- assertEquals("6", row[2]);
-
- assertFalse(iter.hasNext());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/test/java/org/apache/commons/dbutils/TestBean.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils/TestBean.java b/src/test/java/org/apache/commons/dbutils/TestBean.java
deleted file mode 100644
index 0b6156d..0000000
--- a/src/test/java/org/apache/commons/dbutils/TestBean.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.dbutils;
-
-/**
- * A bean to use in testing toBean() and toBeanList().
- */
-public class TestBean {
-
- private String one = null;
-
- private String two = null;
-
- private String three = null;
-
- private int intTest = 0;
-
- private Integer integerTest = Integer.valueOf(0);
-
- private String doNotSet = "not set";
-
- /**
- * toBean() should set primitive fields to their defaults (ie. 0) when
- * null is returned from the ResultSet.
- */
- private int nullPrimitiveTest = 7;
-
- /**
- * toBean() should set Object fields to null when null is returned from the
- * ResultSet
- */
- private Object nullObjectTest = "overwrite";
-
- /**
- * A Date will be returned from the ResultSet but the property is a String.
- * BeanProcessor should create a String from the Date and set this property.
- */
- private String notDate = "not a date";
-
- /**
- * The ResultSet will have a BigDecimal in this column and the
- * BasicColumnProcessor should convert that to a double and store the value
- * in this property.
- */
- private double columnProcessorDoubleTest = -1;
-
- /**
- * Constructor for TestBean.
- */
- public TestBean() {
- super();
- }
-
- public String getOne() {
- return one;
- }
-
- public String getThree() {
- return three;
- }
-
- public String getTwo() {
- return two;
- }
-
- public void setOne(String string) {
- one = string;
- }
-
- public void setThree(String string) {
- three = string;
- }
-
- public void setTwo(String string) {
- two = string;
- }
-
- public String getDoNotSet() {
- return doNotSet;
- }
-
- public void setDoNotSet(String string) {
- doNotSet = string;
- }
-
- public Integer getIntegerTest() {
- return integerTest;
- }
-
- public int getIntTest() {
- return intTest;
- }
-
- public void setIntegerTest(Integer integer) {
- integerTest = integer;
- }
-
- public void setIntTest(int i) {
- intTest = i;
- }
-
- public Object getNullObjectTest() {
- return nullObjectTest;
- }
-
- public int getNullPrimitiveTest() {
- return nullPrimitiveTest;
- }
-
- public void setNullObjectTest(Object object) {
- nullObjectTest = object;
- }
-
- public void setNullPrimitiveTest(int i) {
- nullPrimitiveTest = i;
- }
-
- public String getNotDate() {
- return notDate;
- }
-
- public void setNotDate(String string) {
- notDate = string;
- }
-
- public double getColumnProcessorDoubleTest() {
- return columnProcessorDoubleTest;
- }
-
- public void setColumnProcessorDoubleTest(double d) {
- columnProcessorDoubleTest = d;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/test/java/org/apache/commons/dbutils/UpdateExecutorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils/UpdateExecutorTest.java b/src/test/java/org/apache/commons/dbutils/UpdateExecutorTest.java
deleted file mode 100644
index 1b2cebf..0000000
--- a/src/test/java/org/apache/commons/dbutils/UpdateExecutorTest.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.dbutils;
-
-import static org.junit.Assert.*;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.SQLException;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-
-
-public class UpdateExecutorTest {
-
- private UpdateExecutor executor;
-
- @Mock private Connection conn;
- @Mock private PreparedStatement stmt;
-
- @Before
- public void setup() throws SQLException {
- MockitoAnnotations.initMocks(this);
-
- when(conn.prepareStatement(any(String.class))).thenReturn(stmt);
- when(stmt.executeUpdate()).thenReturn(20);
- }
-
- protected void createExecutor(String sql) throws Exception {
- executor = new UpdateExecutor(conn, sql, true);
- }
-
- @Test
- public void testGoodSQL() throws Exception {
- createExecutor("insert into blah");
-
- int ret = executor.execute();
-
- assertEquals(20, ret);
- verify(conn, times(1)).close();
- verify(stmt, times(1)).close();
- }
-
- @Test(expected=SQLException.class)
- public void testUnmappedParams() throws Exception {
- createExecutor("insert into blah (:something)");
-
- int ret = executor.execute();
-
- assertEquals(20, ret);
- verify(conn, times(1)).close();
- verify(stmt, times(1)).close();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/test/java/org/apache/commons/dbutils/handlers/ArrayHandlerTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils/handlers/ArrayHandlerTest.java b/src/test/java/org/apache/commons/dbutils/handlers/ArrayHandlerTest.java
deleted file mode 100644
index 7c5a829..0000000
--- a/src/test/java/org/apache/commons/dbutils/handlers/ArrayHandlerTest.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.dbutils.handlers;
-
-import java.sql.SQLException;
-
-import org.apache.commons.dbutils.BaseTestCase;
-import org.apache.commons.dbutils.ResultSetHandler;
-
-/**
- * ArrayHandlerTest
- */
-public class ArrayHandlerTest extends BaseTestCase {
-
- public void testHandle() throws SQLException {
- ResultSetHandler<Object[]> h = new ArrayHandler();
- Object[] results = h.handle(this.rs);
-
- assertNotNull(results);
- assertEquals(COLS, results.length);
- assertEquals("1", results[0]);
- assertEquals("2", results[1]);
- assertEquals("3", results[2]);
- }
-
- public void testEmptyResultSetHandle() throws SQLException {
- ResultSetHandler<Object[]> h = new ArrayHandler();
- Object[] results = h.handle(this.emptyResultSet);
-
- assertNull(results);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/test/java/org/apache/commons/dbutils/handlers/ArrayListHandlerTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils/handlers/ArrayListHandlerTest.java b/src/test/java/org/apache/commons/dbutils/handlers/ArrayListHandlerTest.java
deleted file mode 100644
index ea66215..0000000
--- a/src/test/java/org/apache/commons/dbutils/handlers/ArrayListHandlerTest.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.dbutils.handlers;
-
-import java.sql.SQLException;
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.commons.dbutils.BaseTestCase;
-import org.apache.commons.dbutils.ResultSetHandler;
-
-/**
- * ArrayListHandlerTest
- */
-public class ArrayListHandlerTest extends BaseTestCase {
-
- public void testHandle() throws SQLException {
- ResultSetHandler<List<Object[]>> h = new ArrayListHandler();
- List<Object[]> results = h.handle(this.rs);
-
- assertNotNull(results);
- assertEquals(ROWS, results.size());
-
- Iterator<Object[]> iter = results.iterator();
- Object[] row = null;
- assertTrue(iter.hasNext());
- row = iter.next();
- assertEquals(COLS, row.length);
- assertEquals("1", row[0]);
- assertEquals("2", row[1]);
- assertEquals("3", row[2]);
-
- assertTrue(iter.hasNext());
- row = iter.next();
- assertEquals(COLS, row.length);
-
- assertEquals("4", row[0]);
- assertEquals("5", row[1]);
- assertEquals("6", row[2]);
-
- assertFalse(iter.hasNext());
- }
-
- public void testEmptyResultSetHandle() throws SQLException {
- ResultSetHandler<List<Object[]>> h = new ArrayListHandler();
- List<Object[]> results = h.handle(this.emptyResultSet);
-
- assertNotNull(results);
- assertTrue(results.isEmpty());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/test/java/org/apache/commons/dbutils/handlers/BeanHandlerTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils/handlers/BeanHandlerTest.java b/src/test/java/org/apache/commons/dbutils/handlers/BeanHandlerTest.java
deleted file mode 100644
index 6c4d6a0..0000000
--- a/src/test/java/org/apache/commons/dbutils/handlers/BeanHandlerTest.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.dbutils.handlers;
-
-import java.sql.SQLException;
-
-import org.apache.commons.dbutils.BaseTestCase;
-import org.apache.commons.dbutils.ResultSetHandler;
-import org.apache.commons.dbutils.TestBean;
-
-/**
- * BeanHandlerTest
- */
-public class BeanHandlerTest extends BaseTestCase {
-
- public void testHandle() throws SQLException {
- ResultSetHandler<TestBean> h = new BeanHandler<TestBean>(TestBean.class);
- TestBean results = h.handle(this.rs);
-
- assertNotNull(results);
- assertEquals("1", results.getOne());
- assertEquals("2", results.getTwo());
- assertEquals("3", results.getThree());
- assertEquals("not set", results.getDoNotSet());
- }
-
- public void testEmptyResultSetHandle() throws SQLException {
- ResultSetHandler<TestBean> h = new BeanHandler<TestBean>(TestBean.class);
- TestBean results = h.handle(this.emptyResultSet);
-
- assertNull(results);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/test/java/org/apache/commons/dbutils/handlers/BeanListHandlerTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils/handlers/BeanListHandlerTest.java b/src/test/java/org/apache/commons/dbutils/handlers/BeanListHandlerTest.java
deleted file mode 100644
index 8157e93..0000000
--- a/src/test/java/org/apache/commons/dbutils/handlers/BeanListHandlerTest.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.dbutils.handlers;
-
-import java.sql.SQLException;
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.commons.dbutils.BaseTestCase;
-import org.apache.commons.dbutils.ResultSetHandler;
-import org.apache.commons.dbutils.TestBean;
-
-/**
- * BeanListHandlerTest
- */
-public class BeanListHandlerTest extends BaseTestCase {
-
- public void testHandle() throws SQLException {
- ResultSetHandler<List<TestBean>> h = new BeanListHandler<TestBean>(TestBean.class);
- List<TestBean> results = h.handle(this.rs);
-
- assertNotNull(results);
- assertEquals(ROWS, results.size());
-
- Iterator<TestBean> iter = results.iterator();
- TestBean row = null;
- assertTrue(iter.hasNext());
- row = iter.next();
- assertEquals("1", row.getOne());
- assertEquals("2", row.getTwo());
- assertEquals("3", row.getThree());
- assertEquals("not set", row.getDoNotSet());
-
- assertTrue(iter.hasNext());
- row = iter.next();
-
- assertEquals("4", row.getOne());
- assertEquals("5", row.getTwo());
- assertEquals("6", row.getThree());
- assertEquals("not set", row.getDoNotSet());
-
- assertFalse(iter.hasNext());
- }
-
- public void testEmptyResultSetHandle() throws SQLException {
- ResultSetHandler<List<TestBean>> h = new BeanListHandler<TestBean>(TestBean.class);
- List<TestBean> results = h.handle(this.emptyResultSet);
-
- assertNotNull(results);
- assertTrue(results.isEmpty());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/test/java/org/apache/commons/dbutils/handlers/BeanMapHandlerTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils/handlers/BeanMapHandlerTest.java b/src/test/java/org/apache/commons/dbutils/handlers/BeanMapHandlerTest.java
deleted file mode 100644
index 09ae157..0000000
--- a/src/test/java/org/apache/commons/dbutils/handlers/BeanMapHandlerTest.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.dbutils.handlers;
-
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.when;
-
-import java.sql.ResultSet;
-import java.sql.ResultSetMetaData;
-import java.util.Map;
-
-import org.apache.commons.dbutils.RowProcessor;
-import org.apache.commons.dbutils.TestBean;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-
-public class BeanMapHandlerTest {
-
- private BeanMapHandler<Long, TestBean> bmh;
- private Map<Long, TestBean> res;
- @Mock private ResultSet rs;
- @Mock private ResultSetMetaData rsmd;
- @Mock private RowProcessor rp;
-
- @Before
- public void setUp() throws Exception {
- MockitoAnnotations.initMocks(this);
-
- when(Boolean.valueOf(rs.next())).thenReturn(Boolean.TRUE, Boolean.FALSE);
- when(rs.getObject(1)).thenReturn(Long.valueOf(23L));
- when(rs.getObject(2)).thenReturn(Long.valueOf(23L));
- when(rs.getObject("id")).thenReturn(Long.valueOf(23L));
- when(rs.getMetaData()).thenReturn(rsmd);
- when(rp.toBean(rs, TestBean.class)).thenReturn(new TestBean());
- }
-
- private void handle() throws Exception {
- res = bmh.handle(rs);
- assertNotNull(res.get(Long.valueOf(23L)));
- }
-
- @Test
- public void testBeanMapHandlerClassOfV() throws Exception {
- bmh = new BeanMapHandler<Long, TestBean>(TestBean.class);
- handle();
- }
-
- @Test
- public void testBeanMapHandlerClassOfVRowProcessor() throws Exception {
- bmh = new BeanMapHandler<Long, TestBean>(TestBean.class, rp);
- handle();
- }
-
- @Test
- public void testBeanMapHandlerClassOfVInt() throws Exception {
- bmh = new BeanMapHandler<Long, TestBean>(TestBean.class, 2);
- handle();
- }
-
- @Test
- public void testBeanMapHandlerClassOfVString() throws Exception {
- bmh = new BeanMapHandler<Long, TestBean>(TestBean.class, "id");
- handle();
- }
-
- @Test
- public void testEmptyResultSet() throws Exception {
- when(Boolean.valueOf(rs.next())).thenReturn(Boolean.FALSE);
- bmh = new BeanMapHandler<Long, TestBean>(TestBean.class);
- res = bmh.handle(rs);
- assertNull(res.get(Long.valueOf(23L)));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/test/java/org/apache/commons/dbutils/handlers/ColumnListHandlerTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils/handlers/ColumnListHandlerTest.java b/src/test/java/org/apache/commons/dbutils/handlers/ColumnListHandlerTest.java
deleted file mode 100644
index 141d2a6..0000000
--- a/src/test/java/org/apache/commons/dbutils/handlers/ColumnListHandlerTest.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.dbutils.handlers;
-
-import java.sql.SQLException;
-import java.util.List;
-
-import org.apache.commons.dbutils.BaseTestCase;
-import org.apache.commons.dbutils.ResultSetHandler;
-
-/**
- * ColumnListHandlerTest
- */
-public class ColumnListHandlerTest extends BaseTestCase {
-
- public void testHandle() throws SQLException {
- ResultSetHandler<List<String>> h = new ColumnListHandler<String>();
- List<String> results = h.handle(this.rs);
-
- assertNotNull(results);
- assertEquals(ROWS, results.size());
-
- assertEquals("1", results.get(0));
- assertEquals("4", results.get(1));
- }
-
- public void testColumnIndexHandle() throws SQLException {
- ResultSetHandler<List<String>> h = new ColumnListHandler<String>(2);
- List<String> results = h.handle(this.rs);
-
- assertNotNull(results);
- assertEquals(ROWS, results.size());
-
- assertEquals("2", results.get(0));
- assertEquals("5", results.get(1));
- }
-
- public void testColumnNameHandle() throws SQLException {
- ResultSetHandler<List<Integer>> h = new ColumnListHandler<Integer>("intTest");
- List<Integer> results = h.handle(this.rs);
-
- assertNotNull(results);
- assertEquals(ROWS, results.size());
-
- assertEquals(new Integer(1), results.get(0));
- assertEquals(new Integer(3), results.get(1));
- }
-
- public void testEmptyResultSetHandle() throws SQLException {
- ResultSetHandler<List<String>> h = new ColumnListHandler<String>();
- List<String> results = h.handle(this.emptyResultSet);
-
- assertNotNull(results);
- assertTrue(results.isEmpty());
- }
-
-}
[11/58] [abbrv] commons-dbutils git commit: Fixed a number of
FindBugs and Checkstyle issues
Posted by th...@apache.org.
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/3535b10b/src/main/java/org/apache/commons/dbutils2/BatchExecutor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/BatchExecutor.java b/src/main/java/org/apache/commons/dbutils2/BatchExecutor.java
index cb1773e..934c00b 100644
--- a/src/main/java/org/apache/commons/dbutils2/BatchExecutor.java
+++ b/src/main/java/org/apache/commons/dbutils2/BatchExecutor.java
@@ -22,23 +22,30 @@ import java.sql.Types;
/**
* This class provides the ability to execute a batch of statements.
- *
+ *
* It is really just a facade to an array of UpdateExecutors.
- *
+ *
+ * @since 2.0
* @author William Speirs <ws...@apache.org>
*/
public class BatchExecutor extends AbstractExecutor<BatchExecutor> {
private final boolean closeConn;
-
- public BatchExecutor(final Connection conn, final String sql, final boolean closeConnection) throws SQLException {
+
+ /**
+ * Constructs a BatchExecutor given a connection and SQL statement.
+ * @param conn The connection to use during execution.
+ * @param sql The SQL statement.
+ * @param closeConnection If the connection should be closed or not.
+ * @throws SQLException thrown if there is an error during execution.
+ */
+ BatchExecutor(final Connection conn, final String sql, final boolean closeConnection) throws SQLException {
super(conn, sql);
this.closeConn = closeConnection;
}
-
+
/**
* Binds a parameter name to a value for a given statement.
- * @param statement the statement number to operate on.
* @param name the name of the parameter.
* @param value the value to bind to the parameter.
* @return this object.
@@ -49,7 +56,7 @@ public class BatchExecutor extends AbstractExecutor<BatchExecutor> {
public BatchExecutor bind(final String name, final Object value) throws SQLException {
return bind(name, value, false);
}
-
+
/**
* Binds null to a parameter.
* Types.VARCHAR is used as the type's parameter.
@@ -62,7 +69,7 @@ public class BatchExecutor extends AbstractExecutor<BatchExecutor> {
public BatchExecutor bindNull(final String name) throws SQLException {
return bindNull(name, Types.VARCHAR, false);
}
-
+
/**
* Binds null to a parameter, specifying the parameter's type.
* @param name the name of the parameter.
@@ -74,7 +81,7 @@ public class BatchExecutor extends AbstractExecutor<BatchExecutor> {
public BatchExecutor bindNull(final String name, final int sqlType) throws SQLException {
return bindNull(name, sqlType, false);
}
-
+
/**
* Adds the statement to the batch after binding all of the parameters.
* @return this object.
@@ -85,10 +92,10 @@ public class BatchExecutor extends AbstractExecutor<BatchExecutor> {
try {
getStatement().addBatch();
clearValueMap();
- } catch(SQLException e) {
+ } catch (SQLException e) {
rethrow(e);
}
-
+
return this;
}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/3535b10b/src/main/java/org/apache/commons/dbutils2/DbUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/DbUtils.java b/src/main/java/org/apache/commons/dbutils2/DbUtils.java
index 5968d4e..515392f 100644
--- a/src/main/java/org/apache/commons/dbutils2/DbUtils.java
+++ b/src/main/java/org/apache/commons/dbutils2/DbUtils.java
@@ -17,8 +17,10 @@
package org.apache.commons.dbutils2;
import static java.sql.DriverManager.registerDriver;
+
import java.io.PrintWriter;
import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
import java.sql.Connection;
import java.sql.Driver;
import java.sql.DriverPropertyInfo;
@@ -216,14 +218,27 @@ public final class DbUtils {
try {
Driver driver = driverConstructor.newInstance();
registerDriver(new DriverProxy(driver));
+ } catch (SQLException e) {
+ return false;
+ } catch (InstantiationException e) {
+ return false;
+ } catch (IllegalAccessException e) {
+ return false;
+ } catch (IllegalArgumentException e) {
+ return false;
+ } catch (InvocationTargetException e) {
+ return false;
} finally {
driverConstructor.setAccessible(isConstructorAccessible);
}
return true;
- } catch (Exception e) {
+ } catch (ClassNotFoundException e) {
+ return false;
+ } catch (NoSuchMethodException e) {
+ return false;
+ } catch (SecurityException e) {
return false;
-
}
}
@@ -396,7 +411,6 @@ public final class DbUtils {
/**
* Java 1.7 method.
*/
- @SuppressWarnings("unused")
public Logger getParentLogger() throws SQLFeatureNotSupportedException {
throw new SQLFeatureNotSupportedException();
}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/3535b10b/src/main/java/org/apache/commons/dbutils2/GenerousBeanProcessor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/GenerousBeanProcessor.java b/src/main/java/org/apache/commons/dbutils2/GenerousBeanProcessor.java
index b85b66e..0904da8 100644
--- a/src/main/java/org/apache/commons/dbutils2/GenerousBeanProcessor.java
+++ b/src/main/java/org/apache/commons/dbutils2/GenerousBeanProcessor.java
@@ -28,17 +28,17 @@ import java.util.Arrays;
* columns to Java Bean properties.
*/
public class GenerousBeanProcessor extends BeanProcessor {
-
+
/**
* Default constructor.
*/
public GenerousBeanProcessor() {
super();
}
-
+
@Override
protected int[] mapColumnsToProperties(final ResultSetMetaData rsmd,
- final PropertyDescriptor[] props) throws SQLException {
+ final PropertyDescriptor[] props) throws SQLException {
final int cols = rsmd.getColumnCount();
final int[] columnToProperty = new int[cols + 1];
@@ -46,19 +46,19 @@ public class GenerousBeanProcessor extends BeanProcessor {
for (int col = 1; col <= cols; col++) {
String columnName = rsmd.getColumnLabel(col);
-
+
if (null == columnName || 0 == columnName.length()) {
columnName = rsmd.getColumnName(col);
}
-
- final String generousColumnName = columnName.replace("_","");
+
+ final String generousColumnName = columnName.replace("_", "");
for (int i = 0; i < props.length; i++) {
final String propName = props[i].getName();
-
+
// see if either the column name, or the generous one matches
if (columnName.equalsIgnoreCase(propName) ||
- generousColumnName.equalsIgnoreCase(propName)) {
+ generousColumnName.equalsIgnoreCase(propName)) {
columnToProperty[col] = i;
break;
}
@@ -67,5 +67,5 @@ public class GenerousBeanProcessor extends BeanProcessor {
return columnToProperty;
}
-
+
}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/3535b10b/src/main/java/org/apache/commons/dbutils2/InsertExecutor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/InsertExecutor.java b/src/main/java/org/apache/commons/dbutils2/InsertExecutor.java
index 39a6db6..9b5cecb 100644
--- a/src/main/java/org/apache/commons/dbutils2/InsertExecutor.java
+++ b/src/main/java/org/apache/commons/dbutils2/InsertExecutor.java
@@ -21,18 +21,32 @@ import java.sql.ResultSet;
import java.sql.SQLException;
+/**
+ * Fluent class for executing inserts.
+ *
+ * @since 2.0
+ * @author William Speirs <ws...@apache.org>
+ */
public class InsertExecutor extends AbstractExecutor<InsertExecutor> {
private final boolean closeConn;
- public InsertExecutor(final Connection conn, final String sql, final boolean closeConnection) throws SQLException {
+ /**
+ * Constructs an InsertExecutor given a connection and SQL statement.
+ * @param conn The connection to use during execution.
+ * @param sql The SQL statement.
+ * @param closeConnection If the connection should be closed or not.
+ * @throws SQLException thrown if there is an error during execution.
+ */
+ InsertExecutor(final Connection conn, final String sql, final boolean closeConnection) throws SQLException {
super(conn, sql);
this.closeConn = closeConnection;
}
/**
* Executes the given INSERT SQL statement.
- *
+ *
+ * @param <T> the type returned by the ResultSetHandler.
* @param handler The handler used to create the result object from
* the <code>ResultSet</code> of auto-generated keys.
*
@@ -54,10 +68,10 @@ public class InsertExecutor extends AbstractExecutor<InsertExecutor> {
try {
// execute the update
getStatement().executeUpdate();
-
+
// get the result set
final ResultSet resultSet = getStatement().getGeneratedKeys();
-
+
// run the handler over the results and return them
return handler.handle(resultSet);
} catch (SQLException e) {
@@ -72,7 +86,7 @@ public class InsertExecutor extends AbstractExecutor<InsertExecutor> {
// we get here only if something is thrown
return null;
}
-
+
/**
* Executes the given INSERT SQL statement.
* @return the number of rows updated.
@@ -93,8 +107,8 @@ public class InsertExecutor extends AbstractExecutor<InsertExecutor> {
close(getConnection());
}
}
-
+
return 0; // only get here on an error
}
-
+
}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/3535b10b/src/main/java/org/apache/commons/dbutils2/QueryExecutor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/QueryExecutor.java b/src/main/java/org/apache/commons/dbutils2/QueryExecutor.java
index 4a7c317..de55919 100644
--- a/src/main/java/org/apache/commons/dbutils2/QueryExecutor.java
+++ b/src/main/java/org/apache/commons/dbutils2/QueryExecutor.java
@@ -22,15 +22,22 @@ import java.sql.SQLException;
/**
* Fluent class for executing a query.
- *
+ *
* @since 2.0
* @author William Speirs <ws...@apache.org>
*/
class QueryExecutor extends AbstractExecutor<QueryExecutor> {
-
+
private final boolean closeConn;
- public QueryExecutor(final Connection conn, final String sql, final boolean closeConnection) throws SQLException {
+ /**
+ * Constructs a QueryExecutor given a connection and SQL statement.
+ * @param conn The connection to use during execution.
+ * @param sql The SQL statement.
+ * @param closeConnection If the connection should be closed or not.
+ * @throws SQLException thrown if there is an error during execution.
+ */
+ QueryExecutor(final Connection conn, final String sql, final boolean closeConnection) throws SQLException {
super(conn, sql);
this.closeConn = closeConnection;
}
@@ -46,7 +53,7 @@ class QueryExecutor extends AbstractExecutor<QueryExecutor> {
public <T> T execute(ResultSetHandler<T> handler) throws SQLException {
// throw an exception if there are unmapped parameters
this.throwIfUnmappedParams();
-
+
// make sure our handler is not null
if (handler == null) {
if (closeConn) {
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/3535b10b/src/main/java/org/apache/commons/dbutils2/QueryRunner.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/QueryRunner.java b/src/main/java/org/apache/commons/dbutils2/QueryRunner.java
index 9dbc292..eecb252 100644
--- a/src/main/java/org/apache/commons/dbutils2/QueryRunner.java
+++ b/src/main/java/org/apache/commons/dbutils2/QueryRunner.java
@@ -50,7 +50,7 @@ public class QueryRunner {
public QueryRunner(final DataSource ds) {
this.ds = ds;
}
-
+
/**
* Returns the <code>DataSource</code> this runner is using.
* <code>QueryRunner</code> methods always call this method to get the
@@ -76,7 +76,7 @@ public class QueryRunner {
if (this.getDataSource() == null) {
throw new SQLException(
"QueryRunner requires a DataSource to be "
- + "invoked in this way, or a Connection should be passed in");
+ + "invoked in this way, or a Connection should be passed in");
}
return this.getDataSource().getConnection();
}
@@ -98,10 +98,10 @@ public class QueryRunner {
* <code>Connection</code> is retrieved from the <code>DataSource</code>
* set in the constructor. This <code>Connection</code> must be in
* auto-commit mode or the insert will not be saved. The <code>Connection</code> is
- * closed after the call.
- *
+ * closed after the call.
+ *
* @param sql The SQL statement to execute.
- *
+ *
* @return An {@link org.apache.commons.dbutils2.BatchExecutor} for this SQL statement.
* @throws SQLException If there are database or parameter errors.
*/
@@ -115,7 +115,7 @@ public class QueryRunner {
*
* @param conn The connection to use for the batch call.
* @param sql The SQL statement to execute.
- *
+ *
* @return An {@link org.apache.commons.dbutils2.BatchExecutor} for this SQL statement.
* @throws SQLException If there are database or parameter errors.
*/
@@ -125,11 +125,11 @@ public class QueryRunner {
/**
* Creates an {@link org.apache.commons.dbutils2.BatchExecutor} for the given SQL statement and connection.
- *
+ *
* @param conn The connection to use for the batch call.
* @param closeConn True if the connection should be closed, false otherwise.
* @param sql The SQL statement to execute.
- *
+ *
* @return An {@link org.apache.commons.dbutils2.BatchExecutor} for this SQL statement.
* @throws SQLException If there are database or parameter errors.
*/
@@ -144,7 +144,7 @@ public class QueryRunner {
}
throw new SQLException("Null SQL statement");
}
-
+
return new BatchExecutor(conn, sql, closeConn);
}
@@ -153,10 +153,10 @@ public class QueryRunner {
* <code>Connection</code> is retrieved from the <code>DataSource</code>
* set in the constructor. This <code>Connection</code> must be in
* auto-commit mode or the insert will not be saved. The <code>Connection</code> is
- * closed after the call.
- *
+ * closed after the call.
+ *
* @param sql The SQL statement to execute.
- *
+ *
* @return An {@link org.apache.commons.dbutils2.QueryExecutor} for this SQL statement.
* @throws SQLException If there are database or parameter errors.
*/
@@ -167,10 +167,10 @@ public class QueryRunner {
/**
* Creates an {@link org.apache.commons.dbutils2.QueryExecutor} for the given SQL statement and connection.
* The connection is <b>NOT</b> closed after execution.
- *
+ *
* @param conn The connection to use for the update call.
* @param sql The SQL statement to execute.
- *
+ *
* @return An {@link org.apache.commons.dbutils2.QueryExecutor} for this SQL statement.
* @throws SQLException If there are database or parameter errors.
*/
@@ -180,11 +180,11 @@ public class QueryRunner {
/**
* Creates an {@link org.apache.commons.dbutils2.QueryExecutor} for the given SQL statement and connection.
- *
+ *
* @param conn The connection to use for the query call.
* @param closeConn True if the connection should be closed, false otherwise.
* @param sql The SQL statement to execute.
- *
+ *
* @return An {@link org.apache.commons.dbutils2.QueryExecutor} for this SQL statement.
* @throws SQLException If there are database or parameter errors.
*/
@@ -199,7 +199,7 @@ public class QueryRunner {
}
throw new SQLException("Null SQL statement");
}
-
+
return new QueryExecutor(conn, sql, closeConn);
}
@@ -208,10 +208,10 @@ public class QueryRunner {
* <code>Connection</code> is retrieved from the <code>DataSource</code>
* set in the constructor. This <code>Connection</code> must be in
* auto-commit mode or the insert will not be saved. The <code>Connection</code> is
- * closed after the call.
+ * closed after the call.
*
* @param sql The SQL statement to execute.
- *
+ *
* @return An {@link org.apache.commons.dbutils2.UpdateExecutor} for this SQL statement.
* @throws SQLException if a database access error occurs
*/
@@ -222,10 +222,10 @@ public class QueryRunner {
/**
* Creates an {@link org.apache.commons.dbutils2.UpdateExecutor} for the given SQL statement and connection.
* The connection is <b>NOT</b> closed after execution.
- *
+ *
* @param conn The connection to use for the update call.
* @param sql The SQL statement to execute.
- *
+ *
* @return An {@link org.apache.commons.dbutils2.UpdateExecutor} for this SQL statement.
* @throws SQLException If there are database or parameter errors.
*/
@@ -235,11 +235,11 @@ public class QueryRunner {
/**
* Creates an {@link org.apache.commons.dbutils2.UpdateExecutor} for the given SQL statement and connection.
- *
+ *
* @param conn The connection to use for the update call.
* @param closeConn True if the connection should be closed, false otherwise.
* @param sql The SQL statement to execute.
- *
+ *
* @return An {@link org.apache.commons.dbutils2.UpdateExecutor} for this SQL statement.
* @throws SQLException If there are database or parameter errors.
*/
@@ -263,8 +263,8 @@ public class QueryRunner {
* <code>Connection</code> is retrieved from the <code>DataSource</code>
* set in the constructor. This <code>Connection</code> must be in
* auto-commit mode or the insert will not be saved. The <code>Connection</code> is
- * closed after the call.
- *
+ * closed after the call.
+ *
* @param sql The SQL statement to execute.
*
* @return An {@link org.apache.commons.dbutils2.InsertExecutor} for this SQL statement.
@@ -277,7 +277,7 @@ public class QueryRunner {
/**
* Creates an {@link org.apache.commons.dbutils2.InsertExecutor} for the given SQL and connection
* The connection is <b>NOT</b> closed after execution.
- *
+ *
* @param conn The connection to use for the query call.
* @param sql The SQL statement to execute.
*
@@ -290,7 +290,7 @@ public class QueryRunner {
/**
* Creates an {@link org.apache.commons.dbutils2.InsertExecutor} for the given SQL and connection.
- *
+ *
* @param conn The connection to use for the insert call.
* @param closeConn True if the connection should be closed, false otherwise.
* @param sql The SQL statement to execute.
@@ -309,7 +309,7 @@ public class QueryRunner {
}
throw new SQLException("Null SQL statement");
}
-
+
return new InsertExecutor(conn, sql, closeConn);
}
}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/3535b10b/src/main/java/org/apache/commons/dbutils2/UpdateExecutor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/UpdateExecutor.java b/src/main/java/org/apache/commons/dbutils2/UpdateExecutor.java
index 590f069..882aa65 100644
--- a/src/main/java/org/apache/commons/dbutils2/UpdateExecutor.java
+++ b/src/main/java/org/apache/commons/dbutils2/UpdateExecutor.java
@@ -19,12 +19,24 @@ package org.apache.commons.dbutils2;
import java.sql.Connection;
import java.sql.SQLException;
-
+/**
+ * Fluent class for executing updates.
+ *
+ * @since 2.0
+ * @author William Speirs <ws...@apache.org>
+ */
public class UpdateExecutor extends AbstractExecutor<UpdateExecutor> {
private final boolean closeConn;
-
- public UpdateExecutor(final Connection conn, final String sql, final boolean closeConnection) throws SQLException {
+
+ /**
+ * Constructs an UpdateExecutor given a connection and SQL statement.
+ * @param conn The connection to use during execution.
+ * @param sql The SQL statement.
+ * @param closeConnection If the connection should be closed or not.
+ * @throws SQLException thrown if there is an error during execution.
+ */
+ UpdateExecutor(final Connection conn, final String sql, final boolean closeConnection) throws SQLException {
super(conn, sql);
this.closeConn = closeConnection;
}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/3535b10b/src/main/java/org/apache/commons/dbutils2/handlers/KeyedHandler.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/handlers/KeyedHandler.java b/src/main/java/org/apache/commons/dbutils2/handlers/KeyedHandler.java
index f7fe89a..245d2e7 100644
--- a/src/main/java/org/apache/commons/dbutils2/handlers/KeyedHandler.java
+++ b/src/main/java/org/apache/commons/dbutils2/handlers/KeyedHandler.java
@@ -55,18 +55,18 @@ public class KeyedHandler<K> extends AbstractKeyedHandler<K, Map<String, Object>
* The RowProcessor implementation to use when converting rows
* into Objects.
*/
- protected final RowProcessor convert;
+ private final RowProcessor convert;
/**
* The column index to retrieve key values from. Defaults to 1.
*/
- protected final int columnIndex;
+ private final int columnIndex;
/**
* The column name to retrieve key values from. Either columnName or
* columnIndex will be used but never both.
*/
- protected final String columnName;
+ private final String columnName;
/**
* Creates a new instance of KeyedHandler. The value of the first column
@@ -139,8 +139,8 @@ public class KeyedHandler<K> extends AbstractKeyedHandler<K, Map<String, Object>
@Override
protected K createKey(ResultSet rs) throws SQLException {
return (columnName == null) ?
- (K) rs.getObject(columnIndex) :
- (K) rs.getObject(columnName);
+ (K) rs.getObject(columnIndex) :
+ (K) rs.getObject(columnName);
}
/**
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/3535b10b/src/main/java/org/apache/commons/dbutils2/wrappers/SqlNullCheckedResultSet.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/wrappers/SqlNullCheckedResultSet.java b/src/main/java/org/apache/commons/dbutils2/wrappers/SqlNullCheckedResultSet.java
index 7868e66..53e5a95 100644
--- a/src/main/java/org/apache/commons/dbutils2/wrappers/SqlNullCheckedResultSet.java
+++ b/src/main/java/org/apache/commons/dbutils2/wrappers/SqlNullCheckedResultSet.java
@@ -253,7 +253,7 @@ public class SqlNullCheckedResultSet implements InvocationHandler {
* @return the value
*/
public Date getNullDate() {
- return this.nullDate;
+ return new Date(this.nullDate.getTime());
}
/**
@@ -353,7 +353,7 @@ public class SqlNullCheckedResultSet implements InvocationHandler {
* @return the value
*/
public Timestamp getNullTimestamp() {
- return this.nullTimestamp;
+ return new Timestamp(this.nullTimestamp.getTime());
}
/**
@@ -380,7 +380,7 @@ public class SqlNullCheckedResultSet implements InvocationHandler {
*/
@Override
public Object invoke(Object proxy, Method method, Object[] args)
- throws Throwable {
+ throws Throwable {
Object result = method.invoke(this.rs, args);
@@ -389,8 +389,8 @@ public class SqlNullCheckedResultSet implements InvocationHandler {
// Check nullMethod != null first so that we don't call wasNull()
// before a true getter method was invoked on the ResultSet.
return (nullMethod != null && this.rs.wasNull())
- ? nullMethod.invoke(this, (Object[]) null)
- : result;
+ ? nullMethod.invoke(this, (Object[]) null)
+ : result;
}
/**
@@ -492,7 +492,7 @@ public class SqlNullCheckedResultSet implements InvocationHandler {
* @param nullDate the value
*/
public void setNullDate(Date nullDate) {
- this.nullDate = nullDate;
+ this.nullDate = nullDate != null ? new Date(nullDate.getTime()) : null;
}
/**
@@ -592,7 +592,7 @@ public class SqlNullCheckedResultSet implements InvocationHandler {
* @param nullTimestamp the value
*/
public void setNullTimestamp(Timestamp nullTimestamp) {
- this.nullTimestamp = nullTimestamp;
+ this.nullTimestamp = nullTimestamp != null ? new Timestamp(nullTimestamp.getTime()) : null;
}
/**
[47/58] [abbrv] commons-dbutils git commit: Replaced fully qualified
class names in @link tags
Posted by th...@apache.org.
Replaced fully qualified class names in @link tags
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/dbutils/branches/2_0@1482104 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/commons-dbutils/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-dbutils/commit/d25102b9
Tree: http://git-wip-us.apache.org/repos/asf/commons-dbutils/tree/d25102b9
Diff: http://git-wip-us.apache.org/repos/asf/commons-dbutils/diff/d25102b9
Branch: refs/heads/2_0
Commit: d25102b904c9fc0327b3f707d7cde4b2cdf99304
Parents: 70b0158
Author: Emmanuel Bourg <eb...@apache.org>
Authored: Mon May 13 20:59:11 2013 +0000
Committer: Emmanuel Bourg <eb...@apache.org>
Committed: Mon May 13 20:59:11 2013 +0000
----------------------------------------------------------------------
.../apache/commons/dbutils2/AsyncExecutor.java | 10 ++--
.../apache/commons/dbutils2/QueryRunner.java | 48 ++++++++++----------
2 files changed, 29 insertions(+), 29 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/d25102b9/src/main/java/org/apache/commons/dbutils2/AsyncExecutor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/AsyncExecutor.java b/src/main/java/org/apache/commons/dbutils2/AsyncExecutor.java
index dcc58cf..d1ff22b 100644
--- a/src/main/java/org/apache/commons/dbutils2/AsyncExecutor.java
+++ b/src/main/java/org/apache/commons/dbutils2/AsyncExecutor.java
@@ -40,7 +40,7 @@ public class AsyncExecutor {
}
/**
- * Execute a {@link org.apache.commons.dbutils2.BatchExecutor}.
+ * Execute a {@link BatchExecutor}.
*
* @param executor The executor for this SQL statement.
* @return A <code>Future</code> which returns the result of the batch call.
@@ -58,7 +58,7 @@ public class AsyncExecutor {
}
/**
- * Execute a {@link org.apache.commons.dbutils2.QueryExecutor} given a handler.
+ * Execute a {@link QueryExecutor} given a handler.
*
* @param <T> The type of object that the handler returns
* @param executor The executor for this SQL statement.
@@ -78,7 +78,7 @@ public class AsyncExecutor {
}
/**
- * Execute a {@link org.apache.commons.dbutils2.UpdateExecutor}.
+ * Execute an {@link UpdateExecutor}.
*
* @param executor The executor for this SQL statement.
* @return A <code>Future</code> which returns the result of the query call.
@@ -96,7 +96,7 @@ public class AsyncExecutor {
}
/**
- * Execute a {@link org.apache.commons.dbutils2.InsertExecutor} given a handler.
+ * Execute an {@link InsertExecutor} given a handler.
*
* @param <T> The type of object that the handler returns
* @param executor The executor for this SQL statement.
@@ -116,7 +116,7 @@ public class AsyncExecutor {
}
/**
- * Execute a {@link org.apache.commons.dbutils2.InsertExecutor} given a handler.
+ * Execute an {@link InsertExecutor} given a handler.
*
* @param executor The executor for this SQL statement.
* @return A <code>Future</code> which returns the number of rows inserted.
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/d25102b9/src/main/java/org/apache/commons/dbutils2/QueryRunner.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/QueryRunner.java b/src/main/java/org/apache/commons/dbutils2/QueryRunner.java
index eecb252..2d5fe5c 100644
--- a/src/main/java/org/apache/commons/dbutils2/QueryRunner.java
+++ b/src/main/java/org/apache/commons/dbutils2/QueryRunner.java
@@ -94,7 +94,7 @@ public class QueryRunner {
}
/**
- * Creates an {@link org.apache.commons.dbutils2.BatchExecutor} for the given SQL.
+ * Creates an {@link BatchExecutor} for the given SQL.
* <code>Connection</code> is retrieved from the <code>DataSource</code>
* set in the constructor. This <code>Connection</code> must be in
* auto-commit mode or the insert will not be saved. The <code>Connection</code> is
@@ -102,7 +102,7 @@ public class QueryRunner {
*
* @param sql The SQL statement to execute.
*
- * @return An {@link org.apache.commons.dbutils2.BatchExecutor} for this SQL statement.
+ * @return An {@link BatchExecutor} for this SQL statement.
* @throws SQLException If there are database or parameter errors.
*/
public BatchExecutor batch(String sql) throws SQLException {
@@ -110,13 +110,13 @@ public class QueryRunner {
}
/**
- * Creates an {@link org.apache.commons.dbutils2.BatchExecutor} for the given SQL statement and connection.
+ * Creates an {@link BatchExecutor} for the given SQL statement and connection.
* The connection is <b>NOT</b> closed after execution.
*
* @param conn The connection to use for the batch call.
* @param sql The SQL statement to execute.
*
- * @return An {@link org.apache.commons.dbutils2.BatchExecutor} for this SQL statement.
+ * @return An {@link BatchExecutor} for this SQL statement.
* @throws SQLException If there are database or parameter errors.
*/
public BatchExecutor batch(Connection conn, String sql) throws SQLException {
@@ -124,13 +124,13 @@ public class QueryRunner {
}
/**
- * Creates an {@link org.apache.commons.dbutils2.BatchExecutor} for the given SQL statement and connection.
+ * Creates an {@link BatchExecutor} for the given SQL statement and connection.
*
* @param conn The connection to use for the batch call.
* @param closeConn True if the connection should be closed, false otherwise.
* @param sql The SQL statement to execute.
*
- * @return An {@link org.apache.commons.dbutils2.BatchExecutor} for this SQL statement.
+ * @return An {@link BatchExecutor} for this SQL statement.
* @throws SQLException If there are database or parameter errors.
*/
public BatchExecutor batch(Connection conn, boolean closeConn, String sql) throws SQLException {
@@ -149,7 +149,7 @@ public class QueryRunner {
}
/**
- * Creates an {@link org.apache.commons.dbutils2.QueryExecutor} for the given SQL.
+ * Creates an {@link QueryExecutor} for the given SQL.
* <code>Connection</code> is retrieved from the <code>DataSource</code>
* set in the constructor. This <code>Connection</code> must be in
* auto-commit mode or the insert will not be saved. The <code>Connection</code> is
@@ -157,7 +157,7 @@ public class QueryRunner {
*
* @param sql The SQL statement to execute.
*
- * @return An {@link org.apache.commons.dbutils2.QueryExecutor} for this SQL statement.
+ * @return A {@link QueryExecutor} for this SQL statement.
* @throws SQLException If there are database or parameter errors.
*/
public QueryExecutor query(String sql) throws SQLException {
@@ -165,13 +165,13 @@ public class QueryRunner {
}
/**
- * Creates an {@link org.apache.commons.dbutils2.QueryExecutor} for the given SQL statement and connection.
+ * Creates an {@link QueryExecutor} for the given SQL statement and connection.
* The connection is <b>NOT</b> closed after execution.
*
* @param conn The connection to use for the update call.
* @param sql The SQL statement to execute.
*
- * @return An {@link org.apache.commons.dbutils2.QueryExecutor} for this SQL statement.
+ * @return An {@link QueryExecutor} for this SQL statement.
* @throws SQLException If there are database or parameter errors.
*/
public QueryExecutor query(Connection conn, String sql) throws SQLException {
@@ -179,13 +179,13 @@ public class QueryRunner {
}
/**
- * Creates an {@link org.apache.commons.dbutils2.QueryExecutor} for the given SQL statement and connection.
+ * Creates an {@link QueryExecutor} for the given SQL statement and connection.
*
* @param conn The connection to use for the query call.
* @param closeConn True if the connection should be closed, false otherwise.
* @param sql The SQL statement to execute.
*
- * @return An {@link org.apache.commons.dbutils2.QueryExecutor} for this SQL statement.
+ * @return An {@link QueryExecutor} for this SQL statement.
* @throws SQLException If there are database or parameter errors.
*/
public QueryExecutor query(Connection conn, boolean closeConn, String sql) throws SQLException {
@@ -204,7 +204,7 @@ public class QueryRunner {
}
/**
- * Creates an {@link org.apache.commons.dbutils2.UpdateExecutor} for the given SQL.
+ * Creates an {@link UpdateExecutor} for the given SQL.
* <code>Connection</code> is retrieved from the <code>DataSource</code>
* set in the constructor. This <code>Connection</code> must be in
* auto-commit mode or the insert will not be saved. The <code>Connection</code> is
@@ -212,7 +212,7 @@ public class QueryRunner {
*
* @param sql The SQL statement to execute.
*
- * @return An {@link org.apache.commons.dbutils2.UpdateExecutor} for this SQL statement.
+ * @return An {@link UpdateExecutor} for this SQL statement.
* @throws SQLException if a database access error occurs
*/
public UpdateExecutor update(String sql) throws SQLException {
@@ -220,13 +220,13 @@ public class QueryRunner {
}
/**
- * Creates an {@link org.apache.commons.dbutils2.UpdateExecutor} for the given SQL statement and connection.
+ * Creates an {@link UpdateExecutor} for the given SQL statement and connection.
* The connection is <b>NOT</b> closed after execution.
*
* @param conn The connection to use for the update call.
* @param sql The SQL statement to execute.
*
- * @return An {@link org.apache.commons.dbutils2.UpdateExecutor} for this SQL statement.
+ * @return An {@link UpdateExecutor} for this SQL statement.
* @throws SQLException If there are database or parameter errors.
*/
public UpdateExecutor update(Connection conn, String sql) throws SQLException {
@@ -234,13 +234,13 @@ public class QueryRunner {
}
/**
- * Creates an {@link org.apache.commons.dbutils2.UpdateExecutor} for the given SQL statement and connection.
+ * Creates an {@link UpdateExecutor} for the given SQL statement and connection.
*
* @param conn The connection to use for the update call.
* @param closeConn True if the connection should be closed, false otherwise.
* @param sql The SQL statement to execute.
*
- * @return An {@link org.apache.commons.dbutils2.UpdateExecutor} for this SQL statement.
+ * @return An {@link UpdateExecutor} for this SQL statement.
* @throws SQLException If there are database or parameter errors.
*/
public UpdateExecutor update(Connection conn, boolean closeConn, String sql) throws SQLException {
@@ -259,7 +259,7 @@ public class QueryRunner {
}
/**
- * Creates an {@link org.apache.commons.dbutils2.InsertExecutor} for the given SQL.
+ * Creates an {@link InsertExecutor} for the given SQL.
* <code>Connection</code> is retrieved from the <code>DataSource</code>
* set in the constructor. This <code>Connection</code> must be in
* auto-commit mode or the insert will not be saved. The <code>Connection</code> is
@@ -267,7 +267,7 @@ public class QueryRunner {
*
* @param sql The SQL statement to execute.
*
- * @return An {@link org.apache.commons.dbutils2.InsertExecutor} for this SQL statement.
+ * @return An {@link InsertExecutor} for this SQL statement.
* @throws SQLException If there are database or parameter errors.
*/
public InsertExecutor insert(String sql) throws SQLException {
@@ -275,13 +275,13 @@ public class QueryRunner {
}
/**
- * Creates an {@link org.apache.commons.dbutils2.InsertExecutor} for the given SQL and connection
+ * Creates an {@link InsertExecutor} for the given SQL and connection
* The connection is <b>NOT</b> closed after execution.
*
* @param conn The connection to use for the query call.
* @param sql The SQL statement to execute.
*
- * @return An {@link org.apache.commons.dbutils2.InsertExecutor} for this SQL statement.
+ * @return An {@link InsertExecutor} for this SQL statement.
* @throws SQLException If there are database or parameter errors.
*/
public InsertExecutor insert(Connection conn, String sql) throws SQLException {
@@ -289,13 +289,13 @@ public class QueryRunner {
}
/**
- * Creates an {@link org.apache.commons.dbutils2.InsertExecutor} for the given SQL and connection.
+ * Creates an {@link InsertExecutor} for the given SQL and connection.
*
* @param conn The connection to use for the insert call.
* @param closeConn True if the connection should be closed, false otherwise.
* @param sql The SQL statement to execute.
*
- * @return An {@link org.apache.commons.dbutils2.InsertExecutor} for this SQL statement.
+ * @return An {@link InsertExecutor} for this SQL statement.
* @throws SQLException If there are database or parameter errors.
*/
public InsertExecutor insert(Connection conn, boolean closeConn, String sql) throws SQLException {
[29/58] [abbrv] commons-dbutils git commit: Eliminate unboxing
Posted by th...@apache.org.
Eliminate unboxing
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/dbutils/branches/2_0@1481212 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/commons-dbutils/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-dbutils/commit/c0359384
Tree: http://git-wip-us.apache.org/repos/asf/commons-dbutils/tree/c0359384
Diff: http://git-wip-us.apache.org/repos/asf/commons-dbutils/diff/c0359384
Branch: refs/heads/2_0
Commit: c035938477cb7cef1b81462b06af91153abea0c9
Parents: b4a5102
Author: Sebastian Bazley <se...@apache.org>
Authored: Fri May 10 21:54:32 2013 +0000
Committer: Sebastian Bazley <se...@apache.org>
Committed: Fri May 10 21:54:32 2013 +0000
----------------------------------------------------------------------
src/main/java/org/apache/commons/dbutils2/AbstractExecutor.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/c0359384/src/main/java/org/apache/commons/dbutils2/AbstractExecutor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/AbstractExecutor.java b/src/main/java/org/apache/commons/dbutils2/AbstractExecutor.java
index c8cb578..b1ac3f8 100644
--- a/src/main/java/org/apache/commons/dbutils2/AbstractExecutor.java
+++ b/src/main/java/org/apache/commons/dbutils2/AbstractExecutor.java
@@ -45,7 +45,7 @@ abstract class AbstractExecutor<T extends AbstractExecutor<T>> {
private final Map<String, List<Integer>> paramPosMap;
private final Map<String, Object> paramValueMap;
- private Integer currentPosition = Integer.valueOf(0);
+ private int currentPosition = 0;
public AbstractExecutor(final Connection conn, final String sql) throws SQLException {
this.conn = conn;
@@ -79,7 +79,7 @@ abstract class AbstractExecutor<T extends AbstractExecutor<T>> {
}
// increment first, so we match SQL numbering
- posList.add(++currentPosition);
+ posList.add(Integer.valueOf(++currentPosition));
}
/**
[35/58] [abbrv] commons-dbutils git commit: Removed an unnecessary
null asignment
Posted by th...@apache.org.
Removed an unnecessary null asignment
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/dbutils/branches/2_0@1481744 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/commons-dbutils/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-dbutils/commit/c05691b4
Tree: http://git-wip-us.apache.org/repos/asf/commons-dbutils/tree/c05691b4
Diff: http://git-wip-us.apache.org/repos/asf/commons-dbutils/diff/c05691b4
Branch: refs/heads/2_0
Commit: c05691b4ab237867c0d3f2f1d3dace0739f5e8ac
Parents: dfeead1
Author: Emmanuel Bourg <eb...@apache.org>
Authored: Mon May 13 09:17:44 2013 +0000
Committer: Emmanuel Bourg <eb...@apache.org>
Committed: Mon May 13 09:17:44 2013 +0000
----------------------------------------------------------------------
.../org/apache/commons/dbutils2/BeanProcessor.java | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/c05691b4/src/main/java/org/apache/commons/dbutils2/BeanProcessor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/BeanProcessor.java b/src/main/java/org/apache/commons/dbutils2/BeanProcessor.java
index 53e8515..6e621b5 100644
--- a/src/main/java/org/apache/commons/dbutils2/BeanProcessor.java
+++ b/src/main/java/org/apache/commons/dbutils2/BeanProcessor.java
@@ -355,12 +355,10 @@ public class BeanProcessor {
return c.newInstance();
} catch (InstantiationException e) {
- throw new SQLException(
- "Cannot create " + c.getName() + ": " + e.getMessage());
+ throw new SQLException("Cannot create " + c.getName() + ": " + e.getMessage());
} catch (IllegalAccessException e) {
- throw new SQLException(
- "Cannot create " + c.getName() + ": " + e.getMessage());
+ throw new SQLException("Cannot create " + c.getName() + ": " + e.getMessage());
}
}
@@ -371,16 +369,14 @@ public class BeanProcessor {
* @return A PropertyDescriptor[] describing the Class.
* @throws SQLException if introspection failed.
*/
- private PropertyDescriptor[] propertyDescriptors(Class<?> c)
- throws SQLException {
+ private PropertyDescriptor[] propertyDescriptors(Class<?> c) throws SQLException {
// Introspector caches BeanInfo classes for better performance
- BeanInfo beanInfo = null;
+ BeanInfo beanInfo;
try {
beanInfo = Introspector.getBeanInfo(c);
} catch (IntrospectionException e) {
- throw new SQLException(
- "Bean introspection failed: " + e.getMessage());
+ throw new SQLException("Bean introspection failed: " + e.getMessage());
}
return beanInfo.getPropertyDescriptors();
[31/58] [abbrv] commons-dbutils git commit: Directory is no longer
used (was empty)
Posted by th...@apache.org.
Directory is no longer used (was empty)
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/dbutils/branches/2_0@1481324 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/commons-dbutils/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-dbutils/commit/fe043e70
Tree: http://git-wip-us.apache.org/repos/asf/commons-dbutils/tree/fe043e70
Diff: http://git-wip-us.apache.org/repos/asf/commons-dbutils/diff/fe043e70
Branch: refs/heads/2_0
Commit: fe043e703ae9421e34e0add32bcef966ad71e8af
Parents: 44eadb7
Author: Sebastian Bazley <se...@apache.org>
Authored: Sat May 11 13:34:22 2013 +0000
Committer: Sebastian Bazley <se...@apache.org>
Committed: Sat May 11 13:34:22 2013 +0000
----------------------------------------------------------------------
----------------------------------------------------------------------
[10/58] [abbrv] commons-dbutils git commit: Changed the package names
so dbutils and dbutils2 won't conflict if both loaded
Posted by th...@apache.org.
Changed the package names so dbutils and dbutils2 won't conflict if both loaded
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/dbutils/branches/2_0@1454860 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/commons-dbutils/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-dbutils/commit/41d6d58c
Tree: http://git-wip-us.apache.org/repos/asf/commons-dbutils/tree/41d6d58c
Diff: http://git-wip-us.apache.org/repos/asf/commons-dbutils/diff/41d6d58c
Branch: refs/heads/2_0
Commit: 41d6d58c09ac2d0299292080a6845547404f14d7
Parents: b579869
Author: Bill Speirs <ws...@apache.org>
Authored: Sun Mar 10 14:54:34 2013 +0000
Committer: Bill Speirs <ws...@apache.org>
Committed: Sun Mar 10 14:54:34 2013 +0000
----------------------------------------------------------------------
.../commons/dbutils/AbstractExecutor.java | 323 ---
.../apache/commons/dbutils/AsyncExecutor.java | 129 --
.../commons/dbutils/BaseResultSetHandler.java | 1923 ------------------
.../commons/dbutils/BasicRowProcessor.java | 239 ---
.../apache/commons/dbutils/BatchExecutor.java | 117 --
.../apache/commons/dbutils/BeanProcessor.java | 504 -----
.../org/apache/commons/dbutils/DbUtils.java | 406 ----
.../commons/dbutils/GenerousBeanProcessor.java | 71 -
.../apache/commons/dbutils/InsertExecutor.java | 100 -
.../apache/commons/dbutils/ProxyFactory.java | 135 --
.../apache/commons/dbutils/QueryExecutor.java | 82 -
.../org/apache/commons/dbutils/QueryLoader.java | 124 --
.../org/apache/commons/dbutils/QueryRunner.java | 315 ---
.../commons/dbutils/ResultSetHandler.java | 43 -
.../commons/dbutils/ResultSetIterator.java | 141 --
.../apache/commons/dbutils/RowProcessor.java | 86 -
.../apache/commons/dbutils/UpdateExecutor.java | 57 -
.../dbutils/handlers/AbstractKeyedHandler.java | 87 -
.../dbutils/handlers/AbstractListHandler.java | 61 -
.../commons/dbutils/handlers/ArrayHandler.java | 81 -
.../dbutils/handlers/ArrayListHandler.java | 72 -
.../commons/dbutils/handlers/BeanHandler.java | 83 -
.../dbutils/handlers/BeanListHandler.java | 85 -
.../dbutils/handlers/BeanMapHandler.java | 185 --
.../dbutils/handlers/ColumnListHandler.java | 105 -
.../commons/dbutils/handlers/KeyedHandler.java | 161 --
.../commons/dbutils/handlers/MapHandler.java | 76 -
.../dbutils/handlers/MapListHandler.java | 73 -
.../commons/dbutils/handlers/ScalarHandler.java | 110 -
.../commons/dbutils/handlers/package-info.java | 21 -
.../apache/commons/dbutils/package-info.java | 26 -
.../wrappers/SqlNullCheckedResultSet.java | 608 ------
.../wrappers/StringTrimmedResultSet.java | 109 -
.../commons/dbutils/wrappers/package-info.java | 21 -
.../commons/dbutils2/AbstractExecutor.java | 323 +++
.../apache/commons/dbutils2/AsyncExecutor.java | 129 ++
.../commons/dbutils2/BaseResultSetHandler.java | 1923 ++++++++++++++++++
.../commons/dbutils2/BasicRowProcessor.java | 239 +++
.../apache/commons/dbutils2/BatchExecutor.java | 117 ++
.../apache/commons/dbutils2/BeanProcessor.java | 504 +++++
.../org/apache/commons/dbutils2/DbUtils.java | 406 ++++
.../commons/dbutils2/GenerousBeanProcessor.java | 71 +
.../apache/commons/dbutils2/InsertExecutor.java | 100 +
.../apache/commons/dbutils2/ProxyFactory.java | 135 ++
.../apache/commons/dbutils2/QueryExecutor.java | 82 +
.../apache/commons/dbutils2/QueryLoader.java | 124 ++
.../apache/commons/dbutils2/QueryRunner.java | 315 +++
.../commons/dbutils2/ResultSetHandler.java | 43 +
.../commons/dbutils2/ResultSetIterator.java | 141 ++
.../apache/commons/dbutils2/RowProcessor.java | 86 +
.../apache/commons/dbutils2/UpdateExecutor.java | 57 +
.../dbutils2/handlers/AbstractKeyedHandler.java | 87 +
.../dbutils2/handlers/AbstractListHandler.java | 61 +
.../commons/dbutils2/handlers/ArrayHandler.java | 81 +
.../dbutils2/handlers/ArrayListHandler.java | 72 +
.../commons/dbutils2/handlers/BeanHandler.java | 83 +
.../dbutils2/handlers/BeanListHandler.java | 85 +
.../dbutils2/handlers/BeanMapHandler.java | 185 ++
.../dbutils2/handlers/ColumnListHandler.java | 105 +
.../commons/dbutils2/handlers/KeyedHandler.java | 161 ++
.../commons/dbutils2/handlers/MapHandler.java | 76 +
.../dbutils2/handlers/MapListHandler.java | 73 +
.../dbutils2/handlers/ScalarHandler.java | 110 +
.../commons/dbutils2/handlers/package-info.java | 21 +
.../apache/commons/dbutils2/package-info.java | 26 +
.../wrappers/SqlNullCheckedResultSet.java | 608 ++++++
.../wrappers/StringTrimmedResultSet.java | 109 +
.../commons/dbutils2/wrappers/package-info.java | 21 +
.../commons/dbutils/AbstractExecutorTest.java | 122 --
.../commons/dbutils/AsyncExecutorTest.java | 93 -
.../dbutils/BaseResultSetHandlerTestCase.java | 71 -
.../apache/commons/dbutils/BaseTestCase.java | 127 --
.../commons/dbutils/BasicRowProcessorTest.java | 139 --
.../commons/dbutils/BatchExecutorTest.java | 67 -
.../commons/dbutils/BeanProcessorTest.java | 113 -
.../org/apache/commons/dbutils/DbUtilsTest.java | 272 ---
.../dbutils/GenerousBeanProcessorTest.java | 113 -
.../commons/dbutils/InsertExecutorTest.java | 91 -
.../apache/commons/dbutils/MockResultSet.java | 363 ----
.../commons/dbutils/MockResultSetMetaData.java | 95 -
.../commons/dbutils/ProxyFactoryTest.java | 66 -
.../commons/dbutils/QueryExecutorTest.java | 91 -
.../apache/commons/dbutils/QueryLoaderTest.java | 49 -
.../apache/commons/dbutils/QueryRunnerTest.java | 159 --
.../commons/dbutils/ResultSetIteratorTest.java | 49 -
.../org/apache/commons/dbutils/TestBean.java | 148 --
.../commons/dbutils/UpdateExecutorTest.java | 74 -
.../dbutils/handlers/ArrayHandlerTest.java | 47 -
.../dbutils/handlers/ArrayListHandlerTest.java | 66 -
.../dbutils/handlers/BeanHandlerTest.java | 48 -
.../dbutils/handlers/BeanListHandlerTest.java | 67 -
.../dbutils/handlers/BeanMapHandlerTest.java | 90 -
.../dbutils/handlers/ColumnListHandlerTest.java | 71 -
.../dbutils/handlers/KeyedHandlerTest.java | 101 -
.../dbutils/handlers/MapHandlerTest.java | 48 -
.../dbutils/handlers/MapListHandlerTest.java | 67 -
.../dbutils/handlers/ScalarHandlerTest.java | 53 -
.../wrappers/SqlNullCheckedResultSetTest.java | 1020 ----------
.../wrappers/StringTrimmedResultSetTest.java | 69 -
.../commons/dbutils2/AbstractExecutorTest.java | 124 ++
.../commons/dbutils2/AsyncExecutorTest.java | 100 +
.../dbutils2/BaseResultSetHandlerTestCase.java | 72 +
.../apache/commons/dbutils2/BaseTestCase.java | 127 ++
.../commons/dbutils2/BasicRowProcessorTest.java | 142 ++
.../commons/dbutils2/BatchExecutorTest.java | 69 +
.../commons/dbutils2/BeanProcessorTest.java | 116 ++
.../apache/commons/dbutils2/DbUtilsTest.java | 273 +++
.../dbutils2/GenerousBeanProcessorTest.java | 115 ++
.../commons/dbutils2/InsertExecutorTest.java | 94 +
.../apache/commons/dbutils2/MockResultSet.java | 365 ++++
.../commons/dbutils2/MockResultSetMetaData.java | 97 +
.../commons/dbutils2/ProxyFactoryTest.java | 68 +
.../commons/dbutils2/QueryExecutorTest.java | 94 +
.../commons/dbutils2/QueryLoaderTest.java | 51 +
.../commons/dbutils2/QueryRunnerTest.java | 161 ++
.../commons/dbutils2/ResultSetIteratorTest.java | 51 +
.../org/apache/commons/dbutils2/TestBean.java | 148 ++
.../commons/dbutils2/UpdateExecutorTest.java | 76 +
.../dbutils2/handlers/ArrayHandlerTest.java | 48 +
.../dbutils2/handlers/ArrayListHandlerTest.java | 67 +
.../dbutils2/handlers/BeanHandlerTest.java | 49 +
.../dbutils2/handlers/BeanListHandlerTest.java | 68 +
.../dbutils2/handlers/BeanMapHandlerTest.java | 91 +
.../handlers/ColumnListHandlerTest.java | 72 +
.../dbutils2/handlers/KeyedHandlerTest.java | 102 +
.../dbutils2/handlers/MapHandlerTest.java | 49 +
.../dbutils2/handlers/MapListHandlerTest.java | 68 +
.../dbutils2/handlers/ScalarHandlerTest.java | 54 +
.../wrappers/SqlNullCheckedResultSetTest.java | 1021 ++++++++++
.../wrappers/StringTrimmedResultSetTest.java | 71 +
130 files changed, 10862 insertions(+), 10808 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/main/java/org/apache/commons/dbutils/AbstractExecutor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils/AbstractExecutor.java b/src/main/java/org/apache/commons/dbutils/AbstractExecutor.java
deleted file mode 100644
index 63fa3ab..0000000
--- a/src/main/java/org/apache/commons/dbutils/AbstractExecutor.java
+++ /dev/null
@@ -1,323 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.dbutils;
-
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.sql.Types;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * Abstract class for executing a query, insert, update, or batch.
- *
- * @since 2.0
- * @author William Speirs <ws...@apache.org>
- */
-abstract class AbstractExecutor<T extends AbstractExecutor<T>> {
-
- private static final String COLON = ":"; // TODO: change this to any character
-
- private final Connection conn;
- private final String sql;
- private final PreparedStatement stmt;
-
- private final Map<String, List<Integer>> paramPosMap;
- private final Map<String, Object> paramValueMap;
- private Integer currentPosition = Integer.valueOf(0);
-
- public AbstractExecutor(final Connection conn, final String sql) throws SQLException {
- this.conn = conn;
- this.sql = sql;
- this.paramPosMap = new HashMap<String, List<Integer>>();
- this.paramValueMap = new HashMap<String, Object>();
-
- final Pattern paramPattern = Pattern.compile("(:\\w+)");
- final Matcher matcher = paramPattern.matcher(sql);
-
- // go through finding params
- while(matcher.find()) {
- insertParamPosition(matcher.group().replace(COLON, ""));
- }
-
- // replace all of the :names with ?, and create a prepared statement
- stmt = conn.prepareStatement(sql.replaceAll(":\\w+", "\\?"));
- }
-
- /**
- * Helper method to insert params and the current position into the map.
- * @param param the SQL param.
- */
- private void insertParamPosition(final String param) {
- List<Integer> posList = paramPosMap.get(param);
-
- // create a new list if we need to
- if(posList == null) {
- posList = new ArrayList<Integer>();
- paramPosMap.put(param, posList);
- }
-
- // increment first, so we match SQL numbering
- posList.add(++currentPosition);
- }
-
- /**
- * Gets the SQL statement that was passed into the constructor.
- * @return the SQL statement passed into the constructor.
- */
- protected String getSql() {
- return sql;
- }
-
- /**
- * Returns the underlying prepared statement.
- * @return the underlying prepared statement.
- */
- protected PreparedStatement getStatement() {
- return stmt;
- }
-
- /**
- * Returns the underlying connection.
- * @return the underlying connection.
- */
- protected Connection getConnection() {
- return conn;
- }
-
- /**
- * Throws an exception if there are unmapped params.
- * @throws SQLException if there are unmapped params.
- */
- protected void throwIfUnmappedParams() throws SQLException {
- if(paramPosMap.size() != 0) {
- final Set<String> unmappedParams = paramPosMap.keySet();
- final StringBuilder sb = new StringBuilder("There are unbound parameters: ");
-
- for(String param:unmappedParams) {
- sb.append(param);
- sb.append(", ");
- }
-
- // remove the last comma
- sb.delete(sb.length()-2, sb.length());
-
- // throw our exception
- throw new SQLException(sb.toString());
- }
- }
-
- /**
- * Binds a named parameter to a value.
- *
- * @param name the name of the parameter in the SQL statement.
- * @param value the value of the parameter in the SQL statement.
- * @return this execution object to provide the fluent style.
- * @throws SQLException thrown if the parameter is not found, already bound, or there is an issue binding it.
- */
- public T bind(final String name, final Object value) throws SQLException {
- return bind(name, value, true);
- }
-
- /**
- * Binds null to a parameter.
- * Types.VARCHAR is used as the type's parameter.
- * This usually works, but fails with some Oracle and MS SQL drivers.
- * @param name the name of the parameter.
- * @return this execution object to provide the fluent style.
- * @throws SQLException throw if the parameter is not found, already bound, or there is an issue binding null.
- */
- public T bindNull(final String name) throws SQLException {
- return bindNull(name, Types.VARCHAR, true);
- }
-
- /**
- * Binds null to a parameter, specifying the parameter's type.
- * @param name the name of the parameter.
- * @param sqlType the type of the parameter.
- * @return this execution object to provide the fluent style.
- * @throws SQLException throw if the parameter is not found, already bound, or there is an issue binding null.
- */
- public T bindNull(final String name, final int sqlType) throws SQLException {
- return bindNull(name, sqlType, true);
- }
-
- /**
- * Given a param name and sqlType, binds a null to that parameter.
- * @param name the name of the parameter.
- * @param sqlType the type of the parameter.
- * @param removeFromPosMap if the param should be removed from the pos map.
- * @return this
- * @throws SQLException if there is an SQLException during binding.
- */
- protected T bindNull(String name, int sqlType, boolean removeFromPosMap) throws SQLException {
- name = name.replace(COLON, ""); // so we can take ":name" or "name"
-
- final List<Integer> pos = removeFromPosMap ? paramPosMap.remove(name) : paramPosMap.get(name);
-
- if(pos == null) {
- throw new SQLException(name + " is not found in the SQL statement");
- }
-
- // go through and bind all of the positions for this name
- for(Integer p:pos) {
- stmt.setNull(p, sqlType);
- }
-
- // add the param and value to our map
- paramValueMap.put(name, null);
-
- // suppressed because the casting will always work here
- @SuppressWarnings("unchecked")
- final T ret = (T) this;
-
- return ret;
- }
-
- /**
- * Binds value to name, but does not do the bookkeeping.
- * @param name the parameter name.
- * @param value the value.
- * @param removeFromPosMap if the param should be removed from the pos map.
- * @return this
- * @throws SQLException if there is an SQLException during binding.
- */
- protected T bind(String name, final Object value, boolean removeFromPosMap) throws SQLException {
- name = name.replace(COLON, ""); // so we can take ":name" or "name"
-
- final List<Integer> pos = removeFromPosMap ? paramPosMap.remove(name) : paramPosMap.get(name);
-
- if(pos == null) {
- throw new SQLException(name + " is not found in the SQL statement");
- }
-
- // go through and bind all of the positions for this name
- for(Integer p:pos) {
- // TODO: need to figure out how to bind NULL
- stmt.setObject(p, value);
- }
-
- // add the param and value to our map
- paramValueMap.put(name, value);
-
- // suppressed because the casting will always work here
- @SuppressWarnings("unchecked")
- final T ret = (T) this;
-
- return ret;
- }
-
- /**
- * Used for batch calls so we can clear the map after the addBatch call.
- */
- protected void clearValueMap() {
- paramValueMap.clear();
- }
-
- /**
- * Throws a new exception with a more informative error message.
- *
- * @param cause The original exception that will be chained to the new
- * exception when it's rethrown.
- *
- * @throws SQLException if a database access error occurs
- */
- protected void rethrow(SQLException cause) throws SQLException {
- String causeMessage = cause.getMessage();
-
- if (causeMessage == null) {
- causeMessage = "";
- }
-
- final StringBuffer msg = new StringBuffer(causeMessage);
-
- msg.append(" Query: ");
- msg.append(sql);
- msg.append(" Parameters: ");
-
- // loop through adding the parameter to value mappings
- for(Map.Entry<String, Object> param:paramValueMap.entrySet()) {
- msg.append(param.getKey());
- msg.append("=");
- msg.append(param.getValue());
- msg.append(" ");
- }
-
- final SQLException e = new SQLException(msg.toString(), cause.getSQLState(), cause.getErrorCode());
- e.setNextException(cause);
-
- throw e;
- }
-
- /**
- * Wrap the <code>ResultSet</code> in a decorator before processing it. This
- * implementation returns the <code>ResultSet</code> it is given without any
- * decoration.
- *
- * @param rs The <code>ResultSet</code> to decorate; never <code>null</code>.
- * @return The <code>ResultSet</code> wrapped in some decorator.
- */
- protected ResultSet wrap(ResultSet rs) {
- return rs;
- }
-
- /**
- * Close a <code>Connection</code>. This implementation avoids closing if
- * null and does <strong>not</strong> suppress any exceptions. Subclasses
- * can override to provide special handling like logging.
- *
- * @param conn Connection to close
- * @throws SQLException if a database access error occurs
- */
- protected void close(Connection conn) throws SQLException {
- DbUtils.close(conn);
- }
-
- /**
- * Close a <code>Statement</code>. This implementation avoids closing if
- * null and does <strong>not</strong> suppress any exceptions. Subclasses
- * can override to provide special handling like logging.
- *
- * @param stmt Statement to close
- * @throws SQLException if a database access error occurs
- */
- protected void close(Statement stmt) throws SQLException {
- DbUtils.close(stmt);
- }
-
- /**
- * Close a <code>ResultSet</code>. This implementation avoids closing if
- * null and does <strong>not</strong> suppress any exceptions. Subclasses
- * can override to provide special handling like logging.
- *
- * @param rs ResultSet to close
- * @throws SQLException if a database access error occurs
- */
- protected void close(ResultSet rs) throws SQLException {
- DbUtils.close(rs);
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/main/java/org/apache/commons/dbutils/AsyncExecutor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils/AsyncExecutor.java b/src/main/java/org/apache/commons/dbutils/AsyncExecutor.java
deleted file mode 100644
index 295e368..0000000
--- a/src/main/java/org/apache/commons/dbutils/AsyncExecutor.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.dbutils;
-
-import java.sql.SQLException;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Future;
-
-/**
- * Convenience class for executing QueryExecutor, InsertExecutor, or UpdateExecutors asynchronously.
- *
- * @author William Speirs <ws...@apache.org>
- * @since 2.0
- */
-public class AsyncExecutor {
-
- private final ExecutorService executorService;
-
- /**
- * Constructor for AsyncQueryRunner which uses a provided ExecutorService and underlying QueryRunner.
- *
- * @param executorService the {@code ExecutorService} instance used to run JDBC invocations concurrently.
- * @param queryRunner the {@code QueryRunner} instance to use for the queries.
- */
- public AsyncExecutor(ExecutorService executorService) {
- this.executorService = executorService;
- }
-
- /**
- * Execute a {@link org.apache.commons.dbutils.BatchExecutor}.
- * @return A <code>Future</code> which returns the result of the batch call.
- * @throws SQLException if a database access error occurs
- */
- public Future<int[]> execute(final BatchExecutor executor) throws SQLException {
- return executorService.submit(new Callable<int[]>() {
-
- @Override
- public int[] call() throws Exception {
- return executor.execute();
- }
-
- });
- }
-
- /**
- * Execute a {@link org.apache.commons.dbutils.QueryExecutor} given a handler.
- * @param <T> The type of object that the handler returns
- * @param handler The handler that converts the results into an object.
- * @return A <code>Future</code> which returns the result of the query call.
- * @throws SQLException if a database access error occurs
- */
- public <T> Future<T> execute(final QueryExecutor executor, final ResultSetHandler<T> handler) throws SQLException {
- return executorService.submit(new Callable<T>() {
-
- @Override
- public T call() throws Exception {
- return executor.execute(handler);
- }
-
- });
- }
-
- /**
- * Execute a {@link org.apache.commons.dbutils.UpdateExecutor}.
- * @param <T> The type of object that the handler returns
- * @return A <code>Future</code> which returns the result of the query call.
- * @throws SQLException if a database access error occurs
- */
- public Future<Integer> execute(final UpdateExecutor executor) throws SQLException {
- return executorService.submit(new Callable<Integer>() {
-
- @Override
- public Integer call() throws Exception {
- return executor.execute();
- }
-
- });
- }
-
- /**
- * Execute a {@link org.apache.commons.dbutils.InsertExecutor} given a handler.
- * @param <T> The type of object that the handler returns
- * @param handler The handler that converts the results into an object.
- * @return A <code>Future</code> which returns the result of the query call.
- * @throws SQLException if a database access error occurs
- */
- public <T> Future<T> execute(final InsertExecutor executor, final ResultSetHandler<T> handler) throws SQLException {
- return executorService.submit(new Callable<T>() {
-
- @Override
- public T call() throws Exception {
- return executor.execute(handler);
- }
-
- });
- }
-
- /**
- * Execute a {@link org.apache.commons.dbutils.InsertExecutor} given a handler.
- * @return A <code>Future</code> which returns the number of rows inserted.
- * @throws SQLException if a database access error occurs
- */
- public Future<Integer> execute(final InsertExecutor executor) throws SQLException {
- return executorService.submit(new Callable<Integer>() {
-
- @Override
- public Integer call() throws Exception {
- return executor.execute();
- }
-
- });
- }
-
-}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/main/java/org/apache/commons/dbutils/BaseResultSetHandler.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils/BaseResultSetHandler.java b/src/main/java/org/apache/commons/dbutils/BaseResultSetHandler.java
deleted file mode 100644
index 0fbe1ea..0000000
--- a/src/main/java/org/apache/commons/dbutils/BaseResultSetHandler.java
+++ /dev/null
@@ -1,1923 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.dbutils;
-
-import java.io.InputStream;
-import java.io.Reader;
-import java.math.BigDecimal;
-import java.net.URL;
-import java.sql.Array;
-import java.sql.Blob;
-import java.sql.Clob;
-import java.sql.Date;
-import java.sql.NClob;
-import java.sql.Ref;
-import java.sql.ResultSet;
-import java.sql.ResultSetMetaData;
-import java.sql.RowId;
-import java.sql.SQLException;
-import java.sql.SQLWarning;
-import java.sql.SQLXML;
-import java.sql.Statement;
-import java.sql.Time;
-import java.sql.Timestamp;
-import java.util.Calendar;
-import java.util.Map;
-
-/**
- * Extensions of this class convert ResultSets into other objects.
- *
- * According to the <i>DRY</i> principle (Don't Repeat Yourself), repeating <code>resultSet</code>
- * variable inside the {@link ResultSetHandler#handle(ResultSet)} over and over for each iteration
- * can get a little tedious, <code>AbstractResultSetHandler</code> implicitly gives users access to
- * <code>ResultSet</code>'s methods.
- *
- * <b>NOTE</b> This class is <i>NOT</i> thread safe!
- *
- * @param <T> the target type the input ResultSet will be converted to.
- * @since 1.6
- */
-public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
-
- /**
- * The adapted ResultSet.
- */
- private ResultSet rs;
-
- /**
- * {@inheritDoc}
- */
- @Override
- public final T handle(ResultSet rs) throws SQLException {
- if (this.rs != null) {
- throw new IllegalStateException("Re-entry not allowed!");
- }
-
- this.rs = rs;
-
- try {
- return handle();
- } finally {
- this.rs = null;
- }
- }
-
- /**
- * Turn the <code>ResultSet</code> into an Object.
- *
- * @return An Object initialized with <code>ResultSet</code> data
- * @throws SQLException if a database access error occurs
- * @see {@link ResultSetHandler#handle(ResultSet)}
- */
- protected abstract T handle() throws SQLException;
-
- /**
- * @param row
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#absolute(int)
- */
- protected final boolean absolute(int row) throws SQLException {
- return rs.absolute(row);
- }
-
- /**
- * @throws SQLException
- * @see java.sql.ResultSet#afterLast()
- */
- protected final void afterLast() throws SQLException {
- rs.afterLast();
- }
-
- /**
- * @throws SQLException
- * @see java.sql.ResultSet#beforeFirst()
- */
- protected final void beforeFirst() throws SQLException {
- rs.beforeFirst();
- }
-
- /**
- * @throws SQLException
- * @see java.sql.ResultSet#cancelRowUpdates()
- */
- protected final void cancelRowUpdates() throws SQLException {
- rs.cancelRowUpdates();
- }
-
- /**
- * @throws SQLException
- * @see java.sql.ResultSet#clearWarnings()
- */
- protected final void clearWarnings() throws SQLException {
- rs.clearWarnings();
- }
-
- /**
- * @throws SQLException
- * @see java.sql.ResultSet#close()
- */
- protected final void close() throws SQLException {
- rs.close();
- }
-
- /**
- * @throws SQLException
- * @see java.sql.ResultSet#deleteRow()
- */
- protected final void deleteRow() throws SQLException {
- rs.deleteRow();
- }
-
- /**
- * @param columnLabel
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#findColumn(java.lang.String)
- */
- protected final int findColumn(String columnLabel) throws SQLException {
- return rs.findColumn(columnLabel);
- }
-
- /**
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#first()
- */
- protected final boolean first() throws SQLException {
- return rs.first();
- }
-
- /**
- * @param columnIndex
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#getArray(int)
- */
- protected final Array getArray(int columnIndex) throws SQLException {
- return rs.getArray(columnIndex);
- }
-
- /**
- * @param columnLabel
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#getArray(java.lang.String)
- */
- protected final Array getArray(String columnLabel) throws SQLException {
- return rs.getArray(columnLabel);
- }
-
- /**
- * @param columnIndex
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#getAsciiStream(int)
- */
- protected final InputStream getAsciiStream(int columnIndex) throws SQLException {
- return rs.getAsciiStream(columnIndex);
- }
-
- /**
- * @param columnLabel
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#getAsciiStream(java.lang.String)
- */
- protected final InputStream getAsciiStream(String columnLabel) throws SQLException {
- return rs.getAsciiStream(columnLabel);
- }
-
- /**
- * @param columnIndex
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#getBigDecimal(int)
- */
- protected final BigDecimal getBigDecimal(int columnIndex) throws SQLException {
- return rs.getBigDecimal(columnIndex);
- }
-
- /**
- * @param columnLabel
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#getBigDecimal(java.lang.String)
- */
- protected final BigDecimal getBigDecimal(String columnLabel) throws SQLException {
- return rs.getBigDecimal(columnLabel);
- }
-
- /**
- * @param columnIndex
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#getBinaryStream(int)
- */
- protected final InputStream getBinaryStream(int columnIndex) throws SQLException {
- return rs.getBinaryStream(columnIndex);
- }
-
- /**
- * @param columnLabel
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#getBinaryStream(java.lang.String)
- */
- protected final InputStream getBinaryStream(String columnLabel) throws SQLException {
- return rs.getBinaryStream(columnLabel);
- }
-
- /**
- * @param columnIndex
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#getBlob(int)
- */
- protected final Blob getBlob(int columnIndex) throws SQLException {
- return rs.getBlob(columnIndex);
- }
-
- /**
- * @param columnLabel
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#getBlob(java.lang.String)
- */
- protected final Blob getBlob(String columnLabel) throws SQLException {
- return rs.getBlob(columnLabel);
- }
-
- /**
- * @param columnIndex
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#getBoolean(int)
- */
- protected final boolean getBoolean(int columnIndex) throws SQLException {
- return rs.getBoolean(columnIndex);
- }
-
- /**
- * @param columnLabel
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#getBoolean(java.lang.String)
- */
- protected final boolean getBoolean(String columnLabel) throws SQLException {
- return rs.getBoolean(columnLabel);
- }
-
- /**
- * @param columnIndex
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#getByte(int)
- */
- protected final byte getByte(int columnIndex) throws SQLException {
- return rs.getByte(columnIndex);
- }
-
- /**
- * @param columnLabel
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#getByte(java.lang.String)
- */
- protected final byte getByte(String columnLabel) throws SQLException {
- return rs.getByte(columnLabel);
- }
-
- /**
- * @param columnIndex
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#getBytes(int)
- */
- protected final byte[] getBytes(int columnIndex) throws SQLException {
- return rs.getBytes(columnIndex);
- }
-
- /**
- * @param columnLabel
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#getBytes(java.lang.String)
- */
- protected final byte[] getBytes(String columnLabel) throws SQLException {
- return rs.getBytes(columnLabel);
- }
-
- /**
- * @param columnIndex
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#getCharacterStream(int)
- */
- protected final Reader getCharacterStream(int columnIndex) throws SQLException {
- return rs.getCharacterStream(columnIndex);
- }
-
- /**
- * @param columnLabel
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#getCharacterStream(java.lang.String)
- */
- protected final Reader getCharacterStream(String columnLabel) throws SQLException {
- return rs.getCharacterStream(columnLabel);
- }
-
- /**
- * @param columnIndex
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#getClob(int)
- */
- protected final Clob getClob(int columnIndex) throws SQLException {
- return rs.getClob(columnIndex);
- }
-
- /**
- * @param columnLabel
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#getClob(java.lang.String)
- */
- protected final Clob getClob(String columnLabel) throws SQLException {
- return rs.getClob(columnLabel);
- }
-
- /**
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#getConcurrency()
- */
- protected final int getConcurrency() throws SQLException {
- return rs.getConcurrency();
- }
-
- /**
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#getCursorName()
- */
- protected final String getCursorName() throws SQLException {
- return rs.getCursorName();
- }
-
- /**
- * @param columnIndex
- * @param cal
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#getDate(int, java.util.Calendar)
- */
- protected final Date getDate(int columnIndex, Calendar cal) throws SQLException {
- return rs.getDate(columnIndex, cal);
- }
-
- /**
- * @param columnIndex
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#getDate(int)
- */
- protected final Date getDate(int columnIndex) throws SQLException {
- return rs.getDate(columnIndex);
- }
-
- /**
- * @param columnLabel
- * @param cal
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#getDate(java.lang.String, java.util.Calendar)
- */
- protected final Date getDate(String columnLabel, Calendar cal) throws SQLException {
- return rs.getDate(columnLabel, cal);
- }
-
- /**
- * @param columnLabel
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#getDate(java.lang.String)
- */
- protected final Date getDate(String columnLabel) throws SQLException {
- return rs.getDate(columnLabel);
- }
-
- /**
- * @param columnIndex
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#getDouble(int)
- */
- protected final double getDouble(int columnIndex) throws SQLException {
- return rs.getDouble(columnIndex);
- }
-
- /**
- * @param columnLabel
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#getDouble(java.lang.String)
- */
- protected final double getDouble(String columnLabel) throws SQLException {
- return rs.getDouble(columnLabel);
- }
-
- /**
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#getFetchDirection()
- */
- protected final int getFetchDirection() throws SQLException {
- return rs.getFetchDirection();
- }
-
- /**
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#getFetchSize()
- */
- protected final int getFetchSize() throws SQLException {
- return rs.getFetchSize();
- }
-
- /**
- * @param columnIndex
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#getFloat(int)
- */
- protected final float getFloat(int columnIndex) throws SQLException {
- return rs.getFloat(columnIndex);
- }
-
- /**
- * @param columnLabel
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#getFloat(java.lang.String)
- */
- protected final float getFloat(String columnLabel) throws SQLException {
- return rs.getFloat(columnLabel);
- }
-
- /**
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#getHoldability()
- */
- protected final int getHoldability() throws SQLException {
- return rs.getHoldability();
- }
-
- /**
- * @param columnIndex
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#getInt(int)
- */
- protected final int getInt(int columnIndex) throws SQLException {
- return rs.getInt(columnIndex);
- }
-
- /**
- * @param columnLabel
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#getInt(java.lang.String)
- */
- protected final int getInt(String columnLabel) throws SQLException {
- return rs.getInt(columnLabel);
- }
-
- /**
- * @param columnIndex
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#getLong(int)
- */
- protected final long getLong(int columnIndex) throws SQLException {
- return rs.getLong(columnIndex);
- }
-
- /**
- * @param columnLabel
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#getLong(java.lang.String)
- */
- protected final long getLong(String columnLabel) throws SQLException {
- return rs.getLong(columnLabel);
- }
-
- /**
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#getMetaData()
- */
- protected final ResultSetMetaData getMetaData() throws SQLException {
- return rs.getMetaData();
- }
-
- /**
- * @param columnIndex
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#getNCharacterStream(int)
- */
- protected final Reader getNCharacterStream(int columnIndex) throws SQLException {
- return rs.getNCharacterStream(columnIndex);
- }
-
- /**
- * @param columnLabel
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#getNCharacterStream(java.lang.String)
- */
- protected final Reader getNCharacterStream(String columnLabel) throws SQLException {
- return rs.getNCharacterStream(columnLabel);
- }
-
- /**
- * @param columnIndex
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#getNClob(int)
- */
- protected final NClob getNClob(int columnIndex) throws SQLException {
- return rs.getNClob(columnIndex);
- }
-
- /**
- * @param columnLabel
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#getNClob(java.lang.String)
- */
- protected final NClob getNClob(String columnLabel) throws SQLException {
- return rs.getNClob(columnLabel);
- }
-
- /**
- * @param columnIndex
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#getNString(int)
- */
- protected final String getNString(int columnIndex) throws SQLException {
- return rs.getNString(columnIndex);
- }
-
- /**
- * @param columnLabel
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#getNString(java.lang.String)
- */
- protected final String getNString(String columnLabel) throws SQLException {
- return rs.getNString(columnLabel);
- }
-
- /**
- * @param columnIndex
- * @param map
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#getObject(int, java.util.Map)
- */
- protected final Object getObject(int columnIndex, Map<String, Class<?>> map) throws SQLException {
- return rs.getObject(columnIndex, map);
- }
-
- /**
- * @param columnIndex
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#getObject(int)
- */
- protected final Object getObject(int columnIndex) throws SQLException {
- return rs.getObject(columnIndex);
- }
-
- /**
- * @param columnLabel
- * @param map
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#getObject(java.lang.String, java.util.Map)
- */
- protected final Object getObject(String columnLabel, Map<String, Class<?>> map) throws SQLException {
- return rs.getObject(columnLabel, map);
- }
-
- /**
- * @param columnLabel
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#getObject(java.lang.String)
- */
- protected final Object getObject(String columnLabel) throws SQLException {
- return rs.getObject(columnLabel);
- }
-
- /**
- * @param columnIndex
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#getRef(int)
- */
- protected final Ref getRef(int columnIndex) throws SQLException {
- return rs.getRef(columnIndex);
- }
-
- /**
- * @param columnLabel
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#getRef(java.lang.String)
- */
- protected final Ref getRef(String columnLabel) throws SQLException {
- return rs.getRef(columnLabel);
- }
-
- /**
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#getRow()
- */
- protected final int getRow() throws SQLException {
- return rs.getRow();
- }
-
- /**
- * @param columnIndex
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#getRowId(int)
- */
- protected final RowId getRowId(int columnIndex) throws SQLException {
- return rs.getRowId(columnIndex);
- }
-
- /**
- * @param columnLabel
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#getRowId(java.lang.String)
- */
- protected final RowId getRowId(String columnLabel) throws SQLException {
- return rs.getRowId(columnLabel);
- }
-
- /**
- * @param columnIndex
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#getSQLXML(int)
- */
- protected final SQLXML getSQLXML(int columnIndex) throws SQLException {
- return rs.getSQLXML(columnIndex);
- }
-
- /**
- * @param columnLabel
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#getSQLXML(java.lang.String)
- */
- protected final SQLXML getSQLXML(String columnLabel) throws SQLException {
- return rs.getSQLXML(columnLabel);
- }
-
- /**
- * @param columnIndex
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#getShort(int)
- */
- protected final short getShort(int columnIndex) throws SQLException {
- return rs.getShort(columnIndex);
- }
-
- /**
- * @param columnLabel
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#getShort(java.lang.String)
- */
- protected final short getShort(String columnLabel) throws SQLException {
- return rs.getShort(columnLabel);
- }
-
- /**
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#getStatement()
- */
- protected final Statement getStatement() throws SQLException {
- return rs.getStatement();
- }
-
- /**
- * @param columnIndex
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#getString(int)
- */
- protected final String getString(int columnIndex) throws SQLException {
- return rs.getString(columnIndex);
- }
-
- /**
- * @param columnLabel
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#getString(java.lang.String)
- */
- protected final String getString(String columnLabel) throws SQLException {
- return rs.getString(columnLabel);
- }
-
- /**
- * @param columnIndex
- * @param cal
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#getTime(int, java.util.Calendar)
- */
- protected final Time getTime(int columnIndex, Calendar cal) throws SQLException {
- return rs.getTime(columnIndex, cal);
- }
-
- /**
- * @param columnIndex
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#getTime(int)
- */
- protected final Time getTime(int columnIndex) throws SQLException {
- return rs.getTime(columnIndex);
- }
-
- /**
- * @param columnLabel
- * @param cal
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#getTime(java.lang.String, java.util.Calendar)
- */
- protected final Time getTime(String columnLabel, Calendar cal) throws SQLException {
- return rs.getTime(columnLabel, cal);
- }
-
- /**
- * @param columnLabel
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#getTime(java.lang.String)
- */
- protected final Time getTime(String columnLabel) throws SQLException {
- return rs.getTime(columnLabel);
- }
-
- /**
- * @param columnIndex
- * @param cal
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#getTimestamp(int, java.util.Calendar)
- */
- protected final Timestamp getTimestamp(int columnIndex, Calendar cal) throws SQLException {
- return rs.getTimestamp(columnIndex, cal);
- }
-
- /**
- * @param columnIndex
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#getTimestamp(int)
- */
- protected final Timestamp getTimestamp(int columnIndex) throws SQLException {
- return rs.getTimestamp(columnIndex);
- }
-
- /**
- * @param columnLabel
- * @param cal
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#getTimestamp(java.lang.String, java.util.Calendar)
- */
- protected final Timestamp getTimestamp(String columnLabel, Calendar cal) throws SQLException {
- return rs.getTimestamp(columnLabel, cal);
- }
-
- /**
- * @param columnLabel
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#getTimestamp(java.lang.String)
- */
- protected final Timestamp getTimestamp(String columnLabel) throws SQLException {
- return rs.getTimestamp(columnLabel);
- }
-
- /**
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#getType()
- */
- protected final int getType() throws SQLException {
- return rs.getType();
- }
-
- /**
- * @param columnIndex
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#getURL(int)
- */
- protected final URL getURL(int columnIndex) throws SQLException {
- return rs.getURL(columnIndex);
- }
-
- /**
- * @param columnLabel
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#getURL(java.lang.String)
- */
- protected final URL getURL(String columnLabel) throws SQLException {
- return rs.getURL(columnLabel);
- }
-
- /**
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#getWarnings()
- */
- protected final SQLWarning getWarnings() throws SQLException {
- return rs.getWarnings();
- }
-
- /**
- * @throws SQLException
- * @see java.sql.ResultSet#insertRow()
- */
- protected final void insertRow() throws SQLException {
- rs.insertRow();
- }
-
- /**
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#isAfterLast()
- */
- protected final boolean isAfterLast() throws SQLException {
- return rs.isAfterLast();
- }
-
- /**
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#isBeforeFirst()
- */
- protected final boolean isBeforeFirst() throws SQLException {
- return rs.isBeforeFirst();
- }
-
- /**
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#isClosed()
- */
- protected final boolean isClosed() throws SQLException {
- return rs.isClosed();
- }
-
- /**
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#isFirst()
- */
- protected final boolean isFirst() throws SQLException {
- return rs.isFirst();
- }
-
- /**
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#isLast()
- */
- protected final boolean isLast() throws SQLException {
- return rs.isLast();
- }
-
- /**
- * @param iface
- * @return
- * @throws SQLException
- * @see java.sql.Wrapper#isWrapperFor(java.lang.Class)
- */
- protected final boolean isWrapperFor(Class<?> iface) throws SQLException {
- return rs.isWrapperFor(iface);
- }
-
- /**
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#last()
- */
- protected final boolean last() throws SQLException {
- return rs.last();
- }
-
- /**
- * @throws SQLException
- * @see java.sql.ResultSet#moveToCurrentRow()
- */
- protected final void moveToCurrentRow() throws SQLException {
- rs.moveToCurrentRow();
- }
-
- /**
- * @throws SQLException
- * @see java.sql.ResultSet#moveToInsertRow()
- */
- protected final void moveToInsertRow() throws SQLException {
- rs.moveToInsertRow();
- }
-
- /**
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#next()
- */
- protected final boolean next() throws SQLException {
- return rs.next();
- }
-
- /**
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#previous()
- */
- protected final boolean previous() throws SQLException {
- return rs.previous();
- }
-
- /**
- * @throws SQLException
- * @see java.sql.ResultSet#refreshRow()
- */
- protected final void refreshRow() throws SQLException {
- rs.refreshRow();
- }
-
- /**
- * @param rows
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#relative(int)
- */
- protected final boolean relative(int rows) throws SQLException {
- return rs.relative(rows);
- }
-
- /**
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#rowDeleted()
- */
- protected final boolean rowDeleted() throws SQLException {
- return rs.rowDeleted();
- }
-
- /**
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#rowInserted()
- */
- protected final boolean rowInserted() throws SQLException {
- return rs.rowInserted();
- }
-
- /**
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#rowUpdated()
- */
- protected final boolean rowUpdated() throws SQLException {
- return rs.rowUpdated();
- }
-
- /**
- * @param direction
- * @throws SQLException
- * @see java.sql.ResultSet#setFetchDirection(int)
- */
- protected final void setFetchDirection(int direction) throws SQLException {
- rs.setFetchDirection(direction);
- }
-
- /**
- * @param rows
- * @throws SQLException
- * @see java.sql.ResultSet#setFetchSize(int)
- */
- protected final void setFetchSize(int rows) throws SQLException {
- rs.setFetchSize(rows);
- }
-
- /**
- * @param iface
- * @return
- * @throws SQLException
- * @see java.sql.Wrapper#unwrap(java.lang.Class)
- */
- protected final <E> E unwrap(Class<E> iface) throws SQLException {
- return rs.unwrap(iface);
- }
-
- /**
- * @param columnIndex
- * @param x
- * @throws SQLException
- * @see java.sql.ResultSet#updateArray(int, java.sql.Array)
- */
- protected final void updateArray(int columnIndex, Array x) throws SQLException {
- rs.updateArray(columnIndex, x);
- }
-
- /**
- * @param columnLabel
- * @param x
- * @throws SQLException
- * @see java.sql.ResultSet#updateArray(java.lang.String, java.sql.Array)
- */
- protected final void updateArray(String columnLabel, Array x) throws SQLException {
- rs.updateArray(columnLabel, x);
- }
-
- /**
- * @param columnIndex
- * @param x
- * @param length
- * @throws SQLException
- * @see java.sql.ResultSet#updateAsciiStream(int, java.io.InputStream, int)
- */
- protected final void updateAsciiStream(int columnIndex, InputStream x, int length) throws SQLException {
- rs.updateAsciiStream(columnIndex, x, length);
- }
-
- /**
- * @param columnIndex
- * @param x
- * @param length
- * @throws SQLException
- * @see java.sql.ResultSet#updateAsciiStream(int, java.io.InputStream, long)
- */
- protected final void updateAsciiStream(int columnIndex, InputStream x, long length) throws SQLException {
- rs.updateAsciiStream(columnIndex, x, length);
- }
-
- /**
- * @param columnIndex
- * @param x
- * @throws SQLException
- * @see java.sql.ResultSet#updateAsciiStream(int, java.io.InputStream)
- */
- protected final void updateAsciiStream(int columnIndex, InputStream x) throws SQLException {
- rs.updateAsciiStream(columnIndex, x);
- }
-
- /**
- * @param columnLabel
- * @param x
- * @param length
- * @throws SQLException
- * @see java.sql.ResultSet#updateAsciiStream(java.lang.String, java.io.InputStream, int)
- */
- protected final void updateAsciiStream(String columnLabel, InputStream x, int length) throws SQLException {
- rs.updateAsciiStream(columnLabel, x, length);
- }
-
- /**
- * @param columnLabel
- * @param x
- * @param length
- * @throws SQLException
- * @see java.sql.ResultSet#updateAsciiStream(java.lang.String, java.io.InputStream, long)
- */
- protected final void updateAsciiStream(String columnLabel, InputStream x, long length) throws SQLException {
- rs.updateAsciiStream(columnLabel, x, length);
- }
-
- /**
- * @param columnLabel
- * @param x
- * @throws SQLException
- * @see java.sql.ResultSet#updateAsciiStream(java.lang.String, java.io.InputStream)
- */
- protected final void updateAsciiStream(String columnLabel, InputStream x) throws SQLException {
- rs.updateAsciiStream(columnLabel, x);
- }
-
- /**
- * @param columnIndex
- * @param x
- * @throws SQLException
- * @see java.sql.ResultSet#updateBigDecimal(int, java.math.BigDecimal)
- */
- protected final void updateBigDecimal(int columnIndex, BigDecimal x) throws SQLException {
- rs.updateBigDecimal(columnIndex, x);
- }
-
- /**
- * @param columnLabel
- * @param x
- * @throws SQLException
- * @see java.sql.ResultSet#updateBigDecimal(java.lang.String, java.math.BigDecimal)
- */
- protected final void updateBigDecimal(String columnLabel, BigDecimal x) throws SQLException {
- rs.updateBigDecimal(columnLabel, x);
- }
-
- /**
- * @param columnIndex
- * @param x
- * @param length
- * @throws SQLException
- * @see java.sql.ResultSet#updateBinaryStream(int, java.io.InputStream, int)
- */
- protected final void updateBinaryStream(int columnIndex, InputStream x, int length) throws SQLException {
- rs.updateBinaryStream(columnIndex, x, length);
- }
-
- /**
- * @param columnIndex
- * @param x
- * @param length
- * @throws SQLException
- * @see java.sql.ResultSet#updateBinaryStream(int, java.io.InputStream, long)
- */
- protected final void updateBinaryStream(int columnIndex, InputStream x, long length) throws SQLException {
- rs.updateBinaryStream(columnIndex, x, length);
- }
-
- /**
- * @param columnIndex
- * @param x
- * @throws SQLException
- * @see java.sql.ResultSet#updateBinaryStream(int, java.io.InputStream)
- */
- protected final void updateBinaryStream(int columnIndex, InputStream x) throws SQLException {
- rs.updateBinaryStream(columnIndex, x);
- }
-
- /**
- * @param columnLabel
- * @param x
- * @param length
- * @throws SQLException
- * @see java.sql.ResultSet#updateBinaryStream(java.lang.String, java.io.InputStream, int)
- */
- protected final void updateBinaryStream(String columnLabel, InputStream x, int length) throws SQLException {
- rs.updateBinaryStream(columnLabel, x, length);
- }
-
- /**
- * @param columnLabel
- * @param x
- * @param length
- * @throws SQLException
- * @see java.sql.ResultSet#updateBinaryStream(java.lang.String, java.io.InputStream, long)
- */
- protected final void updateBinaryStream(String columnLabel, InputStream x, long length) throws SQLException {
- rs.updateBinaryStream(columnLabel, x, length);
- }
-
- /**
- * @param columnLabel
- * @param x
- * @throws SQLException
- * @see java.sql.ResultSet#updateBinaryStream(java.lang.String, java.io.InputStream)
- */
- protected final void updateBinaryStream(String columnLabel, InputStream x) throws SQLException {
- rs.updateBinaryStream(columnLabel, x);
- }
-
- /**
- * @param columnIndex
- * @param x
- * @throws SQLException
- * @see java.sql.ResultSet#updateBlob(int, java.sql.Blob)
- */
- protected final void updateBlob(int columnIndex, Blob x) throws SQLException {
- rs.updateBlob(columnIndex, x);
- }
-
- /**
- * @param columnIndex
- * @param inputStream
- * @param length
- * @throws SQLException
- * @see java.sql.ResultSet#updateBlob(int, java.io.InputStream, long)
- */
- protected final void updateBlob(int columnIndex, InputStream inputStream, long length) throws SQLException {
- rs.updateBlob(columnIndex, inputStream, length);
- }
-
- /**
- * @param columnIndex
- * @param inputStream
- * @throws SQLException
- * @see java.sql.ResultSet#updateBlob(int, java.io.InputStream)
- */
- protected final void updateBlob(int columnIndex, InputStream inputStream) throws SQLException {
- rs.updateBlob(columnIndex, inputStream);
- }
-
- /**
- * @param columnLabel
- * @param x
- * @throws SQLException
- * @see java.sql.ResultSet#updateBlob(java.lang.String, java.sql.Blob)
- */
- protected final void updateBlob(String columnLabel, Blob x) throws SQLException {
- rs.updateBlob(columnLabel, x);
- }
-
- /**
- * @param columnLabel
- * @param inputStream
- * @param length
- * @throws SQLException
- * @see java.sql.ResultSet#updateBlob(java.lang.String, java.io.InputStream, long)
- */
- protected final void updateBlob(String columnLabel, InputStream inputStream, long length) throws SQLException {
- rs.updateBlob(columnLabel, inputStream, length);
- }
-
- /**
- * @param columnLabel
- * @param inputStream
- * @throws SQLException
- * @see java.sql.ResultSet#updateBlob(java.lang.String, java.io.InputStream)
- */
- protected final void updateBlob(String columnLabel, InputStream inputStream) throws SQLException {
- rs.updateBlob(columnLabel, inputStream);
- }
-
- /**
- * @param columnIndex
- * @param x
- * @throws SQLException
- * @see java.sql.ResultSet#updateBoolean(int, boolean)
- */
- protected final void updateBoolean(int columnIndex, boolean x) throws SQLException {
- rs.updateBoolean(columnIndex, x);
- }
-
- /**
- * @param columnLabel
- * @param x
- * @throws SQLException
- * @see java.sql.ResultSet#updateBoolean(java.lang.String, boolean)
- */
- protected final void updateBoolean(String columnLabel, boolean x) throws SQLException {
- rs.updateBoolean(columnLabel, x);
- }
-
- /**
- * @param columnIndex
- * @param x
- * @throws SQLException
- * @see java.sql.ResultSet#updateByte(int, byte)
- */
- protected final void updateByte(int columnIndex, byte x) throws SQLException {
- rs.updateByte(columnIndex, x);
- }
-
- /**
- * @param columnLabel
- * @param x
- * @throws SQLException
- * @see java.sql.ResultSet#updateByte(java.lang.String, byte)
- */
- protected final void updateByte(String columnLabel, byte x) throws SQLException {
- rs.updateByte(columnLabel, x);
- }
-
- /**
- * @param columnIndex
- * @param x
- * @throws SQLException
- * @see java.sql.ResultSet#updateBytes(int, byte[])
- */
- protected final void updateBytes(int columnIndex, byte[] x) throws SQLException {
- rs.updateBytes(columnIndex, x);
- }
-
- /**
- * @param columnLabel
- * @param x
- * @throws SQLException
- * @see java.sql.ResultSet#updateBytes(java.lang.String, byte[])
- */
- protected final void updateBytes(String columnLabel, byte[] x) throws SQLException {
- rs.updateBytes(columnLabel, x);
- }
-
- /**
- * @param columnIndex
- * @param x
- * @param length
- * @throws SQLException
- * @see java.sql.ResultSet#updateCharacterStream(int, java.io.Reader, int)
- */
- protected final void updateCharacterStream(int columnIndex, Reader x, int length) throws SQLException {
- rs.updateCharacterStream(columnIndex, x, length);
- }
-
- /**
- * @param columnIndex
- * @param x
- * @param length
- * @throws SQLException
- * @see java.sql.ResultSet#updateCharacterStream(int, java.io.Reader, long)
- */
- protected final void updateCharacterStream(int columnIndex, Reader x, long length) throws SQLException {
- rs.updateCharacterStream(columnIndex, x, length);
- }
-
- /**
- * @param columnIndex
- * @param x
- * @throws SQLException
- * @see java.sql.ResultSet#updateCharacterStream(int, java.io.Reader)
- */
- protected final void updateCharacterStream(int columnIndex, Reader x) throws SQLException {
- rs.updateCharacterStream(columnIndex, x);
- }
-
- /**
- * @param columnLabel
- * @param reader
- * @param length
- * @throws SQLException
- * @see java.sql.ResultSet#updateCharacterStream(java.lang.String, java.io.Reader, int)
- */
- protected final void updateCharacterStream(String columnLabel, Reader reader, int length) throws SQLException {
- rs.updateCharacterStream(columnLabel, reader, length);
- }
-
- /**
- * @param columnLabel
- * @param reader
- * @param length
- * @throws SQLException
- * @see java.sql.ResultSet#updateCharacterStream(java.lang.String, java.io.Reader, long)
- */
- protected final void updateCharacterStream(String columnLabel, Reader reader, long length) throws SQLException {
- rs.updateCharacterStream(columnLabel, reader, length);
- }
-
- /**
- * @param columnLabel
- * @param reader
- * @throws SQLException
- * @see java.sql.ResultSet#updateCharacterStream(java.lang.String, java.io.Reader)
- */
- protected final void updateCharacterStream(String columnLabel, Reader reader) throws SQLException {
- rs.updateCharacterStream(columnLabel, reader);
- }
-
- /**
- * @param columnIndex
- * @param x
- * @throws SQLException
- * @see java.sql.ResultSet#updateClob(int, java.sql.Clob)
- */
- protected final void updateClob(int columnIndex, Clob x) throws SQLException {
- rs.updateClob(columnIndex, x);
- }
-
- /**
- * @param columnIndex
- * @param reader
- * @param length
- * @throws SQLException
- * @see java.sql.ResultSet#updateClob(int, java.io.Reader, long)
- */
- protected final void updateClob(int columnIndex, Reader reader, long length) throws SQLException {
- rs.updateClob(columnIndex, reader, length);
- }
-
- /**
- * @param columnIndex
- * @param reader
- * @throws SQLException
- * @see java.sql.ResultSet#updateClob(int, java.io.Reader)
- */
- protected final void updateClob(int columnIndex, Reader reader) throws SQLException {
- rs.updateClob(columnIndex, reader);
- }
-
- /**
- * @param columnLabel
- * @param x
- * @throws SQLException
- * @see java.sql.ResultSet#updateClob(java.lang.String, java.sql.Clob)
- */
- protected final void updateClob(String columnLabel, Clob x) throws SQLException {
- rs.updateClob(columnLabel, x);
- }
-
- /**
- * @param columnLabel
- * @param reader
- * @param length
- * @throws SQLException
- * @see java.sql.ResultSet#updateClob(java.lang.String, java.io.Reader, long)
- */
- protected final void updateClob(String columnLabel, Reader reader, long length) throws SQLException {
- rs.updateClob(columnLabel, reader, length);
- }
-
- /**
- * @param columnLabel
- * @param reader
- * @throws SQLException
- * @see java.sql.ResultSet#updateClob(java.lang.String, java.io.Reader)
- */
- protected final void updateClob(String columnLabel, Reader reader) throws SQLException {
- rs.updateClob(columnLabel, reader);
- }
-
- /**
- * @param columnIndex
- * @param x
- * @throws SQLException
- * @see java.sql.ResultSet#updateDate(int, java.sql.Date)
- */
- protected final void updateDate(int columnIndex, Date x) throws SQLException {
- rs.updateDate(columnIndex, x);
- }
-
- /**
- * @param columnLabel
- * @param x
- * @throws SQLException
- * @see java.sql.ResultSet#updateDate(java.lang.String, java.sql.Date)
- */
- protected final void updateDate(String columnLabel, Date x) throws SQLException {
- rs.updateDate(columnLabel, x);
- }
-
- /**
- * @param columnIndex
- * @param x
- * @throws SQLException
- * @see java.sql.ResultSet#updateDouble(int, double)
- */
- protected final void updateDouble(int columnIndex, double x) throws SQLException {
- rs.updateDouble(columnIndex, x);
- }
-
- /**
- * @param columnLabel
- * @param x
- * @throws SQLException
- * @see java.sql.ResultSet#updateDouble(java.lang.String, double)
- */
- protected final void updateDouble(String columnLabel, double x) throws SQLException {
- rs.updateDouble(columnLabel, x);
- }
-
- /**
- * @param columnIndex
- * @param x
- * @throws SQLException
- * @see java.sql.ResultSet#updateFloat(int, float)
- */
- protected final void updateFloat(int columnIndex, float x) throws SQLException {
- rs.updateFloat(columnIndex, x);
- }
-
- /**
- * @param columnLabel
- * @param x
- * @throws SQLException
- * @see java.sql.ResultSet#updateFloat(java.lang.String, float)
- */
- protected final void updateFloat(String columnLabel, float x) throws SQLException {
- rs.updateFloat(columnLabel, x);
- }
-
- /**
- * @param columnIndex
- * @param x
- * @throws SQLException
- * @see java.sql.ResultSet#updateInt(int, int)
- */
- protected final void updateInt(int columnIndex, int x) throws SQLException {
- rs.updateInt(columnIndex, x);
- }
-
- /**
- * @param columnLabel
- * @param x
- * @throws SQLException
- * @see java.sql.ResultSet#updateInt(java.lang.String, int)
- */
- protected final void updateInt(String columnLabel, int x) throws SQLException {
- rs.updateInt(columnLabel, x);
- }
-
- /**
- * @param columnIndex
- * @param x
- * @throws SQLException
- * @see java.sql.ResultSet#updateLong(int, long)
- */
- protected final void updateLong(int columnIndex, long x) throws SQLException {
- rs.updateLong(columnIndex, x);
- }
-
- /**
- * @param columnLabel
- * @param x
- * @throws SQLException
- * @see java.sql.ResultSet#updateLong(java.lang.String, long)
- */
- protected final void updateLong(String columnLabel, long x) throws SQLException {
- rs.updateLong(columnLabel, x);
- }
-
- /**
- * @param columnIndex
- * @param x
- * @param length
- * @throws SQLException
- * @see java.sql.ResultSet#updateNCharacterStream(int, java.io.Reader, long)
- */
- protected final void updateNCharacterStream(int columnIndex, Reader x, long length) throws SQLException {
- rs.updateNCharacterStream(columnIndex, x, length);
- }
-
- /**
- * @param columnIndex
- * @param x
- * @throws SQLException
- * @see java.sql.ResultSet#updateNCharacterStream(int, java.io.Reader)
- */
- protected final void updateNCharacterStream(int columnIndex, Reader x) throws SQLException {
- rs.updateNCharacterStream(columnIndex, x);
- }
-
- /**
- * @param columnLabel
- * @param reader
- * @param length
- * @throws SQLException
- * @see java.sql.ResultSet#updateNCharacterStream(java.lang.String, java.io.Reader, long)
- */
- protected final void updateNCharacterStream(String columnLabel, Reader reader, long length) throws SQLException {
- rs.updateNCharacterStream(columnLabel, reader, length);
- }
-
- /**
- * @param columnLabel
- * @param reader
- * @throws SQLException
- * @see java.sql.ResultSet#updateNCharacterStream(java.lang.String, java.io.Reader)
- */
- protected final void updateNCharacterStream(String columnLabel, Reader reader) throws SQLException {
- rs.updateNCharacterStream(columnLabel, reader);
- }
-
- /**
- * @param columnIndex
- * @param nClob
- * @throws SQLException
- * @see java.sql.ResultSet#updateNClob(int, java.sql.NClob)
- */
- protected final void updateNClob(int columnIndex, NClob nClob) throws SQLException {
- rs.updateNClob(columnIndex, nClob);
- }
-
- /**
- * @param columnIndex
- * @param reader
- * @param length
- * @throws SQLException
- * @see java.sql.ResultSet#updateNClob(int, java.io.Reader, long)
- */
- protected final void updateNClob(int columnIndex, Reader reader, long length) throws SQLException {
- rs.updateNClob(columnIndex, reader, length);
- }
-
- /**
- * @param columnIndex
- * @param reader
- * @throws SQLException
- * @see java.sql.ResultSet#updateNClob(int, java.io.Reader)
- */
- protected final void updateNClob(int columnIndex, Reader reader) throws SQLException {
- rs.updateNClob(columnIndex, reader);
- }
-
- /**
- * @param columnLabel
- * @param nClob
- * @throws SQLException
- * @see java.sql.ResultSet#updateNClob(java.lang.String, java.sql.NClob)
- */
- protected final void updateNClob(String columnLabel, NClob nClob) throws SQLException {
- rs.updateNClob(columnLabel, nClob);
- }
-
- /**
- * @param columnLabel
- * @param reader
- * @param length
- * @throws SQLException
- * @see java.sql.ResultSet#updateNClob(java.lang.String, java.io.Reader, long)
- */
- protected final void updateNClob(String columnLabel, Reader reader, long length) throws SQLException {
- rs.updateNClob(columnLabel, reader, length);
- }
-
- /**
- * @param columnLabel
- * @param reader
- * @throws SQLException
- * @see java.sql.ResultSet#updateNClob(java.lang.String, java.io.Reader)
- */
- protected final void updateNClob(String columnLabel, Reader reader) throws SQLException {
- rs.updateNClob(columnLabel, reader);
- }
-
- /**
- * @param columnIndex
- * @param nString
- * @throws SQLException
- * @see java.sql.ResultSet#updateNString(int, java.lang.String)
- */
- protected final void updateNString(int columnIndex, String nString) throws SQLException {
- rs.updateNString(columnIndex, nString);
- }
-
- /**
- * @param columnLabel
- * @param nString
- * @throws SQLException
- * @see java.sql.ResultSet#updateNString(java.lang.String, java.lang.String)
- */
- protected final void updateNString(String columnLabel, String nString) throws SQLException {
- rs.updateNString(columnLabel, nString);
- }
-
- /**
- * @param columnIndex
- * @throws SQLException
- * @see java.sql.ResultSet#updateNull(int)
- */
- protected final void updateNull(int columnIndex) throws SQLException {
- rs.updateNull(columnIndex);
- }
-
- /**
- * @param columnLabel
- * @throws SQLException
- * @see java.sql.ResultSet#updateNull(java.lang.String)
- */
- protected final void updateNull(String columnLabel) throws SQLException {
- rs.updateNull(columnLabel);
- }
-
- /**
- * @param columnIndex
- * @param x
- * @param scaleOrLength
- * @throws SQLException
- * @see java.sql.ResultSet#updateObject(int, java.lang.Object, int)
- */
- protected final void updateObject(int columnIndex, Object x, int scaleOrLength) throws SQLException {
- rs.updateObject(columnIndex, x, scaleOrLength);
- }
-
- /**
- * @param columnIndex
- * @param x
- * @throws SQLException
- * @see java.sql.ResultSet#updateObject(int, java.lang.Object)
- */
- protected final void updateObject(int columnIndex, Object x) throws SQLException {
- rs.updateObject(columnIndex, x);
- }
-
- /**
- * @param columnLabel
- * @param x
- * @param scaleOrLength
- * @throws SQLException
- * @see java.sql.ResultSet#updateObject(java.lang.String, java.lang.Object, int)
- */
- protected final void updateObject(String columnLabel, Object x, int scaleOrLength) throws SQLException {
- rs.updateObject(columnLabel, x, scaleOrLength);
- }
-
- /**
- * @param columnLabel
- * @param x
- * @throws SQLException
- * @see java.sql.ResultSet#updateObject(java.lang.String, java.lang.Object)
- */
- protected final void updateObject(String columnLabel, Object x) throws SQLException {
- rs.updateObject(columnLabel, x);
- }
-
- /**
- * @param columnIndex
- * @param x
- * @throws SQLException
- * @see java.sql.ResultSet#updateRef(int, java.sql.Ref)
- */
- protected final void updateRef(int columnIndex, Ref x) throws SQLException {
- rs.updateRef(columnIndex, x);
- }
-
- /**
- * @param columnLabel
- * @param x
- * @throws SQLException
- * @see java.sql.ResultSet#updateRef(java.lang.String, java.sql.Ref)
- */
- protected final void updateRef(String columnLabel, Ref x) throws SQLException {
- rs.updateRef(columnLabel, x);
- }
-
- /**
- * @throws SQLException
- * @see java.sql.ResultSet#updateRow()
- */
- protected final void updateRow() throws SQLException {
- rs.updateRow();
- }
-
- /**
- * @param columnIndex
- * @param x
- * @throws SQLException
- * @see java.sql.ResultSet#updateRowId(int, java.sql.RowId)
- */
- protected final void updateRowId(int columnIndex, RowId x) throws SQLException {
- rs.updateRowId(columnIndex, x);
- }
-
- /**
- * @param columnLabel
- * @param x
- * @throws SQLException
- * @see java.sql.ResultSet#updateRowId(java.lang.String, java.sql.RowId)
- */
- protected final void updateRowId(String columnLabel, RowId x) throws SQLException {
- rs.updateRowId(columnLabel, x);
- }
-
- /**
- * @param columnIndex
- * @param xmlObject
- * @throws SQLException
- * @see java.sql.ResultSet#updateSQLXML(int, java.sql.SQLXML)
- */
- protected final void updateSQLXML(int columnIndex, SQLXML xmlObject) throws SQLException {
- rs.updateSQLXML(columnIndex, xmlObject);
- }
-
- /**
- * @param columnLabel
- * @param xmlObject
- * @throws SQLException
- * @see java.sql.ResultSet#updateSQLXML(java.lang.String, java.sql.SQLXML)
- */
- protected final void updateSQLXML(String columnLabel, SQLXML xmlObject) throws SQLException {
- rs.updateSQLXML(columnLabel, xmlObject);
- }
-
- /**
- * @param columnIndex
- * @param x
- * @throws SQLException
- * @see java.sql.ResultSet#updateShort(int, short)
- */
- protected final void updateShort(int columnIndex, short x) throws SQLException {
- rs.updateShort(columnIndex, x);
- }
-
- /**
- * @param columnLabel
- * @param x
- * @throws SQLException
- * @see java.sql.ResultSet#updateShort(java.lang.String, short)
- */
- protected final void updateShort(String columnLabel, short x) throws SQLException {
- rs.updateShort(columnLabel, x);
- }
-
- /**
- * @param columnIndex
- * @param x
- * @throws SQLException
- * @see java.sql.ResultSet#updateString(int, java.lang.String)
- */
- protected final void updateString(int columnIndex, String x) throws SQLException {
- rs.updateString(columnIndex, x);
- }
-
- /**
- * @param columnLabel
- * @param x
- * @throws SQLException
- * @see java.sql.ResultSet#updateString(java.lang.String, java.lang.String)
- */
- protected final void updateString(String columnLabel, String x) throws SQLException {
- rs.updateString(columnLabel, x);
- }
-
- /**
- * @param columnIndex
- * @param x
- * @throws SQLException
- * @see java.sql.ResultSet#updateTime(int, java.sql.Time)
- */
- protected final void updateTime(int columnIndex, Time x) throws SQLException {
- rs.updateTime(columnIndex, x);
- }
-
- /**
- * @param columnLabel
- * @param x
- * @throws SQLException
- * @see java.sql.ResultSet#updateTime(java.lang.String, java.sql.Time)
- */
- protected final void updateTime(String columnLabel, Time x) throws SQLException {
- rs.updateTime(columnLabel, x);
- }
-
- /**
- * @param columnIndex
- * @param x
- * @throws SQLException
- * @see java.sql.ResultSet#updateTimestamp(int, java.sql.Timestamp)
- */
- protected final void updateTimestamp(int columnIndex, Timestamp x) throws SQLException {
- rs.updateTimestamp(columnIndex, x);
- }
-
- /**
- * @param columnLabel
- * @param x
- * @throws SQLException
- * @see java.sql.ResultSet#updateTimestamp(java.lang.String, java.sql.Timestamp)
- */
- protected final void updateTimestamp(String columnLabel, Timestamp x) throws SQLException {
- rs.updateTimestamp(columnLabel, x);
- }
-
- /**
- * @return
- * @throws SQLException
- * @see java.sql.ResultSet#wasNull()
- */
- protected final boolean wasNull() throws SQLException {
- return rs.wasNull();
- }
-
- protected final ResultSet getAdaptedResultSet() {
- return rs;
- }
-
-}
\ No newline at end of file
[17/58] [abbrv] commons-dbutils git commit: Javadoc errors
Posted by th...@apache.org.
Javadoc errors
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/dbutils/branches/2_0@1457559 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/commons-dbutils/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-dbutils/commit/ac37a340
Tree: http://git-wip-us.apache.org/repos/asf/commons-dbutils/tree/ac37a340
Diff: http://git-wip-us.apache.org/repos/asf/commons-dbutils/diff/ac37a340
Branch: refs/heads/2_0
Commit: ac37a3406daa7366b8545ffacb786656fe3e631f
Parents: 9319b07
Author: Sebastian Bazley <se...@apache.org>
Authored: Sun Mar 17 20:46:46 2013 +0000
Committer: Sebastian Bazley <se...@apache.org>
Committed: Sun Mar 17 20:46:46 2013 +0000
----------------------------------------------------------------------
src/main/java/org/apache/commons/dbutils2/BatchExecutor.java | 6 +++---
src/main/java/org/apache/commons/dbutils2/QueryExecutor.java | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/ac37a340/src/main/java/org/apache/commons/dbutils2/BatchExecutor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/BatchExecutor.java b/src/main/java/org/apache/commons/dbutils2/BatchExecutor.java
index 934c00b..64f1679 100644
--- a/src/main/java/org/apache/commons/dbutils2/BatchExecutor.java
+++ b/src/main/java/org/apache/commons/dbutils2/BatchExecutor.java
@@ -50,7 +50,7 @@ public class BatchExecutor extends AbstractExecutor<BatchExecutor> {
* @param value the value to bind to the parameter.
* @return this object.
* @throws SQLException thrown if the statement number does not exist, or any other SQLException.
- * @see org.apache.commons.dbutils.UpdateExecutor.bind(String, Object)
+ * @see org.apache.commons.dbutils2.UpdateExecutor#bind(String, Object)
*/
@Override
public BatchExecutor bind(final String name, final Object value) throws SQLException {
@@ -86,7 +86,7 @@ public class BatchExecutor extends AbstractExecutor<BatchExecutor> {
* Adds the statement to the batch after binding all of the parameters.
* @return this object.
* @throws SQLException if a SQLException is thrown during the addBatch() call.
- * @see java.sql.PreparedStatement.addBatch()
+ * @see java.sql.PreparedStatement#addBatch()
*/
public BatchExecutor addBatch() throws SQLException {
try {
@@ -103,7 +103,7 @@ public class BatchExecutor extends AbstractExecutor<BatchExecutor> {
* Calls batch after checking the parameters to ensure nothing is null.
* @return an array containing the number of rows updated for each statement.
* @throws SQLException If there are database or parameter errors.
- * @see org.apache.commons.dbutils.UpdateExecutor.update()
+ * @see org.apache.commons.dbutils2.UpdateExecutor#execute()
*/
public int[] execute() throws SQLException {
try {
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/ac37a340/src/main/java/org/apache/commons/dbutils2/QueryExecutor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/QueryExecutor.java b/src/main/java/org/apache/commons/dbutils2/QueryExecutor.java
index de55919..11bd8aa 100644
--- a/src/main/java/org/apache/commons/dbutils2/QueryExecutor.java
+++ b/src/main/java/org/apache/commons/dbutils2/QueryExecutor.java
@@ -45,7 +45,7 @@ class QueryExecutor extends AbstractExecutor<QueryExecutor> {
/**
* Calls query after checking the parameters to ensure nothing is null.
*
- * @param rsh The handler that converts the results into an object.
+ * @param handler The handler that converts the results into an object.
*
* @return The results of the query.
* @throws SQLException If there are database or parameter errors.
[03/58] [abbrv] commons-dbutils git commit: Changed the package names
so dbutils and dbutils2 won't conflict if both loaded
Posted by th...@apache.org.
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/test/java/org/apache/commons/dbutils/handlers/KeyedHandlerTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils/handlers/KeyedHandlerTest.java b/src/test/java/org/apache/commons/dbutils/handlers/KeyedHandlerTest.java
deleted file mode 100644
index e259e42..0000000
--- a/src/test/java/org/apache/commons/dbutils/handlers/KeyedHandlerTest.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.dbutils.handlers;
-
-import java.sql.SQLException;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import org.apache.commons.dbutils.BaseTestCase;
-import org.apache.commons.dbutils.ResultSetHandler;
-
-public class KeyedHandlerTest extends BaseTestCase {
-
- public void testHandle() throws SQLException {
- ResultSetHandler<Map<String,Map<String,Object>>> h = new KeyedHandler<String>();
-
- Map<String,Map<String,Object>> results = h.handle(this.rs);
-
- assertNotNull(results);
- assertEquals(ROWS, results.size());
-
- Map<String,Object> row = null;
- for(Entry<String, Map<String, Object>> entry : results.entrySet())
- {
- Object key = entry.getKey();
- assertNotNull(key);
- row = entry.getValue();
- assertNotNull(row);
- assertEquals(COLS, row.keySet().size());
- }
- row = results.get("1");
- assertEquals("1", row.get("one"));
- assertEquals("2", row.get("TWO"));
- assertEquals("3", row.get("Three"));
- }
-
- public void testColumnIndexHandle() throws SQLException {
- ResultSetHandler<Map<String,Map<String,Object>>> h = new KeyedHandler<String>(2);
- Map<String,Map<String,Object>> results = h.handle(this.rs);
-
- assertNotNull(results);
- assertEquals(ROWS, results.size());
-
- Map<String,Object> row = null;
- for(Entry<String, Map<String, Object>> entry : results.entrySet())
- {
- Object key = entry.getKey();
- assertNotNull(key);
- row = entry.getValue();
- assertNotNull(row);
- assertEquals(COLS, row.keySet().size());
- }
- row = results.get("5");
- assertEquals("4", row.get("one"));
- assertEquals("5", row.get("TWO"));
- assertEquals("6", row.get("Three"));
- }
-
- public void testColumnNameHandle() throws SQLException {
- ResultSetHandler<Map<Integer,Map<String,Object>>> h = new KeyedHandler<Integer>("intTest");
- Map<Integer,Map<String,Object>> results = h.handle(this.rs);
-
- assertNotNull(results);
- assertEquals(ROWS, results.size());
-
- Map<String,Object> row = null;
- for(Entry<Integer, Map<String, Object>> entry : results.entrySet())
- {
- Object key = entry.getKey();
- assertNotNull(key);
- row = entry.getValue();
- assertNotNull(row);
- assertEquals(COLS, row.keySet().size());
- }
- row = results.get(Integer.valueOf(3));
- assertEquals("4", row.get("one"));
- assertEquals("5", row.get("TWO"));
- assertEquals("6", row.get("Three"));
- }
-
- public void testEmptyResultSetHandle() throws SQLException {
- ResultSetHandler<Map<String,Map<String,Object>>> h = new KeyedHandler<String>();
- Map<String,Map<String,Object>> results = h.handle(this.emptyResultSet);
- assertNotNull(results);
- assertTrue(results.isEmpty());
- }
-}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/test/java/org/apache/commons/dbutils/handlers/MapHandlerTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils/handlers/MapHandlerTest.java b/src/test/java/org/apache/commons/dbutils/handlers/MapHandlerTest.java
deleted file mode 100644
index 741e035..0000000
--- a/src/test/java/org/apache/commons/dbutils/handlers/MapHandlerTest.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.dbutils.handlers;
-
-import java.sql.SQLException;
-import java.util.Map;
-
-import org.apache.commons.dbutils.BaseTestCase;
-import org.apache.commons.dbutils.ResultSetHandler;
-
-/**
- * MapHandlerTest
- */
-public class MapHandlerTest extends BaseTestCase {
-
- public void testHandle() throws SQLException {
- ResultSetHandler<Map<String,Object>> h = new MapHandler();
- Map<String,Object> results = h.handle(this.rs);
-
- assertNotNull(results);
- assertEquals(COLS, results.keySet().size());
- assertEquals("1", results.get("ONE"));
- assertEquals("2", results.get("two"));
- assertEquals("3", results.get("Three"));
- }
-
- public void testEmptyResultSetHandle() throws SQLException {
- ResultSetHandler<Map<String,Object>> h = new MapHandler();
- Map<String,Object> results = h.handle(this.emptyResultSet);
-
- assertNull(results);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/test/java/org/apache/commons/dbutils/handlers/MapListHandlerTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils/handlers/MapListHandlerTest.java b/src/test/java/org/apache/commons/dbutils/handlers/MapListHandlerTest.java
deleted file mode 100644
index 275a591..0000000
--- a/src/test/java/org/apache/commons/dbutils/handlers/MapListHandlerTest.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.dbutils.handlers;
-
-import java.sql.SQLException;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.commons.dbutils.BaseTestCase;
-import org.apache.commons.dbutils.ResultSetHandler;
-
-/**
- * MapListHandlerTest
- */
-public class MapListHandlerTest extends BaseTestCase {
-
- public void testHandle() throws SQLException {
- ResultSetHandler<List<Map<String,Object>>> h = new MapListHandler();
- List<Map<String,Object>> results = h.handle(this.rs);
-
- assertNotNull(results);
- assertEquals(ROWS, results.size());
-
- Iterator<Map<String,Object>> iter = results.iterator();
- Map<String,Object> row = null;
- assertTrue(iter.hasNext());
- row = iter.next();
- assertEquals(COLS, row.keySet().size());
- assertEquals("1", row.get("one"));
- assertEquals("2", row.get("TWO"));
- assertEquals("3", row.get("Three"));
-
- assertTrue(iter.hasNext());
- row = iter.next();
- assertEquals(COLS, row.keySet().size());
-
- assertEquals("4", row.get("one"));
- assertEquals("5", row.get("TWO"));
- assertEquals("6", row.get("Three"));
-
- assertFalse(iter.hasNext());
- }
-
- public void testEmptyResultSetHandle() throws SQLException {
- ResultSetHandler<List<Map<String,Object>>> h = new MapListHandler();
- List<Map<String,Object>> results = h.handle(this.emptyResultSet);
-
- assertNotNull(results);
- assertTrue(results.isEmpty());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/test/java/org/apache/commons/dbutils/handlers/ScalarHandlerTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils/handlers/ScalarHandlerTest.java b/src/test/java/org/apache/commons/dbutils/handlers/ScalarHandlerTest.java
deleted file mode 100644
index afebdbd..0000000
--- a/src/test/java/org/apache/commons/dbutils/handlers/ScalarHandlerTest.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.dbutils.handlers;
-
-import java.sql.SQLException;
-
-import org.apache.commons.dbutils.BaseTestCase;
-import org.apache.commons.dbutils.ResultSetHandler;
-
-public class ScalarHandlerTest extends BaseTestCase {
-
- public void testHandle() throws SQLException {
- ResultSetHandler<String> h = new ScalarHandler<String>();
- Object results = h.handle(this.rs);
- assertNotNull(results);
- assertEquals("1", results);
- }
-
- public void testColumnIndexHandle() throws SQLException {
- ResultSetHandler<String> h = new ScalarHandler<String>(2);
- Object results = h.handle(this.rs);
- assertNotNull(results);
- assertEquals("2", results);
- }
-
- public void testColumnNameHandle() throws SQLException {
- ResultSetHandler<Integer> h = new ScalarHandler<Integer>("intTest");
- Object results = h.handle(this.rs);
- assertNotNull(results);
- assertEquals(Integer.valueOf(1), results);
- }
-
- public void testEmptyResultSetHandle() throws SQLException {
- ResultSetHandler<String> h = new ScalarHandler<String>();
- Object results = h.handle(this.emptyResultSet);
- assertNull(results);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/test/java/org/apache/commons/dbutils/wrappers/SqlNullCheckedResultSetTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils/wrappers/SqlNullCheckedResultSetTest.java b/src/test/java/org/apache/commons/dbutils/wrappers/SqlNullCheckedResultSetTest.java
deleted file mode 100644
index e40f8b7..0000000
--- a/src/test/java/org/apache/commons/dbutils/wrappers/SqlNullCheckedResultSetTest.java
+++ /dev/null
@@ -1,1020 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.dbutils.wrappers;
-
-import java.io.ByteArrayInputStream;
-import java.io.CharArrayReader;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.Reader;
-import java.io.Writer;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.math.BigDecimal;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.sql.Blob;
-import java.sql.Clob;
-import java.sql.Ref;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Time;
-import java.sql.Timestamp;
-import java.util.Arrays;
-import java.util.Calendar;
-import java.util.Map;
-
-import org.apache.commons.dbutils.BaseTestCase;
-import org.apache.commons.dbutils.ProxyFactory;
-
-/**
- * Test cases for <code>SqlNullCheckedResultSet</code> class.
- */
-public class SqlNullCheckedResultSetTest extends BaseTestCase {
-
- private SqlNullCheckedResultSet rs2 = null;
-
- /**
- * Sets up instance variables required by this test case.
- */
- @Override
- public void setUp() throws Exception {
- super.setUp();
-
- rs2 =
- new SqlNullCheckedResultSet(
- ProxyFactory.instance().createResultSet(
- new SqlNullUncheckedMockResultSet()));
-
- rs = ProxyFactory.instance().createResultSet(rs2); // Override superclass field
- }
-
- /**
- * Tests the getAsciiStream implementation.
- */
- public void testGetAsciiStream() throws SQLException {
-
- assertNull(rs.getAsciiStream(1));
- assertTrue(rs.wasNull());
- assertNull(rs.getAsciiStream("column"));
- assertTrue(rs.wasNull());
- // Set what gets returned to something other than the default
- InputStream stream = new ByteArrayInputStream(new byte[0]);
- rs2.setNullAsciiStream(stream);
- assertNotNull(rs.getAsciiStream(1));
- assertEquals(stream, rs.getAsciiStream(1));
- assertNotNull(rs.getAsciiStream("column"));
- assertEquals(stream, rs.getAsciiStream("column"));
-
- }
-
- /**
- * Tests the getBigDecimal implementation.
- */
- public void testGetBigDecimal() throws SQLException {
-
- assertNull(rs.getBigDecimal(1));
- assertTrue(rs.wasNull());
- assertNull(rs.getBigDecimal("column"));
- assertTrue(rs.wasNull());
- // Set what gets returned to something other than the default
- BigDecimal bd = new BigDecimal(5.0);
- rs2.setNullBigDecimal(bd);
- assertNotNull(rs.getBigDecimal(1));
- assertEquals(bd, rs.getBigDecimal(1));
- assertNotNull(rs.getBigDecimal("column"));
- assertEquals(bd, rs.getBigDecimal("column"));
-
- }
-
- /**
- * Tests the getBinaryStream implementation.
- */
- public void testGetBinaryStream() throws SQLException {
-
- assertNull(rs.getBinaryStream(1));
- assertTrue(rs.wasNull());
- assertNull(rs.getBinaryStream("column"));
- assertTrue(rs.wasNull());
- // Set what gets returned to something other than the default
- InputStream stream = new ByteArrayInputStream(new byte[0]);
- rs2.setNullBinaryStream(stream);
- assertNotNull(rs.getBinaryStream(1));
- assertEquals(stream, rs.getBinaryStream(1));
- assertNotNull(rs.getBinaryStream("column"));
- assertEquals(stream, rs.getBinaryStream("column"));
-
- }
-
- /**
- * Tests the getBlob implementation.
- */
- public void testGetBlob() throws SQLException {
-
- assertNull(rs.getBlob(1));
- assertTrue(rs.wasNull());
- assertNull(rs.getBlob("column"));
- assertTrue(rs.wasNull());
- // Set what gets returned to something other than the default
- Blob blob = new SqlNullCheckedResultSetMockBlob();
- rs2.setNullBlob(blob);
- assertNotNull(rs.getBlob(1));
- assertEquals(blob, rs.getBlob(1));
- assertNotNull(rs.getBlob("column"));
- assertEquals(blob, rs.getBlob("column"));
-
- }
-
- /**
- * Tests the getBoolean implementation.
- */
- public void testGetBoolean() throws SQLException {
-
- assertEquals(false, rs.getBoolean(1));
- assertTrue(rs.wasNull());
- assertEquals(false, rs.getBoolean("column"));
- assertTrue(rs.wasNull());
- // Set what gets returned to something other than the default
- rs2.setNullBoolean(true);
- assertEquals(true, rs.getBoolean(1));
- assertEquals(true, rs.getBoolean("column"));
-
- }
-
- /**
- * Tests the getByte implementation.
- */
- public void testGetByte() throws SQLException {
-
- assertEquals((byte) 0, rs.getByte(1));
- assertTrue(rs.wasNull());
- assertEquals((byte) 0, rs.getByte("column"));
- assertTrue(rs.wasNull());
- // Set what gets returned to something other than the default
- byte b = (byte) 10;
- rs2.setNullByte(b);
- assertEquals(b, rs.getByte(1));
- assertEquals(b, rs.getByte("column"));
-
- }
-
- /**
- * Tests the getByte implementation.
- */
- public void testGetBytes() throws SQLException {
-
- assertNull(rs.getBytes(1));
- assertTrue(rs.wasNull());
- assertNull(rs.getBytes("column"));
- assertTrue(rs.wasNull());
- // Set what gets returned to something other than the default
- byte[] b = new byte[5];
- for (int i = 0; i < 5; i++) {
- b[0] = (byte) i;
- }
- rs2.setNullBytes(b);
- assertNotNull(rs.getBytes(1));
- assertArrayEquals(b, rs.getBytes(1));
- assertNotNull(rs.getBytes("column"));
- assertArrayEquals(b, rs.getBytes("column"));
-
- }
-
- private static void assertArrayEquals(byte[] expected, byte[] actual) {
- if (expected == actual) return;
- if (expected.length != actual.length) {
- failNotEquals(null, Arrays.toString(expected), Arrays.toString(actual));
- }
- for (int i = 0; i < expected.length; i++) {
- byte expectedItem = expected[i];
- byte actualItem = actual[i];
- assertEquals("Array not equal at index " + i, expectedItem, actualItem);
- }
- }
-
- /**
- * Tests the getCharacterStream implementation.
- */
- public void testGetCharacterStream() throws SQLException {
-
- assertNull(rs.getCharacterStream(1));
- assertTrue(rs.wasNull());
- assertNull(rs.getCharacterStream("column"));
- assertTrue(rs.wasNull());
- // Set what gets returned to something other than the default
- Reader reader = new CharArrayReader("this is a string".toCharArray());
- rs2.setNullCharacterStream(reader);
- assertNotNull(rs.getCharacterStream(1));
- assertEquals(reader, rs.getCharacterStream(1));
- assertNotNull(rs.getCharacterStream("column"));
- assertEquals(reader, rs.getCharacterStream("column"));
-
- }
-
- /**
- * Tests the getClob implementation.
- */
- public void testGetClob() throws SQLException {
-
- assertNull(rs.getClob(1));
- assertTrue(rs.wasNull());
- assertNull(rs.getClob("column"));
- assertTrue(rs.wasNull());
- // Set what gets returned to something other than the default
- Clob clob = new SqlNullCheckedResultSetMockClob();
- rs2.setNullClob(clob);
- assertNotNull(rs.getClob(1));
- assertEquals(clob, rs.getClob(1));
- assertNotNull(rs.getClob("column"));
- assertEquals(clob, rs.getClob("column"));
-
- }
-
- /**
- * Tests the getDate implementation.
- */
- public void testGetDate() throws SQLException {
-
- assertNull(rs.getDate(1));
- assertTrue(rs.wasNull());
- assertNull(rs.getDate("column"));
- assertTrue(rs.wasNull());
- assertNull(rs.getDate(1, Calendar.getInstance()));
- assertTrue(rs.wasNull());
- assertNull(rs.getDate("column", Calendar.getInstance()));
- assertTrue(rs.wasNull());
- // Set what gets returned to something other than the default
- java.sql.Date date = new java.sql.Date(new java.util.Date().getTime());
- rs2.setNullDate(date);
- assertNotNull(rs.getDate(1));
- assertEquals(date, rs.getDate(1));
- assertNotNull(rs.getDate("column"));
- assertEquals(date, rs.getDate("column"));
- assertNotNull(rs.getDate(1, Calendar.getInstance()));
- assertEquals(date, rs.getDate(1, Calendar.getInstance()));
- assertNotNull(rs.getDate("column", Calendar.getInstance()));
- assertEquals(date, rs.getDate("column", Calendar.getInstance()));
-
- }
-
- /**
- * Tests the getDouble implementation.
- */
- public void testGetDouble() throws SQLException {
-
- assertEquals(0.0, rs.getDouble(1), 0.0);
- assertTrue(rs.wasNull());
- assertEquals(0.0, rs.getDouble("column"), 0.0);
- assertTrue(rs.wasNull());
- // Set what gets returned to something other than the default
- double d = 10.0;
- rs2.setNullDouble(d);
- assertEquals(d, rs.getDouble(1), 0.0);
- assertEquals(d, rs.getDouble("column"), 0.0);
-
- }
-
- /**
- * Tests the getFloat implementation.
- */
- public void testGetFloat() throws SQLException {
- assertEquals(0, rs.getFloat(1), 0.0);
- assertTrue(rs.wasNull());
- assertEquals(0, rs.getFloat("column"), 0.0);
- assertTrue(rs.wasNull());
- // Set what gets returned to something other than the default
- float f = 10;
- rs2.setNullFloat(f);
- assertEquals(f, rs.getFloat(1), 0.0);
- assertEquals(f, rs.getFloat("column"), 0.0);
- }
-
- /**
- * Tests the getInt implementation.
- */
- public void testGetInt() throws SQLException {
- assertEquals(0, rs.getInt(1));
- assertTrue(rs.wasNull());
- assertEquals(0, rs.getInt("column"));
- assertTrue(rs.wasNull());
- // Set what gets returned to something other than the default
- int i = 10;
- rs2.setNullInt(i);
- assertEquals(i, rs.getInt(1));
- assertEquals(i, rs.getInt("column"));
- }
-
- /**
- * Tests the getLong implementation.
- */
- public void testGetLong() throws SQLException {
- assertEquals(0, rs.getLong(1));
- assertTrue(rs.wasNull());
- assertEquals(0, rs.getLong("column"));
- assertTrue(rs.wasNull());
- // Set what gets returned to something other than the default
- long l = 10;
- rs2.setNullLong(l);
- assertEquals(l, rs.getLong(1));
- assertEquals(l, rs.getLong("column"));
- }
-
- /**
- * Tests the getObject implementation.
- */
- public void testGetObject() throws SQLException {
-
- assertNull(rs.getObject(1));
- assertTrue(rs.wasNull());
- assertNull(rs.getObject("column"));
- assertTrue(rs.wasNull());
- assertNull(rs.getObject(1, (Map<String, Class<?>>) null));
- assertTrue(rs.wasNull());
- assertNull(rs.getObject("column", (Map<String, Class<?>>) null));
- assertTrue(rs.wasNull());
- // Set what gets returned to something other than the default
- Object o = new Object();
- rs2.setNullObject(o);
- assertNotNull(rs.getObject(1));
- assertEquals(o, rs.getObject(1));
- assertNotNull(rs.getObject("column"));
- assertEquals(o, rs.getObject("column"));
- assertNotNull(rs.getObject(1, (Map<String, Class<?>>) null));
- assertEquals(o, rs.getObject(1, (Map<String, Class<?>>) null));
- assertNotNull(rs.getObject("column", (Map<String, Class<?>>) null));
- assertEquals(o, rs.getObject("column", (Map<String, Class<?>>) null));
-
- }
-
- /**
- * Tests the getRef implementation.
- */
- public void testGetRef() throws SQLException {
-
- assertNull(rs.getRef(1));
- assertTrue(rs.wasNull());
- assertNull(rs.getRef("column"));
- assertTrue(rs.wasNull());
- // Set what gets returned to something other than the default
- Ref ref = new SqlNullCheckedResultSetMockRef();
- rs2.setNullRef(ref);
- assertNotNull(rs.getRef(1));
- assertEquals(ref, rs.getRef(1));
- assertNotNull(rs.getRef("column"));
- assertEquals(ref, rs.getRef("column"));
-
- }
-
- /**
- * Tests the getShort implementation.
- */
- public void testGetShort() throws SQLException {
-
- assertEquals((short) 0, rs.getShort(1));
- assertTrue(rs.wasNull());
- assertEquals((short) 0, rs.getShort("column"));
- assertTrue(rs.wasNull());
- // Set what gets returned to something other than the default
- short s = (short) 10;
- rs2.setNullShort(s);
- assertEquals(s, rs.getShort(1));
- assertEquals(s, rs.getShort("column"));
- }
-
- /**
- * Tests the getString implementation.
- */
- public void testGetString() throws SQLException {
- assertEquals(null, rs.getString(1));
- assertTrue(rs.wasNull());
- assertEquals(null, rs.getString("column"));
- assertTrue(rs.wasNull());
- // Set what gets returned to something other than the default
- String s = "hello, world";
- rs2.setNullString(s);
- assertEquals(s, rs.getString(1));
- assertEquals(s, rs.getString("column"));
- }
-
- /**
- * Tests the getTime implementation.
- */
- public void testGetTime() throws SQLException {
-
- assertNull(rs.getTime(1));
- assertTrue(rs.wasNull());
- assertNull(rs.getTime("column"));
- assertTrue(rs.wasNull());
- assertNull(rs.getTime(1, Calendar.getInstance()));
- assertTrue(rs.wasNull());
- assertNull(rs.getTime("column", Calendar.getInstance()));
- assertTrue(rs.wasNull());
- // Set what gets returned to something other than the default
- Time time = new Time(new java.util.Date().getTime());
- rs2.setNullTime(time);
- assertNotNull(rs.getTime(1));
- assertEquals(time, rs.getTime(1));
- assertNotNull(rs.getTime("column"));
- assertEquals(time, rs.getTime("column"));
- assertNotNull(rs.getTime(1, Calendar.getInstance()));
- assertEquals(time, rs.getTime(1, Calendar.getInstance()));
- assertNotNull(rs.getTime("column", Calendar.getInstance()));
- assertEquals(time, rs.getTime("column", Calendar.getInstance()));
-
- }
-
- /**
- * Tests the getTimestamp implementation.
- */
- public void testGetTimestamp() throws SQLException {
-
- assertNull(rs.getTimestamp(1));
- assertTrue(rs.wasNull());
- assertNull(rs.getTimestamp("column"));
- assertTrue(rs.wasNull());
- assertNull(rs.getTimestamp(1, Calendar.getInstance()));
- assertTrue(rs.wasNull());
- assertNull(rs.getTimestamp("column", Calendar.getInstance()));
- assertTrue(rs.wasNull());
- // Set what gets returned to something other than the default
- Timestamp ts = new Timestamp(new java.util.Date().getTime());
- rs2.setNullTimestamp(ts);
- assertNotNull(rs.getTimestamp(1));
- assertEquals(ts, rs.getTimestamp(1));
- assertNotNull(rs.getTimestamp("column"));
- assertEquals(ts, rs.getTimestamp("column"));
- assertNotNull(rs.getTimestamp(1, Calendar.getInstance()));
- assertEquals(ts, rs.getTimestamp(1, Calendar.getInstance()));
- assertNotNull(rs.getTimestamp("column", Calendar.getInstance()));
- assertEquals(ts, rs.getTimestamp("column", Calendar.getInstance()));
- }
-
- /**
- * Tests the getURL and setNullURL implementations.
- *
- * Uses reflection to allow for building under JDK 1.3.
- */
- public void testURL() throws SQLException, MalformedURLException,
- IllegalAccessException, IllegalArgumentException,
- java.lang.reflect.InvocationTargetException
- {
- Method getUrlInt = null;
- Method getUrlString = null;
- try {
- getUrlInt = ResultSet.class.getMethod("getURL",
- new Class[] { Integer.TYPE } );
- getUrlString = ResultSet.class.getMethod("getURL",
- new Class[] { String.class } );
- } catch(NoSuchMethodException e) {
- // ignore
- } catch(SecurityException e) {
- // ignore
- }
- if (getUrlInt != null && getUrlString != null) {
- assertEquals(null, getUrlInt.invoke(rs,
- new Object[] { Integer.valueOf(1) } ) );
- assertTrue(rs.wasNull());
- assertEquals(null, getUrlString.invoke(rs,
- new Object[] { "column" } ) );
- assertTrue(rs.wasNull());
- // Set what gets returned to something other than the default
- URL u = new URL("http://www.apache.org");
- rs2.setNullURL(u);
- assertEquals(u, getUrlInt.invoke(rs,
- new Object[] { Integer.valueOf(1) } ) );
- assertEquals(u, getUrlString.invoke(rs,
- new Object[] { "column" } ) );
- }
- }
-
- /**
- * Tests the setNullAsciiStream implementation.
- */
- public void testSetNullAsciiStream() throws SQLException {
-
- assertNull(rs2.getNullAsciiStream());
- // Set what gets returned to something other than the default
- InputStream stream = new ByteArrayInputStream(new byte[0]);
- rs2.setNullAsciiStream(stream);
- assertNotNull(rs.getAsciiStream(1));
- assertEquals(stream, rs.getAsciiStream(1));
- assertNotNull(rs.getAsciiStream("column"));
- assertEquals(stream, rs.getAsciiStream("column"));
-
- }
-
- /**
- * Tests the setNullBigDecimal implementation.
- */
- public void testSetNullBigDecimal() throws SQLException {
-
- assertNull(rs2.getNullBigDecimal());
- // Set what gets returned to something other than the default
- BigDecimal bd = new BigDecimal(5.0);
- rs2.setNullBigDecimal(bd);
- assertNotNull(rs.getBigDecimal(1));
- assertEquals(bd, rs.getBigDecimal(1));
- assertNotNull(rs.getBigDecimal("column"));
- assertEquals(bd, rs.getBigDecimal("column"));
-
- }
-
- /**
- * Tests the setNullBinaryStream implementation.
- */
- public void testSetNullBinaryStream() throws SQLException {
-
- assertNull(rs2.getNullBinaryStream());
- // Set what gets returned to something other than the default
- InputStream stream = new ByteArrayInputStream(new byte[0]);
- rs2.setNullBinaryStream(stream);
- assertNotNull(rs.getBinaryStream(1));
- assertEquals(stream, rs.getBinaryStream(1));
- assertNotNull(rs.getBinaryStream("column"));
- assertEquals(stream, rs.getBinaryStream("column"));
-
- }
-
- /**
- * Tests the setNullBlob implementation.
- */
- public void testSetNullBlob() throws SQLException {
-
- assertNull(rs2.getNullBlob());
- // Set what gets returned to something other than the default
- Blob blob = new SqlNullCheckedResultSetMockBlob();
- rs2.setNullBlob(blob);
- assertNotNull(rs.getBlob(1));
- assertEquals(blob, rs.getBlob(1));
- assertNotNull(rs.getBlob("column"));
- assertEquals(blob, rs.getBlob("column"));
-
- }
-
- /**
- * Tests the setNullBoolean implementation.
- */
- public void testSetNullBoolean() throws SQLException {
-
- assertEquals(false, rs2.getNullBoolean());
- // Set what gets returned to something other than the default
- rs2.setNullBoolean(true);
- assertEquals(true, rs.getBoolean(1));
- assertEquals(true, rs.getBoolean("column"));
-
- }
-
- /**
- * Tests the setNullByte implementation.
- */
- public void testSetNullByte() throws SQLException {
-
- assertEquals((byte) 0, rs2.getNullByte());
- // Set what gets returned to something other than the default
- byte b = (byte) 10;
- rs2.setNullByte(b);
- assertEquals(b, rs.getByte(1));
- assertEquals(b, rs.getByte("column"));
-
- }
-
- /**
- * Tests the setNullByte implementation.
- */
- public void testSetNullBytes() throws SQLException {
-
- assertNull(rs2.getNullBytes());
- // Set what gets returned to something other than the default
- byte[] b = new byte[5];
- for (int i = 0; i < 5; i++) {
- b[0] = (byte) i;
- }
- rs2.setNullBytes(b);
- assertNotNull(rs.getBytes(1));
- assertArrayEquals(b, rs.getBytes(1));
- assertNotNull(rs.getBytes("column"));
- assertArrayEquals(b, rs.getBytes("column"));
-
- }
-
- /**
- * Tests the setNullCharacterStream implementation.
- */
- public void testSetNullCharacterStream() throws SQLException {
-
- assertNull(rs2.getNullCharacterStream());
- // Set what gets returned to something other than the default
- Reader reader = new CharArrayReader("this is a string".toCharArray());
- rs2.setNullCharacterStream(reader);
- assertNotNull(rs.getCharacterStream(1));
- assertEquals(reader, rs.getCharacterStream(1));
- assertNotNull(rs.getCharacterStream("column"));
- assertEquals(reader, rs.getCharacterStream("column"));
-
- }
-
- /**
- * Tests the setNullClob implementation.
- */
- public void testSetNullClob() throws SQLException {
-
- assertNull(rs2.getNullClob());
- // Set what gets returned to something other than the default
- Clob clob = new SqlNullCheckedResultSetMockClob();
- rs2.setNullClob(clob);
- assertNotNull(rs.getClob(1));
- assertEquals(clob, rs.getClob(1));
- assertNotNull(rs.getClob("column"));
- assertEquals(clob, rs.getClob("column"));
-
- }
-
- /**
- * Tests the setNullDate implementation.
- */
- public void testSetNullDate() throws SQLException {
-
- assertNull(rs2.getNullDate());
- // Set what gets returned to something other than the default
- java.sql.Date date = new java.sql.Date(new java.util.Date().getTime());
- rs2.setNullDate(date);
- assertNotNull(rs.getDate(1));
- assertEquals(date, rs.getDate(1));
- assertNotNull(rs.getDate("column"));
- assertEquals(date, rs.getDate("column"));
- assertNotNull(rs.getDate(1, Calendar.getInstance()));
- assertEquals(date, rs.getDate(1, Calendar.getInstance()));
- assertNotNull(rs.getDate("column", Calendar.getInstance()));
- assertEquals(date, rs.getDate("column", Calendar.getInstance()));
-
- }
-
- /**
- * Tests the setNullDouble implementation.
- */
- public void testSetNullDouble() throws SQLException {
- assertEquals(0.0, rs2.getNullDouble(), 0.0);
- // Set what gets returned to something other than the default
- double d = 10.0;
- rs2.setNullDouble(d);
- assertEquals(d, rs.getDouble(1), 0.0);
- assertEquals(d, rs.getDouble("column"), 0.0);
- }
-
- /**
- * Tests the setNullFloat implementation.
- */
- public void testSetNullFloat() throws SQLException {
- assertEquals((float) 0.0, rs2.getNullFloat(), 0.0);
- // Set what gets returned to something other than the default
- float f = (float) 10.0;
- rs2.setNullFloat(f);
- assertEquals(f, rs.getFloat(1), 0.0);
- assertEquals(f, rs.getFloat("column"), 0.0);
- }
-
- /**
- * Tests the setNullInt implementation.
- */
- public void testSetNullInt() throws SQLException {
- assertEquals(0, rs2.getNullInt());
- assertEquals(0, rs.getInt(1));
- assertTrue(rs.wasNull());
- assertEquals(0, rs.getInt("column"));
- assertTrue(rs.wasNull());
- // Set what gets returned to something other than the default
- int i = 10;
- rs2.setNullInt(i);
- assertEquals(i, rs.getInt(1));
- assertEquals(i, rs.getInt("column"));
- }
-
- /**
- * Tests the setNullLong implementation.
- */
- public void testSetNullLong() throws SQLException {
- assertEquals(0, rs2.getNullLong());
- // Set what gets returned to something other than the default
- long l = 10;
- rs2.setNullLong(l);
- assertEquals(l, rs.getLong(1));
- assertEquals(l, rs.getLong("column"));
- }
-
- /**
- * Tests the setNullObject implementation.
- */
- public void testSetNullObject() throws SQLException {
- assertNull(rs2.getNullObject());
- // Set what gets returned to something other than the default
- Object o = new Object();
- rs2.setNullObject(o);
- assertNotNull(rs.getObject(1));
- assertEquals(o, rs.getObject(1));
- assertNotNull(rs.getObject("column"));
- assertEquals(o, rs.getObject("column"));
- assertNotNull(rs.getObject(1, (Map<String, Class<?>>) null));
- assertEquals(o, rs.getObject(1, (Map<String, Class<?>>) null));
- assertNotNull(rs.getObject("column", (Map<String, Class<?>>) null));
- assertEquals(o, rs.getObject("column", (Map<String, Class<?>>) null));
- }
-
- /**
- * Tests the setNullShort implementation.
- */
- public void testSetNullShort() throws SQLException {
-
- assertEquals((short) 0, rs2.getNullShort());
- // Set what gets returned to something other than the default
- short s = (short) 10;
- rs2.setNullShort(s);
- assertEquals(s, rs.getShort(1));
- assertEquals(s, rs.getShort("column"));
-
- }
-
- /**
- * Tests the setNullString implementation.
- */
- public void testSetNullString() throws SQLException {
- assertEquals(null, rs2.getNullString());
- // Set what gets returned to something other than the default
- String s = "hello, world";
- rs2.setNullString(s);
- assertEquals(s, rs.getString(1));
- assertEquals(s, rs.getString("column"));
- }
-
- /**
- * Tests the setNullRef implementation.
- */
- public void testSetNullRef() throws SQLException {
- assertNull(rs2.getNullRef());
- // Set what gets returned to something other than the default
- Ref ref = new SqlNullCheckedResultSetMockRef();
- rs2.setNullRef(ref);
- assertNotNull(rs.getRef(1));
- assertEquals(ref, rs.getRef(1));
- assertNotNull(rs.getRef("column"));
- assertEquals(ref, rs.getRef("column"));
- }
-
- /**
- * Tests the setNullTime implementation.
- */
- public void testSetNullTime() throws SQLException {
- assertEquals(null, rs2.getNullTime());
- // Set what gets returned to something other than the default
- Time time = new Time(new java.util.Date().getTime());
- rs2.setNullTime(time);
- assertNotNull(rs.getTime(1));
- assertEquals(time, rs.getTime(1));
- assertNotNull(rs.getTime("column"));
- assertEquals(time, rs.getTime("column"));
- assertNotNull(rs.getTime(1, Calendar.getInstance()));
- assertEquals(time, rs.getTime(1, Calendar.getInstance()));
- assertNotNull(rs.getTime("column", Calendar.getInstance()));
- assertEquals(time, rs.getTime("column", Calendar.getInstance()));
- }
-
- /**
- * Tests the setNullTimestamp implementation.
- */
- public void testSetNullTimestamp() throws SQLException {
- assertEquals(null, rs2.getNullTimestamp());
- // Set what gets returned to something other than the default
- Timestamp ts = new Timestamp(new java.util.Date().getTime());
- rs2.setNullTimestamp(ts);
- assertNotNull(rs.getTimestamp(1));
- assertEquals(ts, rs.getTimestamp(1));
- assertNotNull(rs.getTimestamp("column"));
- assertEquals(ts, rs.getTimestamp("column"));
- assertNotNull(rs.getTimestamp(1, Calendar.getInstance()));
- assertEquals(ts, rs.getTimestamp(1, Calendar.getInstance()));
- assertNotNull(rs.getTimestamp("column", Calendar.getInstance()));
- assertEquals(ts, rs.getTimestamp("column", Calendar.getInstance()));
- }
-
-}
-
-class SqlNullUncheckedMockResultSet implements InvocationHandler {
-
- /**
- * Always return false for booleans, 0 for numerics, and null for Objects.
- * @see java.lang.reflect.InvocationHandler#invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
- */
- @Override
- public Object invoke(Object proxy, Method method, Object[] args)
- throws Throwable {
-
- Class<?> returnType = method.getReturnType();
-
- if (method.getName().equals("wasNull")) {
- return Boolean.TRUE;
-
- } else if (returnType.equals(Boolean.TYPE)) {
- return Boolean.FALSE;
-
- } else if (returnType.equals(Integer.TYPE)) {
- return Integer.valueOf(0);
-
- } else if (returnType.equals(Short.TYPE)) {
- return Short.valueOf((short) 0);
-
- } else if (returnType.equals(Double.TYPE)) {
- return new Double(0);
-
- } else if (returnType.equals(Long.TYPE)) {
- return Long.valueOf(0);
-
- } else if (returnType.equals(Byte.TYPE)) {
- return Byte.valueOf((byte) 0);
-
- } else if (returnType.equals(Float.TYPE)) {
- return new Float(0);
-
- } else {
- return null;
- }
- }
-}
-
-class SqlNullCheckedResultSetMockBlob implements Blob {
-
- @Override
- public InputStream getBinaryStream() throws SQLException {
- return new ByteArrayInputStream(new byte[0]);
- }
-
- @Override
- public byte[] getBytes(long param, int param1) throws SQLException {
- return new byte[0];
- }
-
- @Override
- public long length() throws SQLException {
- return 0;
- }
-
- @Override
- public long position(byte[] values, long param) throws SQLException {
- return 0;
- }
-
- @Override
- public long position(Blob blob, long param) throws SQLException {
- return 0;
- }
-
- @Override
- public void truncate(long len) throws SQLException {
-
- }
-
- @Override
- public int setBytes(long pos, byte[] bytes) throws SQLException {
- return 0;
- }
-
- @Override
- public int setBytes(long pos, byte[] bytes, int offset, int len)
- throws SQLException {
- return 0;
- }
-
- @Override
- public OutputStream setBinaryStream(long pos) throws SQLException {
- return null;
- }
-
- /**
- * @throws SQLException
- */
- @Override
- public void free() throws SQLException {
-
- }
-
- /**
- * @throws SQLException
- */
- @Override
- public InputStream getBinaryStream(long pos, long length) throws SQLException {
- return null;
- }
-
-}
-
-class SqlNullCheckedResultSetMockClob implements Clob {
-
- @Override
- public InputStream getAsciiStream() throws SQLException {
- return null;
- }
-
- @Override
- public Reader getCharacterStream() throws SQLException {
- return null;
- }
-
- @Override
- public String getSubString(long param, int param1) throws SQLException {
- return "";
- }
-
- @Override
- public long length() throws SQLException {
- return 0;
- }
-
- @Override
- public long position(Clob clob, long param) throws SQLException {
- return 0;
- }
-
- @Override
- public long position(String str, long param) throws SQLException {
- return 0;
- }
-
- @Override
- public void truncate(long len) throws SQLException {
-
- }
-
- @Override
- public OutputStream setAsciiStream(long pos) throws SQLException {
- return null;
- }
-
- @Override
- public Writer setCharacterStream(long pos) throws SQLException {
- return null;
- }
-
- @Override
- public int setString(long pos, String str) throws SQLException {
- return 0;
- }
-
- @Override
- public int setString(long pos, String str, int offset, int len)
- throws SQLException {
- return 0;
- }
-
- /**
- * @throws SQLException
- */
- @Override
- public void free() throws SQLException {
-
- }
-
- /**
- * @throws SQLException
- */
- @Override
- public Reader getCharacterStream(long pos, long length) throws SQLException {
- return null;
- }
-
-}
-
-class SqlNullCheckedResultSetMockRef implements Ref {
-
- @Override
- public String getBaseTypeName() throws SQLException {
- return "";
- }
-
- @Override
- public Object getObject() throws SQLException {
- return null;
- }
-
- @Override
- public void setObject(Object value) throws SQLException {
-
- }
-
- @Override
- public Object getObject(Map<String,Class<?>> map) throws SQLException {
- return null;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/test/java/org/apache/commons/dbutils/wrappers/StringTrimmedResultSetTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils/wrappers/StringTrimmedResultSetTest.java b/src/test/java/org/apache/commons/dbutils/wrappers/StringTrimmedResultSetTest.java
deleted file mode 100644
index 3df4070..0000000
--- a/src/test/java/org/apache/commons/dbutils/wrappers/StringTrimmedResultSetTest.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.dbutils.wrappers;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-import org.apache.commons.dbutils.BaseTestCase;
-import org.apache.commons.dbutils.MockResultSet;
-import org.apache.commons.dbutils.ProxyFactory;
-
-/**
- * StringTrimmedResultSetTest
- */
-public class StringTrimmedResultSetTest extends BaseTestCase {
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- this.rs = StringTrimmedResultSet.wrap(this.rs);
- }
-
- public void testGetString() throws SQLException {
- this.rs.next();
- assertEquals("notInBean", rs.getString(4));
- }
-
- public void testGetObject() throws SQLException {
- this.rs.next();
- assertEquals("notInBean", rs.getObject(4));
- }
-
- /**
- * Make sure 2 wrappers work together.
- * @throws SQLException if a database access error occurs
- */
- public void testMultipleWrappers() throws Exception {
- // Create a ResultSet with data
- Object[][] rows = new Object[][] { { null }
- };
- ResultSet rs = MockResultSet.create(metaData, rows);
-
- // Wrap the ResultSet with a null checked version
- SqlNullCheckedResultSet ncrs = new SqlNullCheckedResultSet(rs);
- ncrs.setNullString(" trim this ");
- rs = ProxyFactory.instance().createResultSet(ncrs);
-
- // Wrap the wrapper with a string trimmed version
- rs = StringTrimmedResultSet.wrap(rs);
-
- rs.next();
- assertEquals("trim this", rs.getString(1));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/test/java/org/apache/commons/dbutils2/AbstractExecutorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils2/AbstractExecutorTest.java b/src/test/java/org/apache/commons/dbutils2/AbstractExecutorTest.java
new file mode 100644
index 0000000..61fcc91
--- /dev/null
+++ b/src/test/java/org/apache/commons/dbutils2/AbstractExecutorTest.java
@@ -0,0 +1,124 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.dbutils2;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.sql.Types;
+
+import org.apache.commons.dbutils2.AbstractExecutor;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+
+public class AbstractExecutorTest {
+
+ @SuppressWarnings("rawtypes") // don't care about this in the unit test
+ private AbstractExecutor executor;
+
+ @Mock private Connection conn;
+ @Mock private PreparedStatement stmt;
+
+ @Before
+ public void setup() throws SQLException {
+ MockitoAnnotations.initMocks(this);
+
+ when(conn.prepareStatement(any(String.class))).thenReturn(stmt);
+ }
+
+ @SuppressWarnings("rawtypes")
+ public void createExecutor(String sql) throws SQLException {
+ executor = new AbstractExecutor(conn, sql) { };
+ }
+
+ @Test
+ public void testGoodSql() throws SQLException {
+ createExecutor("select * from blah :first = first and :last=last and phone=:phone");
+
+ verify(conn, times(1)).prepareStatement("select * from blah ? = first and ?=last and phone=?");
+
+ executor.bind("first", "first_name")
+ .bind(":last", "last_name")
+ .bind("phone", Integer.valueOf(12345));
+
+ verify(stmt, times(1)).setObject(1, "first_name");
+ verify(stmt, times(1)).setObject(2, "last_name");
+ verify(stmt, times(1)).setObject(eq(3), eq(Integer.valueOf(12345)));
+
+ executor.throwIfUnmappedParams();
+ }
+
+ @Test
+ public void testNoParamsSql() throws SQLException {
+ createExecutor("select * from blah");
+
+ verify(conn, times(1)).prepareStatement("select * from blah");
+ verify(stmt, times(0)).setObject(any(Integer.class), any(Object.class));
+
+ executor.throwIfUnmappedParams();
+ }
+
+ @Test(expected=SQLException.class)
+ public void testMissingParamSql() throws SQLException {
+ createExecutor("select * from blah :first = first and :last=last");
+
+ verify(conn, times(1)).prepareStatement("select * from blah ? = first and ?=last");
+
+ executor.bind("first", "first_name")
+ .bind(":last", "last_name")
+ .bind("phone", Integer.valueOf(12345)); // should throw
+
+ verify(stmt, times(1)).setObject(1, "first_name");
+ verify(stmt, times(1)).setObject(2, "last_name");
+ verify(stmt, times(1)).setObject(eq(3), eq(Integer.valueOf(12345)));
+ }
+
+ @Test(expected=SQLException.class)
+ public void testDoubleBind() throws SQLException {
+ createExecutor("select * from blah :first = first and :last=last");
+
+ verify(conn, times(1)).prepareStatement("select * from blah ? = first and ?=last");
+
+ executor.bind("first", "first_name")
+ .bind(":last", "last_name")
+ .bind(":last", "last_name");
+
+ verify(stmt, times(1)).setObject(1, "first_name");
+ verify(stmt, times(1)).setObject(2, "last_name");
+ }
+
+ @Test
+ public void testNullBind() throws SQLException {
+ createExecutor("select * from blah :first = first and :last=last");
+
+ verify(conn, times(1)).prepareStatement("select * from blah ? = first and ?=last");
+
+ executor.bindNull("first")
+ .bindNull(":last", Types.NULL);
+
+ verify(stmt, times(1)).setNull(1, Types.VARCHAR);
+ verify(stmt, times(1)).setNull(2, Types.NULL);
+ }
+}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/test/java/org/apache/commons/dbutils2/AsyncExecutorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils2/AsyncExecutorTest.java b/src/test/java/org/apache/commons/dbutils2/AsyncExecutorTest.java
new file mode 100644
index 0000000..fe7f6f7
--- /dev/null
+++ b/src/test/java/org/apache/commons/dbutils2/AsyncExecutorTest.java
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.dbutils2;
+
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import java.sql.SQLException;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Executors;
+
+import org.apache.commons.dbutils2.AsyncExecutor;
+import org.apache.commons.dbutils2.InsertExecutor;
+import org.apache.commons.dbutils2.QueryExecutor;
+import org.apache.commons.dbutils2.QueryRunner;
+import org.apache.commons.dbutils2.ResultSetHandler;
+import org.apache.commons.dbutils2.UpdateExecutor;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+@SuppressWarnings("boxing") // test code
+public class AsyncExecutorTest {
+ AsyncExecutor runner;
+
+ @Mock QueryRunner qRunner;
+ @Mock ResultSetHandler<Object> handler;
+ @Mock QueryExecutor queryExecutor;
+ @Mock UpdateExecutor updateExecutor;
+ @Mock InsertExecutor insertExecutor;
+
+ @Before
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this); // init the mocks
+
+ runner = new AsyncExecutor(Executors.newFixedThreadPool(1));
+ }
+
+ @Test
+ public void testQueryExecutor() throws Exception {
+ runner.execute(queryExecutor, handler).get();
+
+ verify(queryExecutor, times(1)).execute(handler);
+ }
+
+ @Test(expected=ExecutionException.class)
+ public void testQueryExecutorException() throws Exception {
+ doThrow(SQLException.class).when(queryExecutor).execute(handler);
+ runner.execute(queryExecutor, handler).get();
+
+ verify(queryExecutor, times(1)).execute(handler);
+ }
+
+ @Test
+ public void testUpdateExecutor() throws Exception {
+ runner.execute(updateExecutor).get();
+
+ verify(updateExecutor, times(1)).execute();
+ }
+
+ @Test(expected=ExecutionException.class)
+ public void testUpdateExecutorException() throws Exception {
+ doThrow(SQLException.class).when(updateExecutor).execute();
+ runner.execute(updateExecutor).get();
+
+ verify(updateExecutor, times(1)).execute();
+ }
+
+ @Test
+ public void testInsertExecutor() throws Exception {
+ runner.execute(insertExecutor, handler).get();
+
+ verify(insertExecutor, times(1)).execute(handler);
+ }
+
+ @Test(expected=ExecutionException.class)
+ public void testInsertExecutorException() throws Exception {
+ doThrow(SQLException.class).when(insertExecutor).execute(handler);
+ runner.execute(insertExecutor, handler).get();
+
+ verify(insertExecutor, times(1)).execute(handler);
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/test/java/org/apache/commons/dbutils2/BaseResultSetHandlerTestCase.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils2/BaseResultSetHandlerTestCase.java b/src/test/java/org/apache/commons/dbutils2/BaseResultSetHandlerTestCase.java
new file mode 100644
index 0000000..f9cd433
--- /dev/null
+++ b/src/test/java/org/apache/commons/dbutils2/BaseResultSetHandlerTestCase.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.dbutils2;
+
+import java.sql.SQLException;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.Map;
+
+import org.apache.commons.dbutils2.BaseResultSetHandler;
+import org.junit.Test;
+
+public final class BaseResultSetHandlerTestCase extends BaseTestCase {
+
+ @Test
+ public void handleWithoutExplicitResultSetInvocation() throws Exception {
+ Collection<Map<String, Object>> result = new ToMapCollectionHandler().handle(createMockResultSet());
+
+ assertFalse(result.isEmpty());
+
+ for (Map<String, Object> current : result) {
+ assertTrue(current.containsKey("one"));
+ assertTrue(current.containsKey("two"));
+ assertTrue(current.containsKey("three"));
+ assertTrue(current.containsKey("notInBean"));
+ assertTrue(current.containsKey("intTest"));
+ assertTrue(current.containsKey("integerTest"));
+ assertTrue(current.containsKey("nullObjectTest"));
+ assertTrue(current.containsKey("nullPrimitiveTest"));
+ assertTrue(current.containsKey("notDate"));
+ assertTrue(current.containsKey("columnProcessorDoubleTest"));
+ }
+ }
+
+ private static final class ToMapCollectionHandler
+ extends BaseResultSetHandler<Collection<Map<String, Object>>> {
+
+ @Override
+ protected Collection<Map<String, Object>> handle() throws SQLException {
+ Collection<Map<String, Object>> result = new LinkedList<Map<String, Object>>();
+
+ while (next()) {
+ Map<String, Object> current = new HashMap<String, Object>();
+
+ for (int i = 1; i <= getMetaData().getColumnCount(); i++) {
+ current.put(getMetaData().getColumnName(i), getObject(i));
+ }
+
+ result.add(current);
+ }
+
+ return result;
+ }
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/test/java/org/apache/commons/dbutils2/BaseTestCase.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils2/BaseTestCase.java b/src/test/java/org/apache/commons/dbutils2/BaseTestCase.java
new file mode 100644
index 0000000..0debc1f
--- /dev/null
+++ b/src/test/java/org/apache/commons/dbutils2/BaseTestCase.java
@@ -0,0 +1,127 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.dbutils2;
+
+import java.math.BigInteger;
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.util.Date;
+
+import junit.framework.TestCase;
+
+/**
+ * BaseTestCase is the base class for all test cases as well as the "all tests"
+ * runner.
+ */
+public class BaseTestCase extends TestCase {
+
+ private static final String[] columnNames =
+ new String[] {
+ "one",
+ "two",
+ "three",
+ "notInBean",
+ "intTest",
+ "integerTest",
+ "nullObjectTest",
+ "nullPrimitiveTest",
+ "notDate",
+ "columnProcessorDoubleTest" };
+
+ /**
+ * The number of columns in the MockResultSet.
+ */
+ protected static final int COLS = columnNames.length;
+
+ protected static final ResultSetMetaData metaData =
+ MockResultSetMetaData.create(columnNames);
+
+ private static final Object[] row1 =
+ new Object[] {
+ "1",
+ "2",
+ "3",
+ " notInBean ",
+ Integer.valueOf(1),
+ Integer.valueOf(2),
+ null,
+ null,
+ new Date(),
+ BigInteger.valueOf(13)};
+
+ private static final Object[] row2 =
+ new Object[] {
+ "4",
+ "5",
+ "6",
+ " notInBean ",
+ Integer.valueOf(3),
+ Integer.valueOf(4),
+ null,
+ null,
+ new Date(),
+ BigInteger.valueOf(13)};
+
+ private static final Object[][] rows = new Object[][] { row1, row2 };
+
+ /**
+ * The number of rows in the MockResultSet.
+ */
+ protected static final int ROWS = rows.length;
+
+ /**
+ * The ResultSet all test methods will use.
+ */
+ protected ResultSet rs = null;
+
+ /**
+ * A ResultSet with 0 rows.
+ */
+ protected ResultSet emptyResultSet = null;
+
+ /**
+ * This is called before each test method so ResultSet will be fresh each
+ * time.
+ * @see junit.framework.TestCase#setUp()
+ */
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ rs = this.createMockResultSet();
+ emptyResultSet = MockResultSet.create(metaData, null);
+ }
+
+ /**
+ * Creates a freshly initialized ResultSet.
+ */
+ protected ResultSet createMockResultSet() {
+ return MockResultSet.create(metaData, rows);
+ }
+
+ // Test which allows Eclipse to be run on full project (avoids no tests found)
+ // check that the rows are valid for the column definition
+ public void testCheckDataSizes() {
+ assertEquals("Row 1 must contain correct number of columns", columnNames.length, row1.length);
+ assertEquals("Row 1 must contain correct number of columns", columnNames.length, row2.length);
+ }
+
+ public void testResultSets() throws Exception {
+ assertFalse("emptyResultSet should be empty", emptyResultSet.next());
+ // fails in SqlNullCheckedResultSetTest assertTrue("rs should not be empty", rs.next());
+ }
+}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/test/java/org/apache/commons/dbutils2/BasicRowProcessorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils2/BasicRowProcessorTest.java b/src/test/java/org/apache/commons/dbutils2/BasicRowProcessorTest.java
new file mode 100644
index 0000000..684e9db
--- /dev/null
+++ b/src/test/java/org/apache/commons/dbutils2/BasicRowProcessorTest.java
@@ -0,0 +1,142 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.dbutils2;
+
+import java.sql.SQLException;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+import org.apache.commons.dbutils2.BasicRowProcessor;
+import org.apache.commons.dbutils2.RowProcessor;
+
+/**
+ * Test the BasicRowProcessor class.
+ */
+public class BasicRowProcessorTest extends BaseTestCase {
+
+ private static final RowProcessor processor = new BasicRowProcessor();
+
+ /**
+ * Format that matches Date.toString().
+ * Sun Mar 14 15:19:15 MST 2004
+ */
+ private static final DateFormat datef =
+ new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.US);
+
+ public void testToArray() throws SQLException {
+
+ Object[] a = null;
+ assertTrue(this.rs.next());
+ a = processor.toArray(this.rs);
+ assertEquals(COLS, a.length);
+ assertEquals("1", a[0]);
+ assertEquals("2", a[1]);
+ assertEquals("3", a[2]);
+
+ assertTrue(this.rs.next());
+ a = processor.toArray(this.rs);
+ assertEquals(COLS, a.length);
+
+ assertEquals("4", a[0]);
+ assertEquals("5", a[1]);
+ assertEquals("6", a[2]);
+
+ assertFalse(this.rs.next());
+ }
+
+ public void testToBean() throws SQLException, ParseException {
+
+ TestBean row = null;
+ assertTrue(this.rs.next());
+ row = processor.toBean(this.rs, TestBean.class);
+ assertEquals("1", row.getOne());
+ assertEquals("2", row.getTwo());
+ assertEquals("3", row.getThree());
+ assertEquals("not set", row.getDoNotSet());
+
+ assertTrue(this.rs.next());
+ row = processor.toBean(this.rs, TestBean.class);
+
+ assertEquals("4", row.getOne());
+ assertEquals("5", row.getTwo());
+ assertEquals("6", row.getThree());
+ assertEquals("not set", row.getDoNotSet());
+ assertEquals(3, row.getIntTest());
+ assertEquals(Integer.valueOf(4), row.getIntegerTest());
+ assertEquals(null, row.getNullObjectTest());
+ assertEquals(0, row.getNullPrimitiveTest());
+ // test date -> string handling
+ assertNotNull(row.getNotDate());
+ assertTrue(!"not a date".equals(row.getNotDate()));
+ datef.parse(row.getNotDate());
+
+ assertFalse(this.rs.next());
+
+ }
+
+ public void testToBeanList() throws SQLException, ParseException {
+
+ List<TestBean> list = processor.toBeanList(this.rs, TestBean.class);
+ assertNotNull(list);
+ assertEquals(ROWS, list.size());
+
+ TestBean b = list.get(0);
+ assertEquals("1", b.getOne());
+ assertEquals("2", b.getTwo());
+ assertEquals("3", b.getThree());
+ assertEquals("not set", b.getDoNotSet());
+
+ b = list.get(1);
+ assertEquals("4", b.getOne());
+ assertEquals("5", b.getTwo());
+ assertEquals("6", b.getThree());
+ assertEquals("not set", b.getDoNotSet());
+ assertEquals(3, b.getIntTest());
+ assertEquals(Integer.valueOf(4), b.getIntegerTest());
+ assertEquals(null, b.getNullObjectTest());
+ assertEquals(0, b.getNullPrimitiveTest());
+ // test date -> string handling
+ assertNotNull(b.getNotDate());
+ assertTrue(!"not a date".equals(b.getNotDate()));
+ datef.parse(b.getNotDate());
+ }
+
+ public void testToMap() throws SQLException {
+
+ assertTrue(this.rs.next());
+ Map<String, Object> m = processor.toMap(this.rs);
+ assertEquals(COLS, m.keySet().size());
+ assertEquals("1", m.get("one"));
+ assertEquals("2", m.get("TWO"));
+ assertEquals("3", m.get("Three"));
+
+ assertTrue(this.rs.next());
+ m = processor.toMap(this.rs);
+ assertEquals(COLS, m.keySet().size());
+
+ assertEquals("4", m.get("One")); // case shouldn't matter
+ assertEquals("5", m.get("two"));
+ assertEquals("6", m.get("THREE"));
+
+ assertFalse(this.rs.next());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/test/java/org/apache/commons/dbutils2/BatchExecutorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils2/BatchExecutorTest.java b/src/test/java/org/apache/commons/dbutils2/BatchExecutorTest.java
new file mode 100644
index 0000000..a049bc7
--- /dev/null
+++ b/src/test/java/org/apache/commons/dbutils2/BatchExecutorTest.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.dbutils2;
+
+import static org.junit.Assert.*;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+
+import org.apache.commons.dbutils2.BatchExecutor;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+
+public class BatchExecutorTest {
+
+ private BatchExecutor executor;
+
+ @Mock private Connection conn;
+ @Mock private PreparedStatement stmt;
+
+ @Before
+ public void setup() throws SQLException {
+ MockitoAnnotations.initMocks(this);
+
+ when(conn.prepareStatement(any(String.class))).thenReturn(stmt);
+ when(stmt.executeBatch()).thenReturn(new int[] { 2, 3, 4 });
+ }
+
+ protected void createExecutor(String sql) throws Exception {
+ executor = new BatchExecutor(conn, sql, true);
+ }
+
+ @Test
+ public void testGoodSQL() throws Exception {
+ createExecutor("insert into blah");
+
+ executor.addBatch();
+ int[] ret = executor.execute();
+
+ assertEquals(3, ret.length);
+ assertEquals(2, ret[0]);
+ assertEquals(3, ret[1]);
+ assertEquals(4, ret[2]);
+ verify(conn, times(1)).close();
+ verify(stmt, times(1)).close();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/test/java/org/apache/commons/dbutils2/BeanProcessorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils2/BeanProcessorTest.java b/src/test/java/org/apache/commons/dbutils2/BeanProcessorTest.java
new file mode 100644
index 0000000..73fc26b
--- /dev/null
+++ b/src/test/java/org/apache/commons/dbutils2/BeanProcessorTest.java
@@ -0,0 +1,116 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.dbutils2;
+
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.commons.dbutils2.BeanProcessor;
+import org.apache.commons.dbutils2.ProxyFactory;
+
+public class BeanProcessorTest extends BaseTestCase {
+
+ private static final BeanProcessor beanProc = new BeanProcessor();
+
+ public void testProcess() throws SQLException {
+ TestBean b = null;
+ assertTrue(this.rs.next());
+ b = beanProc.toBean(this.rs, TestBean.class);
+ assertEquals(13.0, b.getColumnProcessorDoubleTest(), 0);
+
+ assertTrue(this.rs.next());
+ b = beanProc.toBean(this.rs, TestBean.class);
+ assertEquals(13.0, b.getColumnProcessorDoubleTest(), 0);
+
+ assertFalse(this.rs.next());
+ }
+
+ public static class MapColumnToPropertiesBean {
+ private String one;
+
+ private String two;
+
+ private String three;
+
+ private String four;
+
+ public String getOne() {
+ return one;
+ }
+
+ public void setOne(String one) {
+ this.one = one;
+ }
+
+ public String getTwo() {
+ return two;
+ }
+
+ public void setTwo(String two) {
+ this.two = two;
+ }
+
+ public String getThree() {
+ return three;
+ }
+
+ public void setThree(String three) {
+ this.three = three;
+ }
+
+ public String getFour() {
+ return four;
+ }
+
+ public void setFour(String four) {
+ this.four = four;
+ }
+ }
+
+ public void testMapColumnToProperties() throws Exception {
+ String[] columnNames = { "test", "test", "three" };
+ String[] columnLabels = { "one", "two", null };
+ ResultSetMetaData rsmd = ProxyFactory.instance().createResultSetMetaData(
+ new MockResultSetMetaData(columnNames, columnLabels));
+ PropertyDescriptor[] props = Introspector.getBeanInfo(MapColumnToPropertiesBean.class).getPropertyDescriptors();
+
+ int[] columns = beanProc.mapColumnsToProperties(rsmd, props);
+ for (int i = 1; i < columns.length; i++) {
+ assertTrue(columns[i] != BeanProcessor.PROPERTY_NOT_FOUND);
+ }
+ }
+
+ public void testMapColumnToPropertiesWithOverrides() throws Exception {
+ Map<String, String> columnToPropertyOverrides = new HashMap<String, String>();
+ columnToPropertyOverrides.put("five", "four");
+ BeanProcessor beanProc = new BeanProcessor(columnToPropertyOverrides);
+ String[] columnNames = { "test", "test", "three", "five" };
+ String[] columnLabels = { "one", "two", null, null };
+ ResultSetMetaData rsmd = ProxyFactory.instance().createResultSetMetaData(
+ new MockResultSetMetaData(columnNames, columnLabels));
+ PropertyDescriptor[] props = Introspector.getBeanInfo(MapColumnToPropertiesBean.class).getPropertyDescriptors();
+
+ int[] columns = beanProc.mapColumnsToProperties(rsmd, props);
+ for (int i = 1; i < columns.length; i++) {
+ assertTrue(columns[i] != BeanProcessor.PROPERTY_NOT_FOUND);
+ }
+ }
+}
[54/58] [abbrv] commons-dbutils git commit: DBUTILS-106 - DBUtils
can't build using JDK 1.7 - DriverProxy needs to implement getParentLogger()
Add dynamic invocation.
Posted by th...@apache.org.
DBUTILS-106 - DBUtils can't build using JDK 1.7 - DriverProxy needs to implement getParentLogger()
Add dynamic invocation.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/dbutils/branches/2_0@1482460 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/commons-dbutils/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-dbutils/commit/d9e63eed
Tree: http://git-wip-us.apache.org/repos/asf/commons-dbutils/tree/d9e63eed
Diff: http://git-wip-us.apache.org/repos/asf/commons-dbutils/diff/d9e63eed
Branch: refs/heads/2_0
Commit: d9e63eed98002d71a2df868b14a0fae60f6cb171
Parents: 949c5d9
Author: Sebastian Bazley <se...@apache.org>
Authored: Tue May 14 17:00:33 2013 +0000
Committer: Sebastian Bazley <se...@apache.org>
Committed: Tue May 14 17:00:33 2013 +0000
----------------------------------------------------------------------
src/changes/changes.xml | 4 ++++
.../org/apache/commons/dbutils2/DbUtils.java | 21 +++++++++++++++++++-
2 files changed, 24 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/d9e63eed/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index a19d1ed..788596f 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -48,6 +48,10 @@ The <action> type attribute can be add,update,fix,remove.
This is the first release of the 2.x branch of the Commons DbUtils package, DbUtils2.
The motivation for creating DbUtils2 was two-fold: a number of deprecated methods in the original DbUtils, and the desire to support named parameters (DBUTILS-105).
">
+ <action dev="sebb" type="fix" issue="DBUTILS-106">
+ DBUtils can't build using JDK 1.7 - DriverProxy needs to implement getParentLogger()
+ Add dynamic invocation.
+ </action>
<action dev="sebb" type="fix" issue="DBUTILS-109">
AbstractExecutor.currentPosition should be an int
</action>
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/d9e63eed/src/main/java/org/apache/commons/dbutils2/DbUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/DbUtils.java b/src/main/java/org/apache/commons/dbutils2/DbUtils.java
index 47f9ace..530ddb9 100644
--- a/src/main/java/org/apache/commons/dbutils2/DbUtils.java
+++ b/src/main/java/org/apache/commons/dbutils2/DbUtils.java
@@ -21,6 +21,7 @@ import static java.sql.DriverManager.registerDriver;
import java.io.PrintWriter;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
import java.sql.Connection;
import java.sql.Driver;
import java.sql.DriverPropertyInfo;
@@ -347,6 +348,8 @@ public final class DbUtils {
*/
private static final class DriverProxy implements Driver {
+ private boolean parentLoggerSupported = true;
+
/**
* The adapted JDBC Driver loaded dynamically.
*/
@@ -395,7 +398,23 @@ public final class DbUtils {
* Java 1.7 method.
*/
public Logger getParentLogger() throws SQLFeatureNotSupportedException {
- throw new SQLFeatureNotSupportedException();
+ if (parentLoggerSupported) {
+ try {
+ Method method = adapted.getClass().getMethod("getParentLogger", new Class[0]);
+ return (Logger)method.invoke(adapted, new Object[0]);
+ } catch (NoSuchMethodException e) {
+ parentLoggerSupported = false;
+ throw new SQLFeatureNotSupportedException(e);
+ } catch (IllegalAccessException e) {
+ parentLoggerSupported = false;
+ throw new SQLFeatureNotSupportedException(e);
+ } catch (InvocationTargetException e) {
+ parentLoggerSupported = false;
+ throw new SQLFeatureNotSupportedException(e);
+ }
+ } else {
+ throw new SQLFeatureNotSupportedException();
+ }
}
}
[50/58] [abbrv] commons-dbutils git commit: Reverted r1481176 changes
for ArrayHandler
Posted by th...@apache.org.
Reverted r1481176 changes for ArrayHandler
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/dbutils/branches/2_0@1482404 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/commons-dbutils/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-dbutils/commit/8914548f
Tree: http://git-wip-us.apache.org/repos/asf/commons-dbutils/tree/8914548f
Diff: http://git-wip-us.apache.org/repos/asf/commons-dbutils/diff/8914548f
Branch: refs/heads/2_0
Commit: 8914548f5c201e1865e0eb63a204b3ecc0edd8a4
Parents: f2fba8d
Author: Bill Speirs <ws...@apache.org>
Authored: Tue May 14 15:39:27 2013 +0000
Committer: Bill Speirs <ws...@apache.org>
Committed: Tue May 14 15:39:27 2013 +0000
----------------------------------------------------------------------
.../apache/commons/dbutils2/handlers/ArrayHandler.java | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/8914548f/src/main/java/org/apache/commons/dbutils2/handlers/ArrayHandler.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/handlers/ArrayHandler.java b/src/main/java/org/apache/commons/dbutils2/handlers/ArrayHandler.java
index 5eef4ba..3ad73c1 100644
--- a/src/main/java/org/apache/commons/dbutils2/handlers/ArrayHandler.java
+++ b/src/main/java/org/apache/commons/dbutils2/handlers/ArrayHandler.java
@@ -25,12 +25,12 @@ import org.apache.commons.dbutils2.RowProcessor;
/**
* <code>ResultSetHandler</code> implementation that converts a
- * <code>ResultSet</code> into an <code>T[]</code>. This class is
+ * <code>ResultSet</code> into an <code>Object[]</code>. This class is
* thread safe.
*
* @see org.apache.commons.dbutils2.ResultSetHandler
*/
-public class ArrayHandler<T> implements ResultSetHandler<T[]> {
+public class ArrayHandler implements ResultSetHandler<Object[]> {
/**
* Singleton processor instance that handlers share to save memory. Notice
@@ -65,18 +65,18 @@ public class ArrayHandler<T> implements ResultSetHandler<T[]> {
}
/**
- * Places the column values from the first row in an <code>T[]</code>.
+ * Places the column values from the first row in an <code>Object[]</code>.
*
* @param rs <code>ResultSet</code> to process.
- * @return An T[] or <code>null</code> if there are no rows in the
+ * @return An Object[] or <code>null</code> if there are no rows in the
* <code>ResultSet</code>.
*
* @throws SQLException if a database access error occurs
* @see org.apache.commons.dbutils2.ResultSetHandler#handle(java.sql.ResultSet)
*/
@Override
- public T[] handle(ResultSet rs) throws SQLException {
- return (T[]) (rs.next() ? this.convert.toArray(rs) : null);
+ public Object[] handle(ResultSet rs) throws SQLException {
+ return rs.next() ? this.convert.toArray(rs) : null;
}
}
[58/58] [abbrv] commons-dbutils git commit: Obsolete DOAP
Posted by th...@apache.org.
Obsolete DOAP
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/dbutils/branches/2_0@1719147 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/commons-dbutils/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-dbutils/commit/8de35c7e
Tree: http://git-wip-us.apache.org/repos/asf/commons-dbutils/tree/8de35c7e
Diff: http://git-wip-us.apache.org/repos/asf/commons-dbutils/diff/8de35c7e
Branch: refs/heads/2_0
Commit: 8de35c7e285320e9d621c90b34dde8a1223d47bc
Parents: 44eafd6
Author: Sebastian Bazley <se...@apache.org>
Authored: Thu Dec 10 18:13:18 2015 +0000
Committer: Sebastian Bazley <se...@apache.org>
Committed: Thu Dec 10 18:13:18 2015 +0000
----------------------------------------------------------------------
doap_dbutils.rdf | 66 ---------------------------------------------------
1 file changed, 66 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/8de35c7e/doap_dbutils.rdf
----------------------------------------------------------------------
diff --git a/doap_dbutils.rdf b/doap_dbutils.rdf
deleted file mode 100644
index 3489b29..0000000
--- a/doap_dbutils.rdf
+++ /dev/null
@@ -1,66 +0,0 @@
-<?xml version="1.0"?>
-<rdf:RDF xmlns="http://usefulinc.com/ns/doap#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:asfext="http://projects.apache.org/ns/asfext#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:doap="http://usefulinc.com/ns/doap#" xml:lang="en">
-<!--
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
--->
- <Project rdf:about="http://commons.apache.org/dbutils/">
- <name>Apache Commons DbUtils</name>
- <homepage rdf:resource="http://commons.apache.org/dbutils/"/>
- <programming-language>Java</programming-language>
- <category rdf:resource="http://projects.apache.org/category/library"/>
- <license rdf:resource="http://usefulinc.com/doap/licenses/asl20"/>
- <bug-database rdf:resource="http://issues.apache.org/jira/browse/DBUTILS"/>
- <download-page rdf:resource="http://commons.apache.org/dbutils/download_dbutils.cgi"/>
- <asfext:pmc rdf:resource="http://commons.apache.org/"/>
- <shortdesc xml:lang="en">Commons DbUtils</shortdesc>
- <description xml:lang="en">A package of Java utility classes for easing JDBC development</description>
- <repository>
- <SVNRepository>
- <browse rdf:resource="http://svn.apache.org/repos/asf/commons/proper/dbutils/trunk"/>
- <location rdf:resource="http://svn.apache.org/repos/asf/commons/proper/dbutils"/>
- </SVNRepository>
- </repository>
- <release>
- <!-- Dates for 1.1-1.3 taken from http://archive.apache.org/dist/commons/dbutils/binaries/ -->
- <Version>
- <name>commons-dbutils</name>
- <created>2011-10-23</created>
- <revision>1.4</revision>
- </Version>
- <Version>
- <name>commons-dbutils</name>
- <created>2009-11-11</created>
- <revision>1.3</revision>
- </Version>
- <Version>
- <name>commons-dbutils</name>
- <created>2009-04-26</created>
- <revision>1.2</revision>
- </Version>
- <Version>
- <name>commons-dbutils</name>
- <created>2006-12-02</created>
- <revision>1.1</revision>
- </Version>
- <Version>
- <name>commons-dbutils</name>
- <created>2003-11-11</created>
- <revision>1.0</revision>
- </Version>
- </release>
- <mailing-list rdf:resource="http://commons.apache.org/mail-lists.html"/>
- </Project>
-</rdf:RDF>
[40/58] [abbrv] commons-dbutils git commit: Applied DBUTILS-100 to
2.0 branch
Posted by th...@apache.org.
Applied DBUTILS-100 to 2.0 branch
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/dbutils/branches/2_0@1482074 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/commons-dbutils/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-dbutils/commit/67728b05
Tree: http://git-wip-us.apache.org/repos/asf/commons-dbutils/tree/67728b05
Diff: http://git-wip-us.apache.org/repos/asf/commons-dbutils/diff/67728b05
Branch: refs/heads/2_0
Commit: 67728b059178f5db2a9579e2c183173e2863562f
Parents: f28bd88
Author: Bill Speirs <ws...@apache.org>
Authored: Mon May 13 20:10:53 2013 +0000
Committer: Bill Speirs <ws...@apache.org>
Committed: Mon May 13 20:10:53 2013 +0000
----------------------------------------------------------------------
.../java/org/apache/commons/dbutils2/BasicRowProcessor.java | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/67728b05/src/main/java/org/apache/commons/dbutils2/BasicRowProcessor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/BasicRowProcessor.java b/src/main/java/org/apache/commons/dbutils2/BasicRowProcessor.java
index 1b66dc9..264bf57 100644
--- a/src/main/java/org/apache/commons/dbutils2/BasicRowProcessor.java
+++ b/src/main/java/org/apache/commons/dbutils2/BasicRowProcessor.java
@@ -142,7 +142,11 @@ public class BasicRowProcessor implements RowProcessor {
int cols = rsmd.getColumnCount();
for (int i = 1; i <= cols; i++) {
- result.put(rsmd.getColumnName(i), rs.getObject(i));
+ String columnName = rsmd.getColumnLabel(i);
+ if (null == columnName || 0 == columnName.length()) {
+ columnName = rsmd.getColumnName(i);
+ }
+ result.put(columnName, rs.getObject(i));
}
return result;
[39/58] [abbrv] commons-dbutils git commit: Applied DBUTILS-107 to
2.0 branch
Posted by th...@apache.org.
Applied DBUTILS-107 to 2.0 branch
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/dbutils/branches/2_0@1482071 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/commons-dbutils/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-dbutils/commit/f28bd88b
Tree: http://git-wip-us.apache.org/repos/asf/commons-dbutils/tree/f28bd88b
Diff: http://git-wip-us.apache.org/repos/asf/commons-dbutils/diff/f28bd88b
Branch: refs/heads/2_0
Commit: f28bd88b7fbf3d14187bcf64d29d3d6e49fddaa7
Parents: 04b2f8e
Author: Bill Speirs <ws...@apache.org>
Authored: Mon May 13 20:08:25 2013 +0000
Committer: Bill Speirs <ws...@apache.org>
Committed: Mon May 13 20:08:25 2013 +0000
----------------------------------------------------------------------
.../apache/commons/dbutils2/QueryLoader.java | 27 +++++++++++++++++---
1 file changed, 24 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/f28bd88b/src/main/java/org/apache/commons/dbutils2/QueryLoader.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/QueryLoader.java b/src/main/java/org/apache/commons/dbutils2/QueryLoader.java
index 59c1152..a9a1c74 100644
--- a/src/main/java/org/apache/commons/dbutils2/QueryLoader.java
+++ b/src/main/java/org/apache/commons/dbutils2/QueryLoader.java
@@ -19,8 +19,10 @@ package org.apache.commons.dbutils2;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
+import java.util.InvalidPropertiesFormatException;
import java.util.Map;
import java.util.Properties;
+import java.util.regex.Pattern;
/**
* <code>QueryLoader</code> is a registry for sets of queries so
@@ -36,6 +38,11 @@ public class QueryLoader {
private static final QueryLoader instance = new QueryLoader();
/**
+ * Matches .xml file extensions.
+ */
+ private static final Pattern dotXml = Pattern.compile(".+\\.[xX][mM][lL]");
+
+ /**
* Return an instance of this class.
*
* @return The Singleton instance.
@@ -59,7 +66,9 @@ public class QueryLoader {
/**
* Loads a Map of query names to SQL values. The Maps are cached so a
* subsequent request to load queries from the same path will return
- * the cached Map.
+ * the cached Map. The properties file to load can be in either
+ * line-oriented or XML format. XML formatted properties files must use a
+ * <code>.xml</code> file extension.
*
* @param path The path that the ClassLoader will use to find the file.
* This is <strong>not</strong> a file system path. If you had a jarred
@@ -68,7 +77,10 @@ public class QueryLoader {
* @throws IOException if a file access error occurs
* @throws IllegalArgumentException if the ClassLoader can't find a file at
* the given path.
+ * @throws InvalidPropertiesFormatException if the XML properties file is
+ * invalid
* @return Map of query names to SQL values
+ * @see java.util.Properties
*/
public synchronized Map<String, String> load(String path) throws IOException {
@@ -84,14 +96,19 @@ public class QueryLoader {
/**
* Loads a set of named queries into a Map object. This implementation
- * reads a properties file at the given path.
+ * reads a properties file at the given path. The properties file can be
+ * in either line-oriented or XML format. XML formatted properties files
+ * must use a <code>.xml</code> file extension.
*
* @param path The path that the ClassLoader will use to find the file.
* @throws IOException if a file access error occurs
* @throws IllegalArgumentException if the ClassLoader can't find a file at
* the given path.
+ * @throws InvalidPropertiesFormatException if the XML properties file is
+ * invalid
* @since 1.1
* @return Map of query names to SQL values
+ * @see java.util.Properties
*/
protected Map<String, String> loadQueries(String path) throws IOException {
// Findbugs flags getClass().getResource as a bad practice; maybe we should change the API?
@@ -103,7 +120,11 @@ public class QueryLoader {
Properties props = new Properties();
try {
- props.load(in);
+ if (dotXml.matcher(path).matches()) {
+ props.loadFromXML(in);
+ } else {
+ props.load(in);
+ }
} finally {
in.close();
}
[05/58] [abbrv] commons-dbutils git commit: Changed the package names
so dbutils and dbutils2 won't conflict if both loaded
Posted by th...@apache.org.
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/main/java/org/apache/commons/dbutils2/handlers/ArrayHandler.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/handlers/ArrayHandler.java b/src/main/java/org/apache/commons/dbutils2/handlers/ArrayHandler.java
new file mode 100644
index 0000000..0863894
--- /dev/null
+++ b/src/main/java/org/apache/commons/dbutils2/handlers/ArrayHandler.java
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.dbutils2.handlers;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+import org.apache.commons.dbutils2.BasicRowProcessor;
+import org.apache.commons.dbutils2.ResultSetHandler;
+import org.apache.commons.dbutils2.RowProcessor;
+
+/**
+ * <code>ResultSetHandler</code> implementation that converts a
+ * <code>ResultSet</code> into an <code>Object[]</code>. This class is
+ * thread safe.
+ *
+ * @see org.apache.commons.dbutils2.ResultSetHandler
+ */
+public class ArrayHandler implements ResultSetHandler<Object[]> {
+
+ /**
+ * Singleton processor instance that handlers share to save memory. Notice
+ * the default scoping to allow only classes in this package to use this
+ * instance.
+ */
+ static final RowProcessor ROW_PROCESSOR = new BasicRowProcessor();
+
+ /**
+ * The RowProcessor implementation to use when converting rows
+ * into arrays.
+ */
+ private final RowProcessor convert;
+
+ /**
+ * Creates a new instance of ArrayHandler using a
+ * <code>BasicRowProcessor</code> for conversion.
+ */
+ public ArrayHandler() {
+ this(ROW_PROCESSOR);
+ }
+
+ /**
+ * Creates a new instance of ArrayHandler.
+ *
+ * @param convert The <code>RowProcessor</code> implementation
+ * to use when converting rows into arrays.
+ */
+ public ArrayHandler(RowProcessor convert) {
+ super();
+ this.convert = convert;
+ }
+
+ /**
+ * Places the column values from the first row in an <code>Object[]</code>.
+ * @param rs <code>ResultSet</code> to process.
+ * @return An Object[] or <code>null</code> if there are no rows in the
+ * <code>ResultSet</code>.
+ *
+ * @throws SQLException if a database access error occurs
+ * @see org.apache.commons.dbutils2.ResultSetHandler#handle(java.sql.ResultSet)
+ */
+ @Override
+ public Object[] handle(ResultSet rs) throws SQLException {
+ return rs.next() ? this.convert.toArray(rs) : null;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/main/java/org/apache/commons/dbutils2/handlers/ArrayListHandler.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/handlers/ArrayListHandler.java b/src/main/java/org/apache/commons/dbutils2/handlers/ArrayListHandler.java
new file mode 100644
index 0000000..6328c58
--- /dev/null
+++ b/src/main/java/org/apache/commons/dbutils2/handlers/ArrayListHandler.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.dbutils2.handlers;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+import org.apache.commons.dbutils2.RowProcessor;
+
+/**
+ * <code>ResultSetHandler</code> implementation that converts the
+ * <code>ResultSet</code> into a <code>List</code> of <code>Object[]</code>s.
+ * This class is thread safe.
+ *
+ * @see org.apache.commons.dbutils2.ResultSetHandler
+ */
+public class ArrayListHandler extends AbstractListHandler<Object[]> {
+
+ /**
+ * The RowProcessor implementation to use when converting rows
+ * into Object[]s.
+ */
+ private final RowProcessor convert;
+
+ /**
+ * Creates a new instance of ArrayListHandler using a
+ * <code>BasicRowProcessor</code> for conversions.
+ */
+ public ArrayListHandler() {
+ this(ArrayHandler.ROW_PROCESSOR);
+ }
+
+ /**
+ * Creates a new instance of ArrayListHandler.
+ *
+ * @param convert The <code>RowProcessor</code> implementation
+ * to use when converting rows into Object[]s.
+ */
+ public ArrayListHandler(RowProcessor convert) {
+ super();
+ this.convert = convert;
+ }
+
+
+ /**
+ * Convert row's columns into an <code>Object[]</code>.
+ * @param rs <code>ResultSet</code> to process.
+ * @return <code>Object[]</code>, never <code>null</code>.
+ *
+ * @throws SQLException if a database access error occurs
+ * @see org.apache.commons.dbutils2.handlers.AbstractListHandler#handle(ResultSet)
+ */
+ @Override
+ protected Object[] handleRow(ResultSet rs) throws SQLException {
+ return this.convert.toArray(rs);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/main/java/org/apache/commons/dbutils2/handlers/BeanHandler.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/handlers/BeanHandler.java b/src/main/java/org/apache/commons/dbutils2/handlers/BeanHandler.java
new file mode 100644
index 0000000..9146bd0
--- /dev/null
+++ b/src/main/java/org/apache/commons/dbutils2/handlers/BeanHandler.java
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.dbutils2.handlers;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+import org.apache.commons.dbutils2.ResultSetHandler;
+import org.apache.commons.dbutils2.RowProcessor;
+
+/**
+ * <code>ResultSetHandler</code> implementation that converts the first
+ * <code>ResultSet</code> row into a JavaBean. This class is thread safe.
+ *
+ * @param <T> the target bean type
+ * @see org.apache.commons.dbutils2.ResultSetHandler
+ */
+public class BeanHandler<T> implements ResultSetHandler<T> {
+
+ /**
+ * The Class of beans produced by this handler.
+ */
+ private final Class<T> type;
+
+ /**
+ * The RowProcessor implementation to use when converting rows
+ * into beans.
+ */
+ private final RowProcessor convert;
+
+ /**
+ * Creates a new instance of BeanHandler.
+ *
+ * @param type The Class that objects returned from <code>handle()</code>
+ * are created from.
+ */
+ public BeanHandler(Class<T> type) {
+ this(type, ArrayHandler.ROW_PROCESSOR);
+ }
+
+ /**
+ * Creates a new instance of BeanHandler.
+ *
+ * @param type The Class that objects returned from <code>handle()</code>
+ * are created from.
+ * @param convert The <code>RowProcessor</code> implementation
+ * to use when converting rows into beans.
+ */
+ public BeanHandler(Class<T> type, RowProcessor convert) {
+ this.type = type;
+ this.convert = convert;
+ }
+
+ /**
+ * Convert the first row of the <code>ResultSet</code> into a bean with the
+ * <code>Class</code> given in the constructor.
+ * @param rs <code>ResultSet</code> to process.
+ * @return An initialized JavaBean or <code>null</code> if there were no
+ * rows in the <code>ResultSet</code>.
+ *
+ * @throws SQLException if a database access error occurs
+ * @see org.apache.commons.dbutils2.ResultSetHandler#handle(java.sql.ResultSet)
+ */
+ @Override
+ public T handle(ResultSet rs) throws SQLException {
+ return rs.next() ? this.convert.toBean(rs, this.type) : null;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/main/java/org/apache/commons/dbutils2/handlers/BeanListHandler.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/handlers/BeanListHandler.java b/src/main/java/org/apache/commons/dbutils2/handlers/BeanListHandler.java
new file mode 100644
index 0000000..2997926
--- /dev/null
+++ b/src/main/java/org/apache/commons/dbutils2/handlers/BeanListHandler.java
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.dbutils2.handlers;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.List;
+
+import org.apache.commons.dbutils2.ResultSetHandler;
+import org.apache.commons.dbutils2.RowProcessor;
+
+/**
+ * <code>ResultSetHandler</code> implementation that converts a
+ * <code>ResultSet</code> into a <code>List</code> of beans. This class is
+ * thread safe.
+ *
+ * @param <T> the target bean type
+ * @see org.apache.commons.dbutils2.ResultSetHandler
+ */
+public class BeanListHandler<T> implements ResultSetHandler<List<T>> {
+
+ /**
+ * The Class of beans produced by this handler.
+ */
+ private final Class<T> type;
+
+ /**
+ * The RowProcessor implementation to use when converting rows
+ * into beans.
+ */
+ private final RowProcessor convert;
+
+ /**
+ * Creates a new instance of BeanListHandler.
+ *
+ * @param type The Class that objects returned from <code>handle()</code>
+ * are created from.
+ */
+ public BeanListHandler(Class<T> type) {
+ this(type, ArrayHandler.ROW_PROCESSOR);
+ }
+
+ /**
+ * Creates a new instance of BeanListHandler.
+ *
+ * @param type The Class that objects returned from <code>handle()</code>
+ * are created from.
+ * @param convert The <code>RowProcessor</code> implementation
+ * to use when converting rows into beans.
+ */
+ public BeanListHandler(Class<T> type, RowProcessor convert) {
+ this.type = type;
+ this.convert = convert;
+ }
+
+ /**
+ * Convert the whole <code>ResultSet</code> into a List of beans with
+ * the <code>Class</code> given in the constructor.
+ *
+ * @param rs The <code>ResultSet</code> to handle.
+ *
+ * @return A List of beans, never <code>null</code>.
+ *
+ * @throws SQLException if a database access error occurs
+ * @see org.apache.commons.dbutils2.RowProcessor#toBeanList(ResultSet, Class)
+ */
+ @Override
+ public List<T> handle(ResultSet rs) throws SQLException {
+ return this.convert.toBeanList(rs, type);
+ }
+}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/main/java/org/apache/commons/dbutils2/handlers/BeanMapHandler.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/handlers/BeanMapHandler.java b/src/main/java/org/apache/commons/dbutils2/handlers/BeanMapHandler.java
new file mode 100644
index 0000000..6f37fca
--- /dev/null
+++ b/src/main/java/org/apache/commons/dbutils2/handlers/BeanMapHandler.java
@@ -0,0 +1,185 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.dbutils2.handlers;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+import org.apache.commons.dbutils2.RowProcessor;
+
+/**
+ * <p>
+ * <code>ResultSetHandler</code> implementation that returns a Map of Beans.
+ * <code>ResultSet</code> rows are converted into Beans which are then stored in
+ * a Map under the given key.
+ * </p>
+ * <p>
+ * If you had a Person table with a primary key column called ID, you could
+ * retrieve rows from the table like this:
+ *
+ * <pre>
+ * ResultSetHandler<Map<Long, Person>> h = new BeanMapdHandler<Long, Person>(Person.class, "id");
+ * Map&ltLong, Person> found = queryRunner.query("select id, name, age from person", h);
+ * Person jane = found.get(1L); // jane's id is 1
+ * String janesName = jane.getName();
+ * Integer janesAge = jane.getAge();
+ * </pre>
+ *
+ * Note that the "id" passed to BeanMapHandler can be in any case. The data type
+ * returned for id is dependent upon how your JDBC driver converts SQL column
+ * types from the Person table into Java types. The "name" and "age" columns are
+ * converted according to their property descriptors by DbUtils.
+ * </p>
+ * <p>
+ * This class is thread safe.
+ * </p>
+ *
+ * @param <K>
+ * the type of keys maintained by the returned map
+ * @param <V>
+ * the type of the bean
+ * @see org.apache.commons.dbutils2.ResultSetHandler
+ * @since DbUtils 1.5
+ */
+public class BeanMapHandler<K, V> extends AbstractKeyedHandler<K, V> {
+
+ /**
+ * The Class of beans produced by this handler.
+ */
+ private final Class<V> type;
+
+ /**
+ * The RowProcessor implementation to use when converting rows into Objects.
+ */
+ private final RowProcessor convert;
+
+ /**
+ * The column index to retrieve key values from. Defaults to 1.
+ */
+ private final int columnIndex;
+
+ /**
+ * The column name to retrieve key values from. Either columnName or
+ * columnIndex will be used but never both.
+ */
+ private final String columnName;
+
+ /**
+ * Creates a new instance of BeanMapHandler. The value of the first column
+ * of each row will be a key in the Map.
+ *
+ * @param type
+ * The Class that objects returned from <code>createRow()</code>
+ * are created from.
+ */
+ public BeanMapHandler(Class<V> type) {
+ this(type, ArrayHandler.ROW_PROCESSOR, 1, null);
+ }
+
+ /**
+ * Creates a new instance of BeanMapHandler. The value of the first column
+ * of each row will be a key in the Map.
+ *
+ * @param type
+ * The Class that objects returned from <code>createRow()</code>
+ * are created from.
+ * @param convert
+ * The <code>RowProcessor</code> implementation to use when
+ * converting rows into Beans
+ */
+ public BeanMapHandler(Class<V> type, RowProcessor convert) {
+ this(type, convert, 1, null);
+ }
+
+ /**
+ * Creates a new instance of BeanMapHandler.
+ *
+ * @param type
+ * The Class that objects returned from <code>createRow()</code>
+ * are created from.
+ * @param columnIndex
+ * The values to use as keys in the Map are retrieved from the
+ * column at this index.
+ */
+ public BeanMapHandler(Class<V> type, int columnIndex) {
+ this(type, ArrayHandler.ROW_PROCESSOR, columnIndex, null);
+ }
+
+ /**
+ * Creates a new instance of BeanMapHandler.
+ *
+ * @param type
+ * The Class that objects returned from <code>createRow()</code>
+ * are created from.
+ * @param columnName
+ * The values to use as keys in the Map are retrieved from the
+ * column with this name.
+ */
+ public BeanMapHandler(Class<V> type, String columnName) {
+ this(type, ArrayHandler.ROW_PROCESSOR, 1, columnName);
+ }
+
+ /**
+ * Private Helper
+ *
+ * @param convert
+ * The <code>RowProcessor</code> implementation to use when
+ * converting rows into Beans
+ * @param columnIndex
+ * The values to use as keys in the Map are retrieved from the
+ * column at this index.
+ * @param columnName
+ * The values to use as keys in the Map are retrieved from the
+ * column with this name.
+ */
+ private BeanMapHandler(Class<V> type, RowProcessor convert,
+ int columnIndex, String columnName) {
+ super();
+ this.type = type;
+ this.convert = convert;
+ this.columnIndex = columnIndex;
+ this.columnName = columnName;
+ }
+
+ /**
+ * This factory method is called by <code>handle()</code> to retrieve the
+ * key value from the current <code>ResultSet</code> row.
+ * @param rs ResultSet to create a key from
+ *
+ * @return K from the configured key column name/index
+ *
+ * @throws SQLException if a database access error occurs
+ * @throws ClassCastException if the class datatype does not match the column type
+ *
+ * @see org.apache.commons.dbutils2.handlers.AbstractKeyedHandler#createKey(ResultSet)
+ */
+ // We assume that the user has picked the correct type to match the column
+ // so getObject will return the appropriate type and the cast will succeed.
+ @SuppressWarnings("unchecked")
+ @Override
+ protected K createKey(ResultSet rs) throws SQLException {
+ return (columnName == null) ?
+ (K) rs.getObject(columnIndex) :
+ (K) rs.getObject(columnName);
+ }
+
+ @Override
+ protected V createRow(ResultSet rs) throws SQLException {
+ return this.convert.toBean(rs, type);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/main/java/org/apache/commons/dbutils2/handlers/ColumnListHandler.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/handlers/ColumnListHandler.java b/src/main/java/org/apache/commons/dbutils2/handlers/ColumnListHandler.java
new file mode 100644
index 0000000..a432682
--- /dev/null
+++ b/src/main/java/org/apache/commons/dbutils2/handlers/ColumnListHandler.java
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.dbutils2.handlers;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+/**
+ * <code>ResultSetHandler</code> implementation that converts one
+ * <code>ResultSet</code> column into a <code>List</code> of
+ * <code>Object</code>s. This class is thread safe.
+ *
+ * @param <T> The type of the column.
+ * @see org.apache.commons.dbutils2.ResultSetHandler
+ * @since DbUtils 1.1
+ */
+public class ColumnListHandler<T> extends AbstractListHandler<T> {
+
+ /**
+ * The column number to retrieve.
+ */
+ private final int columnIndex;
+
+ /**
+ * The column name to retrieve. Either columnName or columnIndex
+ * will be used but never both.
+ */
+ private final String columnName;
+
+ /**
+ * Creates a new instance of ColumnListHandler. The first column of each
+ * row will be returned from <code>handle()</code>.
+ */
+ public ColumnListHandler() {
+ this(1, null);
+ }
+
+ /**
+ * Creates a new instance of ColumnListHandler.
+ *
+ * @param columnIndex The index of the column to retrieve from the
+ * <code>ResultSet</code>.
+ */
+ public ColumnListHandler(int columnIndex) {
+ this(columnIndex, null);
+ }
+
+ /**
+ * Creates a new instance of ColumnListHandler.
+ *
+ * @param columnName The name of the column to retrieve from the
+ * <code>ResultSet</code>.
+ */
+ public ColumnListHandler(String columnName) {
+ this(1, columnName);
+ }
+
+ /** Private Helper
+ * @param columnIndex The index of the column to retrieve from the
+ * <code>ResultSet</code>.
+ * @param columnName The name of the column to retrieve from the
+ * <code>ResultSet</code>.
+ */
+ private ColumnListHandler(int columnIndex, String columnName) {
+ super();
+ this.columnIndex = columnIndex;
+ this.columnName = columnName;
+ }
+
+ /**
+ * Returns one <code>ResultSet</code> column value as <code>Object</code>.
+ * @param rs <code>ResultSet</code> to process.
+ * @return <code>Object</code>, never <code>null</code>.
+ *
+ * @throws SQLException if a database access error occurs
+ * @throws ClassCastException if the class datatype does not match the column type
+ *
+ * @see org.apache.commons.dbutils2.handlers.AbstractListHandler#handle(ResultSet)
+ */
+ // We assume that the user has picked the correct type to match the column
+ // so getObject will return the appropriate type and the cast will succeed.
+ @SuppressWarnings("unchecked")
+ @Override
+ protected T handleRow(ResultSet rs) throws SQLException {
+ if (this.columnName == null) {
+ return (T) rs.getObject(this.columnIndex);
+ }
+ return (T) rs.getObject(this.columnName);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/main/java/org/apache/commons/dbutils2/handlers/KeyedHandler.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/handlers/KeyedHandler.java b/src/main/java/org/apache/commons/dbutils2/handlers/KeyedHandler.java
new file mode 100644
index 0000000..f7fe89a
--- /dev/null
+++ b/src/main/java/org/apache/commons/dbutils2/handlers/KeyedHandler.java
@@ -0,0 +1,161 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.dbutils2.handlers;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.Map;
+
+import org.apache.commons.dbutils2.RowProcessor;
+
+/**
+ * <p>
+ * <code>ResultSetHandler</code> implementation that returns a Map of Maps.
+ * <code>ResultSet</code> rows are converted into Maps which are then stored
+ * in a Map under the given key.
+ * </p>
+ * <p>
+ * If you had a Person table with a primary key column called ID, you could
+ * retrieve rows from the table like this:
+ * <pre>
+ * ResultSetHandler h = new KeyedHandler("id");
+ * Map found = (Map) queryRunner.query("select id, name, age from person", h);
+ * Map jane = (Map) found.get(new Long(1)); // jane's id is 1
+ * String janesName = (String) jane.get("name");
+ * Integer janesAge = (Integer) jane.get("age");
+ * </pre>
+ * Note that the "id" passed to KeyedHandler and "name" and "age" passed to the
+ * returned Map's get() method can be in any case. The data types returned for
+ * name and age are dependent upon how your JDBC driver converts SQL column
+ * types from the Person table into Java types.
+ * </p>
+ * <p>This class is thread safe.</p>
+ *
+ * @param <K> The type of the key
+ * @see org.apache.commons.dbutils2.ResultSetHandler
+ * @since DbUtils 1.1
+ */
+public class KeyedHandler<K> extends AbstractKeyedHandler<K, Map<String, Object>> {
+
+ /**
+ * The RowProcessor implementation to use when converting rows
+ * into Objects.
+ */
+ protected final RowProcessor convert;
+
+ /**
+ * The column index to retrieve key values from. Defaults to 1.
+ */
+ protected final int columnIndex;
+
+ /**
+ * The column name to retrieve key values from. Either columnName or
+ * columnIndex will be used but never both.
+ */
+ protected final String columnName;
+
+ /**
+ * Creates a new instance of KeyedHandler. The value of the first column
+ * of each row will be a key in the Map.
+ */
+ public KeyedHandler() {
+ this(ArrayHandler.ROW_PROCESSOR, 1, null);
+ }
+
+ /**
+ * Creates a new instance of KeyedHandler. The value of the first column
+ * of each row will be a key in the Map.
+ *
+ * @param convert The <code>RowProcessor</code> implementation
+ * to use when converting rows into Maps
+ */
+ public KeyedHandler(RowProcessor convert) {
+ this(convert, 1, null);
+ }
+
+ /**
+ * Creates a new instance of KeyedHandler.
+ *
+ * @param columnIndex The values to use as keys in the Map are
+ * retrieved from the column at this index.
+ */
+ public KeyedHandler(int columnIndex) {
+ this(ArrayHandler.ROW_PROCESSOR, columnIndex, null);
+ }
+
+ /**
+ * Creates a new instance of KeyedHandler.
+ *
+ * @param columnName The values to use as keys in the Map are
+ * retrieved from the column with this name.
+ */
+ public KeyedHandler(String columnName) {
+ this(ArrayHandler.ROW_PROCESSOR, 1, columnName);
+ }
+
+ /** Private Helper
+ * @param convert The <code>RowProcessor</code> implementation
+ * to use when converting rows into Maps
+ * @param columnIndex The values to use as keys in the Map are
+ * retrieved from the column at this index.
+ * @param columnName The values to use as keys in the Map are
+ * retrieved from the column with this name.
+ */
+ private KeyedHandler(RowProcessor convert, int columnIndex,
+ String columnName) {
+ super();
+ this.convert = convert;
+ this.columnIndex = columnIndex;
+ this.columnName = columnName;
+ }
+ /**
+ * This factory method is called by <code>handle()</code> to retrieve the
+ * key value from the current <code>ResultSet</code> row. This
+ * implementation returns <code>ResultSet.getObject()</code> for the
+ * configured key column name or index.
+ * @param rs ResultSet to create a key from
+ * @return Object from the configured key column name/index
+ *
+ * @throws SQLException if a database access error occurs
+ * @throws ClassCastException if the class datatype does not match the column type
+ */
+ // We assume that the user has picked the correct type to match the column
+ // so getObject will return the appropriate type and the cast will succeed.
+ @SuppressWarnings("unchecked")
+ @Override
+ protected K createKey(ResultSet rs) throws SQLException {
+ return (columnName == null) ?
+ (K) rs.getObject(columnIndex) :
+ (K) rs.getObject(columnName);
+ }
+
+ /**
+ * This factory method is called by <code>handle()</code> to store the
+ * current <code>ResultSet</code> row in some object. This
+ * implementation returns a <code>Map</code> with case insensitive column
+ * names as keys. Calls to <code>map.get("COL")</code> and
+ * <code>map.get("col")</code> return the same value.
+ * @param rs ResultSet to create a row from
+ * @return Object typed Map containing column names to values
+ * @throws SQLException if a database access error occurs
+ */
+ @Override
+ protected Map<String, Object> createRow(ResultSet rs) throws SQLException {
+ return this.convert.toMap(rs);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/main/java/org/apache/commons/dbutils2/handlers/MapHandler.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/handlers/MapHandler.java b/src/main/java/org/apache/commons/dbutils2/handlers/MapHandler.java
new file mode 100644
index 0000000..c767948
--- /dev/null
+++ b/src/main/java/org/apache/commons/dbutils2/handlers/MapHandler.java
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.dbutils2.handlers;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.Map;
+
+import org.apache.commons.dbutils2.ResultSetHandler;
+import org.apache.commons.dbutils2.RowProcessor;
+
+/**
+ * <code>ResultSetHandler</code> implementation that converts the first
+ * <code>ResultSet</code> row into a <code>Map</code>. This class is thread
+ * safe.
+ *
+ * @see org.apache.commons.dbutils2.ResultSetHandler
+ */
+public class MapHandler implements ResultSetHandler<Map<String, Object>> {
+
+ /**
+ * The RowProcessor implementation to use when converting rows
+ * into Maps.
+ */
+ private final RowProcessor convert;
+
+ /**
+ * Creates a new instance of MapHandler using a
+ * <code>BasicRowProcessor</code> for conversion.
+ */
+ public MapHandler() {
+ this(ArrayHandler.ROW_PROCESSOR);
+ }
+
+ /**
+ * Creates a new instance of MapHandler.
+ *
+ * @param convert The <code>RowProcessor</code> implementation
+ * to use when converting rows into Maps.
+ */
+ public MapHandler(RowProcessor convert) {
+ super();
+ this.convert = convert;
+ }
+
+ /**
+ * Converts the first row in the <code>ResultSet</code> into a
+ * <code>Map</code>.
+ * @param rs <code>ResultSet</code> to process.
+ * @return A <code>Map</code> with the values from the first row or
+ * <code>null</code> if there are no rows in the <code>ResultSet</code>.
+ *
+ * @throws SQLException if a database access error occurs
+ *
+ * @see org.apache.commons.dbutils2.ResultSetHandler#handle(java.sql.ResultSet)
+ */
+ @Override
+ public Map<String, Object> handle(ResultSet rs) throws SQLException {
+ return rs.next() ? this.convert.toMap(rs) : null;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/main/java/org/apache/commons/dbutils2/handlers/MapListHandler.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/handlers/MapListHandler.java b/src/main/java/org/apache/commons/dbutils2/handlers/MapListHandler.java
new file mode 100644
index 0000000..f557f59
--- /dev/null
+++ b/src/main/java/org/apache/commons/dbutils2/handlers/MapListHandler.java
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.dbutils2.handlers;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.Map;
+
+import org.apache.commons.dbutils2.RowProcessor;
+
+/**
+ * <code>ResultSetHandler</code> implementation that converts a
+ * <code>ResultSet</code> into a <code>List</code> of <code>Map</code>s.
+ * This class is thread safe.
+ *
+ * @see org.apache.commons.dbutils2.ResultSetHandler
+ */
+public class MapListHandler extends AbstractListHandler<Map<String, Object>> {
+
+ /**
+ * The RowProcessor implementation to use when converting rows
+ * into Maps.
+ */
+ private final RowProcessor convert;
+
+ /**
+ * Creates a new instance of MapListHandler using a
+ * <code>BasicRowProcessor</code> for conversion.
+ */
+ public MapListHandler() {
+ this(ArrayHandler.ROW_PROCESSOR);
+ }
+
+ /**
+ * Creates a new instance of MapListHandler.
+ *
+ * @param convert The <code>RowProcessor</code> implementation
+ * to use when converting rows into Maps.
+ */
+ public MapListHandler(RowProcessor convert) {
+ super();
+ this.convert = convert;
+ }
+
+ /**
+ * Converts the <code>ResultSet</code> row into a <code>Map</code> object.
+ * @param rs <code>ResultSet</code> to process.
+ * @return A <code>Map</code>, never null.
+ *
+ * @throws SQLException if a database access error occurs
+ *
+ * @see org.apache.commons.dbutils2.handlers.AbstractListHandler#handle(ResultSet)
+ */
+ @Override
+ protected Map<String, Object> handleRow(ResultSet rs) throws SQLException {
+ return this.convert.toMap(rs);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/main/java/org/apache/commons/dbutils2/handlers/ScalarHandler.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/handlers/ScalarHandler.java b/src/main/java/org/apache/commons/dbutils2/handlers/ScalarHandler.java
new file mode 100644
index 0000000..902c380
--- /dev/null
+++ b/src/main/java/org/apache/commons/dbutils2/handlers/ScalarHandler.java
@@ -0,0 +1,110 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.dbutils2.handlers;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+import org.apache.commons.dbutils2.ResultSetHandler;
+
+/**
+ * <code>ResultSetHandler</code> implementation that converts one
+ * <code>ResultSet</code> column into an Object. This class is thread safe.
+ *
+ * @param <T> The type of the scalar
+ * @see org.apache.commons.dbutils2.ResultSetHandler
+ */
+public class ScalarHandler<T> implements ResultSetHandler<T> {
+
+ /**
+ * The column number to retrieve.
+ */
+ private final int columnIndex;
+
+ /**
+ * The column name to retrieve. Either columnName or columnIndex
+ * will be used but never both.
+ */
+ private final String columnName;
+
+ /**
+ * Creates a new instance of ScalarHandler. The first column will
+ * be returned from <code>handle()</code>.
+ */
+ public ScalarHandler() {
+ this(1, null);
+ }
+
+ /**
+ * Creates a new instance of ScalarHandler.
+ *
+ * @param columnIndex The index of the column to retrieve from the
+ * <code>ResultSet</code>.
+ */
+ public ScalarHandler(int columnIndex) {
+ this(columnIndex, null);
+ }
+
+ /**
+ * Creates a new instance of ScalarHandler.
+ *
+ * @param columnName The name of the column to retrieve from the
+ * <code>ResultSet</code>.
+ */
+ public ScalarHandler(String columnName) {
+ this(1, columnName);
+ }
+
+ /** Helper constructor
+ * @param columnIndex The index of the column to retrieve from the
+ * <code>ResultSet</code>.
+ * @param columnName The name of the column to retrieve from the
+ * <code>ResultSet</code>.
+ */
+ private ScalarHandler(int columnIndex, String columnName) {
+ this.columnIndex = columnIndex;
+ this.columnName = columnName;
+ }
+
+ /**
+ * Returns one <code>ResultSet</code> column as an object via the
+ * <code>ResultSet.getObject()</code> method that performs type
+ * conversions.
+ * @param rs <code>ResultSet</code> to process.
+ * @return The column or <code>null</code> if there are no rows in
+ * the <code>ResultSet</code>.
+ *
+ * @throws SQLException if a database access error occurs
+ * @throws ClassCastException if the class datatype does not match the column type
+ *
+ * @see org.apache.commons.dbutils2.ResultSetHandler#handle(java.sql.ResultSet)
+ */
+ // We assume that the user has picked the correct type to match the column
+ // so getObject will return the appropriate type and the cast will succeed.
+ @SuppressWarnings("unchecked")
+ @Override
+ public T handle(ResultSet rs) throws SQLException {
+
+ if (rs.next()) {
+ if (this.columnName == null) {
+ return (T) rs.getObject(this.columnIndex);
+ }
+ return (T) rs.getObject(this.columnName);
+ }
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/main/java/org/apache/commons/dbutils2/handlers/package-info.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/handlers/package-info.java b/src/main/java/org/apache/commons/dbutils2/handlers/package-info.java
new file mode 100644
index 0000000..6cc9e99
--- /dev/null
+++ b/src/main/java/org/apache/commons/dbutils2/handlers/package-info.java
@@ -0,0 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Implementations of the org.apache.commons.dbutils.ResultSetHandler interface.
+ */
+package org.apache.commons.dbutils2.handlers;
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/main/java/org/apache/commons/dbutils2/package-info.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/package-info.java b/src/main/java/org/apache/commons/dbutils2/package-info.java
new file mode 100644
index 0000000..e3a98fb
--- /dev/null
+++ b/src/main/java/org/apache/commons/dbutils2/package-info.java
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * DbUtils is a small set of classes designed to make working with JDBC easier. JDBC resource cleanup code is mundane,
+ * error prone work so these classes abstract out all of the cleanup tasks from your code leaving you with what you
+ * really wanted to do with JDBC in the first place: query and update data.
+ *
+ * This package contains the core classes and interfaces - DbUtils, QueryRunner and the ResultSetHandler interface
+ * should be your first items of interest.
+ */
+package org.apache.commons.dbutils2;
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/main/java/org/apache/commons/dbutils2/wrappers/SqlNullCheckedResultSet.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/wrappers/SqlNullCheckedResultSet.java b/src/main/java/org/apache/commons/dbutils2/wrappers/SqlNullCheckedResultSet.java
new file mode 100644
index 0000000..7868e66
--- /dev/null
+++ b/src/main/java/org/apache/commons/dbutils2/wrappers/SqlNullCheckedResultSet.java
@@ -0,0 +1,608 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.dbutils2.wrappers;
+
+import java.io.InputStream;
+import java.io.Reader;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.math.BigDecimal;
+import java.net.URL;
+import java.sql.Blob;
+import java.sql.Clob;
+import java.sql.Date;
+import java.sql.Ref;
+import java.sql.ResultSet;
+import java.sql.Time;
+import java.sql.Timestamp;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.commons.dbutils2.ProxyFactory;
+
+/**
+ * Decorates a <code>ResultSet</code> with checks for a SQL NULL value on each
+ * <code>getXXX</code> method. If a column value obtained by a
+ * <code>getXXX</code> method is not SQL NULL, the column value is returned. If
+ * the column value is SQL null, an alternate value is returned. The alternate
+ * value defaults to the Java <code>null</code> value, which can be overridden
+ * for instances of the class.
+ *
+ * <p>
+ * Usage example:
+ * <blockquote>
+ * <pre>
+ * Connection conn = // somehow get a connection
+ * Statement stmt = conn.createStatement();
+ * ResultSet rs = stmt.executeQuery("SELECT col1, col2 FROM table1");
+ *
+ * // Wrap the result set for SQL NULL checking
+ * SqlNullCheckedResultSet wrapper = new SqlNullCheckedResultSet(rs);
+ * wrapper.setNullString("---N/A---"); // Set null string
+ * wrapper.setNullInt(-999); // Set null integer
+ * rs = ProxyFactory.instance().createResultSet(wrapper);
+ *
+ * while (rs.next()) {
+ * // If col1 is SQL NULL, value returned will be "---N/A---"
+ * String col1 = rs.getString("col1");
+ * // If col2 is SQL NULL, value returned will be -999
+ * int col2 = rs.getInt("col2");
+ * }
+ * rs.close();
+ * </pre>
+ * </blockquote>
+ * </p>
+ * <p>Unlike some other classes in DbUtils, this class is NOT thread-safe.</p>
+ */
+public class SqlNullCheckedResultSet implements InvocationHandler {
+
+ /**
+ * Maps normal method names (ie. "getBigDecimal") to the corresponding null
+ * Method object (ie. getNullBigDecimal).
+ */
+ private static final Map<String, Method> nullMethods = new HashMap<String, Method>();
+
+ /**
+ * The {@code getNull} string prefix.
+ * @since 1.4
+ */
+ private static final String GET_NULL_PREFIX = "getNull";
+
+ static {
+ Method[] methods = SqlNullCheckedResultSet.class.getMethods();
+ for (int i = 0; i < methods.length; i++) {
+ String methodName = methods[i].getName();
+
+ if (methodName.startsWith(GET_NULL_PREFIX)) {
+ String normalName = "get" + methodName.substring(GET_NULL_PREFIX.length());
+ nullMethods.put(normalName, methods[i]);
+ }
+ }
+ }
+
+ /**
+ * The factory to create proxies with.
+ */
+ private static final ProxyFactory factory = ProxyFactory.instance();
+
+ /**
+ * Wraps the <code>ResultSet</code> in an instance of this class. This is
+ * equivalent to:
+ * <pre>
+ * ProxyFactory.instance().createResultSet(new SqlNullCheckedResultSet(rs));
+ * </pre>
+ *
+ * @param rs The <code>ResultSet</code> to wrap.
+ * @return wrapped ResultSet
+ */
+ public static ResultSet wrap(ResultSet rs) {
+ return factory.createResultSet(new SqlNullCheckedResultSet(rs));
+ }
+
+ private InputStream nullAsciiStream = null;
+ private BigDecimal nullBigDecimal = null;
+ private InputStream nullBinaryStream = null;
+ private Blob nullBlob = null;
+ private boolean nullBoolean = false;
+ private byte nullByte = 0;
+ private byte[] nullBytes = null;
+ private Reader nullCharacterStream = null;
+ private Clob nullClob = null;
+ private Date nullDate = null;
+ private double nullDouble = 0.0;
+ private float nullFloat = 0.0f;
+ private int nullInt = 0;
+ private long nullLong = 0;
+ private Object nullObject = null;
+ private Ref nullRef = null;
+ private short nullShort = 0;
+ private String nullString = null;
+ private Time nullTime = null;
+ private Timestamp nullTimestamp = null;
+ private URL nullURL = null;
+
+ /**
+ * The wrapped result.
+ */
+ private final ResultSet rs;
+
+ /**
+ * Constructs a new instance of
+ * <code>SqlNullCheckedResultSet</code>
+ * to wrap the specified <code>ResultSet</code>.
+ * @param rs ResultSet to wrap
+ */
+ public SqlNullCheckedResultSet(ResultSet rs) {
+ super();
+ this.rs = rs;
+ }
+
+ /**
+ * Returns the value when a SQL null is encountered as the result of
+ * invoking a <code>getAsciiStream</code> method.
+ *
+ * @return the value
+ */
+ public InputStream getNullAsciiStream() {
+ return this.nullAsciiStream;
+ }
+
+ /**
+ * Returns the value when a SQL null is encountered as the result of
+ * invoking a <code>getBigDecimal</code> method.
+ *
+ * @return the value
+ */
+ public BigDecimal getNullBigDecimal() {
+ return this.nullBigDecimal;
+ }
+
+ /**
+ * Returns the value when a SQL null is encountered as the result of
+ * invoking a <code>getBinaryStream</code> method.
+ *
+ * @return the value
+ */
+ public InputStream getNullBinaryStream() {
+ return this.nullBinaryStream;
+ }
+
+ /**
+ * Returns the value when a SQL null is encountered as the result of
+ * invoking a <code>getBlob</code> method.
+ *
+ * @return the value
+ */
+ public Blob getNullBlob() {
+ return this.nullBlob;
+ }
+
+ /**
+ * Returns the value when a SQL null is encountered as the result of
+ * invoking a <code>getBoolean</code> method.
+ *
+ * @return the value
+ */
+ public boolean getNullBoolean() {
+ return this.nullBoolean;
+ }
+
+ /**
+ * Returns the value when a SQL null is encountered as the result of
+ * invoking a <code>getByte</code> method.
+ *
+ * @return the value
+ */
+ public byte getNullByte() {
+ return this.nullByte;
+ }
+
+ /**
+ * Returns the value when a SQL null is encountered as the result of
+ * invoking a <code>getBytes</code> method.
+ *
+ * @return the value
+ */
+ public byte[] getNullBytes() {
+ if (this.nullBytes == null) {
+ return null;
+ }
+ byte[] copy = new byte[this.nullBytes.length];
+ System.arraycopy(this.nullBytes, 0, copy, 0, this.nullBytes.length);
+ return copy;
+ }
+
+ /**
+ * Returns the value when a SQL null is encountered as the result of
+ * invoking a <code>getCharacterStream</code> method.
+ *
+ * @return the value
+ */
+ public Reader getNullCharacterStream() {
+ return this.nullCharacterStream;
+ }
+
+ /**
+ * Returns the value when a SQL null is encountered as the result of
+ * invoking a <code>getClob</code> method.
+ *
+ * @return the value
+ */
+ public Clob getNullClob() {
+ return this.nullClob;
+ }
+
+ /**
+ * Returns the value when a SQL null is encountered as the result of
+ * invoking a <code>getDate</code> method.
+ *
+ * @return the value
+ */
+ public Date getNullDate() {
+ return this.nullDate;
+ }
+
+ /**
+ * Returns the value when a SQL null is encountered as the result of
+ * invoking a <code>getDouble</code> method.
+ *
+ * @return the value
+ */
+ public double getNullDouble() {
+ return this.nullDouble;
+ }
+
+ /**
+ * Returns the value when a SQL null is encountered as the result of
+ * invoking a <code>getFloat</code> method.
+ *
+ * @return the value
+ */
+ public float getNullFloat() {
+ return this.nullFloat;
+ }
+
+ /**
+ * Returns the value when a SQL null is encountered as the result of
+ * invoking a <code>getInt</code> method.
+ *
+ * @return the value
+ */
+ public int getNullInt() {
+ return this.nullInt;
+ }
+
+ /**
+ * Returns the value when a SQL null is encountered as the result of
+ * invoking a <code>getLong</code> method.
+ *
+ * @return the value
+ */
+ public long getNullLong() {
+ return this.nullLong;
+ }
+
+ /**
+ * Returns the value when a SQL null is encountered as the result of
+ * invoking a <code>getObject</code> method.
+ *
+ * @return the value
+ */
+ public Object getNullObject() {
+ return this.nullObject;
+ }
+
+ /**
+ * Returns the value when a SQL null is encountered as the result of
+ * invoking a <code>getRef</code> method.
+ *
+ * @return the value
+ */
+ public Ref getNullRef() {
+ return this.nullRef;
+ }
+
+ /**
+ * Returns the value when a SQL null is encountered as the result of
+ * invoking a <code>getShort</code> method.
+ *
+ * @return the value
+ */
+ public short getNullShort() {
+ return this.nullShort;
+ }
+
+ /**
+ * Returns the value when a SQL null is encountered as the result of
+ * invoking a <code>getString</code> method.
+ *
+ * @return the value
+ */
+ public String getNullString() {
+ return this.nullString;
+ }
+
+ /**
+ * Returns the value when a SQL null is encountered as the result of
+ * invoking a <code>getTime</code> method.
+ *
+ * @return the value
+ */
+ public Time getNullTime() {
+ return this.nullTime;
+ }
+
+ /**
+ * Returns the value when a SQL null is encountered as the result of
+ * invoking a <code>getTimestamp</code> method.
+ *
+ * @return the value
+ */
+ public Timestamp getNullTimestamp() {
+ return this.nullTimestamp;
+ }
+
+ /**
+ * Returns the value when a SQL null is encountered as the result of
+ * invoking a <code>getURL</code> method.
+ *
+ * @return the value
+ */
+ public URL getNullURL() {
+ return this.nullURL;
+ }
+
+ /**
+ * Intercepts calls to <code>get*</code> methods and calls the appropriate
+ * <code>getNull*</code> method if the <code>ResultSet</code> returned
+ * <code>null</code>.
+ *
+ * @see java.lang.reflect.InvocationHandler#invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
+ * @param proxy Not used; all method calls go to the internal result set
+ * @param method The method to invoke on the result set
+ * @param args The arguments to pass to the result set
+ * @return null checked result
+ * @throws Throwable error
+ */
+ @Override
+ public Object invoke(Object proxy, Method method, Object[] args)
+ throws Throwable {
+
+ Object result = method.invoke(this.rs, args);
+
+ Method nullMethod = nullMethods.get(method.getName());
+
+ // Check nullMethod != null first so that we don't call wasNull()
+ // before a true getter method was invoked on the ResultSet.
+ return (nullMethod != null && this.rs.wasNull())
+ ? nullMethod.invoke(this, (Object[]) null)
+ : result;
+ }
+
+ /**
+ * Sets the value to return when a SQL null is encountered as the result of
+ * invoking a <code>getAsciiStream</code> method.
+ *
+ * @param nullAsciiStream the value
+ */
+ public void setNullAsciiStream(InputStream nullAsciiStream) {
+ this.nullAsciiStream = nullAsciiStream;
+ }
+
+ /**
+ * Sets the value to return when a SQL null is encountered as the result of
+ * invoking a <code>getBigDecimal</code> method.
+ *
+ * @param nullBigDecimal the value
+ */
+ public void setNullBigDecimal(BigDecimal nullBigDecimal) {
+ this.nullBigDecimal = nullBigDecimal;
+ }
+
+ /**
+ * Sets the value to return when a SQL null is encountered as the result of
+ * invoking a <code>getBinaryStream</code> method.
+ *
+ * @param nullBinaryStream the value
+ */
+ public void setNullBinaryStream(InputStream nullBinaryStream) {
+ this.nullBinaryStream = nullBinaryStream;
+ }
+
+ /**
+ * Sets the value to return when a SQL null is encountered as the result of
+ * invoking a <code>getBlob</code> method.
+ *
+ * @param nullBlob the value
+ */
+ public void setNullBlob(Blob nullBlob) {
+ this.nullBlob = nullBlob;
+ }
+
+ /**
+ * Sets the value to return when a SQL null is encountered as the result of
+ * invoking a <code>getBoolean</code> method.
+ *
+ * @param nullBoolean the value
+ */
+ public void setNullBoolean(boolean nullBoolean) {
+ this.nullBoolean = nullBoolean;
+ }
+
+ /**
+ * Sets the value to return when a SQL null is encountered as the result of
+ * invoking a <code>getByte</code> method.
+ *
+ * @param nullByte the value
+ */
+ public void setNullByte(byte nullByte) {
+ this.nullByte = nullByte;
+ }
+
+ /**
+ * Sets the value to return when a SQL null is encountered as the result of
+ * invoking a <code>getBytes</code> method.
+ *
+ * @param nullBytes the value
+ */
+ public void setNullBytes(byte[] nullBytes) {
+ byte[] copy = new byte[nullBytes.length];
+ System.arraycopy(nullBytes, 0, copy, 0, nullBytes.length);
+ this.nullBytes = copy;
+ }
+
+ /**
+ * Sets the value to return when a SQL null is encountered as the result of
+ * invoking a <code>getCharacterStream</code> method.
+ *
+ * @param nullCharacterStream the value
+ */
+ public void setNullCharacterStream(Reader nullCharacterStream) {
+ this.nullCharacterStream = nullCharacterStream;
+ }
+
+ /**
+ * Sets the value to return when a SQL null is encountered as the result of
+ * invoking a <code>getClob</code> method.
+ *
+ * @param nullClob the value
+ */
+ public void setNullClob(Clob nullClob) {
+ this.nullClob = nullClob;
+ }
+
+ /**
+ * Sets the value to return when a SQL null is encountered as the result of
+ * invoking a <code>getDate</code> method.
+ *
+ * @param nullDate the value
+ */
+ public void setNullDate(Date nullDate) {
+ this.nullDate = nullDate;
+ }
+
+ /**
+ * Sets the value to return when a SQL null is encountered as the result of
+ * invoking a <code>getDouble</code> method.
+ *
+ * @param nullDouble the value
+ */
+ public void setNullDouble(double nullDouble) {
+ this.nullDouble = nullDouble;
+ }
+
+ /**
+ * Sets the value to return when a SQL null is encountered as the result of
+ * invoking a <code>getFloat</code> method.
+ *
+ * @param nullFloat the value
+ */
+ public void setNullFloat(float nullFloat) {
+ this.nullFloat = nullFloat;
+ }
+
+ /**
+ * Sets the value to return when a SQL null is encountered as the result of
+ * invoking a <code>getInt</code> method.
+ *
+ * @param nullInt the value
+ */
+ public void setNullInt(int nullInt) {
+ this.nullInt = nullInt;
+ }
+
+ /**
+ * Sets the value to return when a SQL null is encountered as the result of
+ * invoking a <code>getLong</code> method.
+ *
+ * @param nullLong the value
+ */
+ public void setNullLong(long nullLong) {
+ this.nullLong = nullLong;
+ }
+
+ /**
+ * Sets the value to return when a SQL null is encountered as the result of
+ * invoking a <code>getObject</code> method.
+ *
+ * @param nullObject the value
+ */
+ public void setNullObject(Object nullObject) {
+ this.nullObject = nullObject;
+ }
+
+ /**
+ * Sets the value to return when a SQL null is encountered as the result of
+ * invoking a <code>getRef</code> method.
+ *
+ * @param nullRef the value
+ */
+ public void setNullRef(Ref nullRef) {
+ this.nullRef = nullRef;
+ }
+
+ /**
+ * Sets the value to return when a SQL null is encountered as the result of
+ * invoking a <code>getShort</code> method.
+ *
+ * @param nullShort the value
+ */
+ public void setNullShort(short nullShort) {
+ this.nullShort = nullShort;
+ }
+
+ /**
+ * Sets the value to return when a SQL null is encountered as the result of
+ * invoking a <code>getString</code> method.
+ *
+ * @param nullString the value
+ */
+ public void setNullString(String nullString) {
+ this.nullString = nullString;
+ }
+
+ /**
+ * Sets the value to return when a SQL null is encountered as the result of
+ * invoking a <code>getTime</code> method.
+ *
+ * @param nullTime the value
+ */
+ public void setNullTime(Time nullTime) {
+ this.nullTime = nullTime;
+ }
+
+ /**
+ * Sets the value to return when a SQL null is encountered as the result of
+ * invoking a <code>getTimestamp</code> method.
+ *
+ * @param nullTimestamp the value
+ */
+ public void setNullTimestamp(Timestamp nullTimestamp) {
+ this.nullTimestamp = nullTimestamp;
+ }
+
+ /**
+ * Sets the value to return when a SQL null is encountered as the result of
+ * invoking a <code>getURL</code> method.
+ *
+ * @param nullURL the value
+ */
+ public void setNullURL(URL nullURL) {
+ this.nullURL = nullURL;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/main/java/org/apache/commons/dbutils2/wrappers/StringTrimmedResultSet.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/wrappers/StringTrimmedResultSet.java b/src/main/java/org/apache/commons/dbutils2/wrappers/StringTrimmedResultSet.java
new file mode 100644
index 0000000..c65dbb6
--- /dev/null
+++ b/src/main/java/org/apache/commons/dbutils2/wrappers/StringTrimmedResultSet.java
@@ -0,0 +1,109 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.dbutils2.wrappers;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.sql.ResultSet;
+
+import org.apache.commons.dbutils2.ProxyFactory;
+
+/**
+ * Wraps a <code>ResultSet</code> to trim strings returned by the
+ * <code>getString()</code> and <code>getObject()</code> methods.
+ *
+ * <p>
+ * Usage Example:
+ * This example shows how to decorate ResultSets so processing continues as
+ * normal but all Strings are trimmed before being returned from the
+ * <code>ResultSet</code>.
+ * </p>
+ *
+ * <pre>
+ * ResultSet rs = // somehow get a ResultSet;
+ *
+ * // Substitute wrapped ResultSet with additional behavior for real ResultSet
+ * rs = StringTrimmedResultSet.wrap(rs);
+ *
+ * // Pass wrapped ResultSet to processor
+ * List list = new BasicRowProcessor().toBeanList(rs);
+ * </pre>
+ */
+public class StringTrimmedResultSet implements InvocationHandler {
+
+ /**
+ * The factory to create proxies with.
+ */
+ private static final ProxyFactory factory = ProxyFactory.instance();
+
+ /**
+ * Wraps the <code>ResultSet</code> in an instance of this class. This is
+ * equivalent to:
+ * <pre>
+ * ProxyFactory.instance().createResultSet(new StringTrimmedResultSet(rs));
+ * </pre>
+ *
+ * @param rs The <code>ResultSet</code> to wrap.
+ * @return wrapped ResultSet
+ */
+ public static ResultSet wrap(ResultSet rs) {
+ return factory.createResultSet(new StringTrimmedResultSet(rs));
+ }
+
+ /**
+ * The wrapped result.
+ */
+ private final ResultSet rs;
+
+ /**
+ * Constructs a new instance of <code>StringTrimmedResultSet</code>
+ * to wrap the specified <code>ResultSet</code>.
+ * @param rs ResultSet to wrap
+ */
+ public StringTrimmedResultSet(ResultSet rs) {
+ super();
+ this.rs = rs;
+ }
+
+ /**
+ * Intercept calls to the <code>getString()</code> and
+ * <code>getObject()</code> methods and trim any Strings before they're
+ * returned.
+ *
+ * @see java.lang.reflect.InvocationHandler#invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
+ * @param proxy Not used; all method calls go to the internal result set
+ * @param method The method to invoke on the result set
+ * @param args The arguments to pass to the result set
+ * @return string trimmed result
+ * @throws Throwable error
+ */
+ @Override
+ public Object invoke(Object proxy, Method method, Object[] args)
+ throws Throwable {
+
+ Object result = method.invoke(this.rs, args);
+
+ if ((method.getName().equals("getObject")
+ || method.getName().equals("getString"))
+ && result instanceof String) {
+ result = ((String) result).trim();
+ }
+
+ return result;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/main/java/org/apache/commons/dbutils2/wrappers/package-info.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/wrappers/package-info.java b/src/main/java/org/apache/commons/dbutils2/wrappers/package-info.java
new file mode 100644
index 0000000..e14b91d
--- /dev/null
+++ b/src/main/java/org/apache/commons/dbutils2/wrappers/package-info.java
@@ -0,0 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Wrappers that add functionality to java.sql classes.
+ */
+package org.apache.commons.dbutils2.wrappers;
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/test/java/org/apache/commons/dbutils/AbstractExecutorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils/AbstractExecutorTest.java b/src/test/java/org/apache/commons/dbutils/AbstractExecutorTest.java
deleted file mode 100644
index 606458b..0000000
--- a/src/test/java/org/apache/commons/dbutils/AbstractExecutorTest.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.dbutils;
-
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.SQLException;
-import java.sql.Types;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-
-
-public class AbstractExecutorTest {
-
- @SuppressWarnings("rawtypes") // don't care about this in the unit test
- private AbstractExecutor executor;
-
- @Mock private Connection conn;
- @Mock private PreparedStatement stmt;
-
- @Before
- public void setup() throws SQLException {
- MockitoAnnotations.initMocks(this);
-
- when(conn.prepareStatement(any(String.class))).thenReturn(stmt);
- }
-
- @SuppressWarnings("rawtypes")
- public void createExecutor(String sql) throws SQLException {
- executor = new AbstractExecutor(conn, sql) { };
- }
-
- @Test
- public void testGoodSql() throws SQLException {
- createExecutor("select * from blah :first = first and :last=last and phone=:phone");
-
- verify(conn, times(1)).prepareStatement("select * from blah ? = first and ?=last and phone=?");
-
- executor.bind("first", "first_name")
- .bind(":last", "last_name")
- .bind("phone", Integer.valueOf(12345));
-
- verify(stmt, times(1)).setObject(1, "first_name");
- verify(stmt, times(1)).setObject(2, "last_name");
- verify(stmt, times(1)).setObject(eq(3), eq(Integer.valueOf(12345)));
-
- executor.throwIfUnmappedParams();
- }
-
- @Test
- public void testNoParamsSql() throws SQLException {
- createExecutor("select * from blah");
-
- verify(conn, times(1)).prepareStatement("select * from blah");
- verify(stmt, times(0)).setObject(any(Integer.class), any(Object.class));
-
- executor.throwIfUnmappedParams();
- }
-
- @Test(expected=SQLException.class)
- public void testMissingParamSql() throws SQLException {
- createExecutor("select * from blah :first = first and :last=last");
-
- verify(conn, times(1)).prepareStatement("select * from blah ? = first and ?=last");
-
- executor.bind("first", "first_name")
- .bind(":last", "last_name")
- .bind("phone", Integer.valueOf(12345)); // should throw
-
- verify(stmt, times(1)).setObject(1, "first_name");
- verify(stmt, times(1)).setObject(2, "last_name");
- verify(stmt, times(1)).setObject(eq(3), eq(Integer.valueOf(12345)));
- }
-
- @Test(expected=SQLException.class)
- public void testDoubleBind() throws SQLException {
- createExecutor("select * from blah :first = first and :last=last");
-
- verify(conn, times(1)).prepareStatement("select * from blah ? = first and ?=last");
-
- executor.bind("first", "first_name")
- .bind(":last", "last_name")
- .bind(":last", "last_name");
-
- verify(stmt, times(1)).setObject(1, "first_name");
- verify(stmt, times(1)).setObject(2, "last_name");
- }
-
- @Test
- public void testNullBind() throws SQLException {
- createExecutor("select * from blah :first = first and :last=last");
-
- verify(conn, times(1)).prepareStatement("select * from blah ? = first and ?=last");
-
- executor.bindNull("first")
- .bindNull(":last", Types.NULL);
-
- verify(stmt, times(1)).setNull(1, Types.VARCHAR);
- verify(stmt, times(1)).setNull(2, Types.NULL);
- }
-}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/test/java/org/apache/commons/dbutils/AsyncExecutorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils/AsyncExecutorTest.java b/src/test/java/org/apache/commons/dbutils/AsyncExecutorTest.java
deleted file mode 100644
index cdc671f..0000000
--- a/src/test/java/org/apache/commons/dbutils/AsyncExecutorTest.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.dbutils;
-
-import static org.mockito.Mockito.doThrow;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import java.sql.SQLException;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Executors;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-
-@SuppressWarnings("boxing") // test code
-public class AsyncExecutorTest {
- AsyncExecutor runner;
-
- @Mock QueryRunner qRunner;
- @Mock ResultSetHandler<Object> handler;
- @Mock QueryExecutor queryExecutor;
- @Mock UpdateExecutor updateExecutor;
- @Mock InsertExecutor insertExecutor;
-
- @Before
- public void setUp() throws Exception {
- MockitoAnnotations.initMocks(this); // init the mocks
-
- runner = new AsyncExecutor(Executors.newFixedThreadPool(1));
- }
-
- @Test
- public void testQueryExecutor() throws Exception {
- runner.execute(queryExecutor, handler).get();
-
- verify(queryExecutor, times(1)).execute(handler);
- }
-
- @Test(expected=ExecutionException.class)
- public void testQueryExecutorException() throws Exception {
- doThrow(SQLException.class).when(queryExecutor).execute(handler);
- runner.execute(queryExecutor, handler).get();
-
- verify(queryExecutor, times(1)).execute(handler);
- }
-
- @Test
- public void testUpdateExecutor() throws Exception {
- runner.execute(updateExecutor).get();
-
- verify(updateExecutor, times(1)).execute();
- }
-
- @Test(expected=ExecutionException.class)
- public void testUpdateExecutorException() throws Exception {
- doThrow(SQLException.class).when(updateExecutor).execute();
- runner.execute(updateExecutor).get();
-
- verify(updateExecutor, times(1)).execute();
- }
-
- @Test
- public void testInsertExecutor() throws Exception {
- runner.execute(insertExecutor, handler).get();
-
- verify(insertExecutor, times(1)).execute(handler);
- }
-
- @Test(expected=ExecutionException.class)
- public void testInsertExecutorException() throws Exception {
- doThrow(SQLException.class).when(insertExecutor).execute(handler);
- runner.execute(insertExecutor, handler).get();
-
- verify(insertExecutor, times(1)).execute(handler);
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/test/java/org/apache/commons/dbutils/BaseResultSetHandlerTestCase.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils/BaseResultSetHandlerTestCase.java b/src/test/java/org/apache/commons/dbutils/BaseResultSetHandlerTestCase.java
deleted file mode 100644
index a574c73..0000000
--- a/src/test/java/org/apache/commons/dbutils/BaseResultSetHandlerTestCase.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.dbutils;
-
-import java.sql.SQLException;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.Map;
-
-import org.junit.Test;
-
-public final class BaseResultSetHandlerTestCase extends BaseTestCase {
-
- @Test
- public void handleWithoutExplicitResultSetInvocation() throws Exception {
- Collection<Map<String, Object>> result = new ToMapCollectionHandler().handle(createMockResultSet());
-
- assertFalse(result.isEmpty());
-
- for (Map<String, Object> current : result) {
- assertTrue(current.containsKey("one"));
- assertTrue(current.containsKey("two"));
- assertTrue(current.containsKey("three"));
- assertTrue(current.containsKey("notInBean"));
- assertTrue(current.containsKey("intTest"));
- assertTrue(current.containsKey("integerTest"));
- assertTrue(current.containsKey("nullObjectTest"));
- assertTrue(current.containsKey("nullPrimitiveTest"));
- assertTrue(current.containsKey("notDate"));
- assertTrue(current.containsKey("columnProcessorDoubleTest"));
- }
- }
-
- private static final class ToMapCollectionHandler
- extends BaseResultSetHandler<Collection<Map<String, Object>>> {
-
- @Override
- protected Collection<Map<String, Object>> handle() throws SQLException {
- Collection<Map<String, Object>> result = new LinkedList<Map<String, Object>>();
-
- while (next()) {
- Map<String, Object> current = new HashMap<String, Object>();
-
- for (int i = 1; i <= getMetaData().getColumnCount(); i++) {
- current.put(getMetaData().getColumnName(i), getObject(i));
- }
-
- result.add(current);
- }
-
- return result;
- }
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/test/java/org/apache/commons/dbutils/BaseTestCase.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils/BaseTestCase.java b/src/test/java/org/apache/commons/dbutils/BaseTestCase.java
deleted file mode 100644
index f0270a2..0000000
--- a/src/test/java/org/apache/commons/dbutils/BaseTestCase.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.dbutils;
-
-import java.math.BigInteger;
-import java.sql.ResultSet;
-import java.sql.ResultSetMetaData;
-import java.util.Date;
-
-import junit.framework.TestCase;
-
-/**
- * BaseTestCase is the base class for all test cases as well as the "all tests"
- * runner.
- */
-public class BaseTestCase extends TestCase {
-
- private static final String[] columnNames =
- new String[] {
- "one",
- "two",
- "three",
- "notInBean",
- "intTest",
- "integerTest",
- "nullObjectTest",
- "nullPrimitiveTest",
- "notDate",
- "columnProcessorDoubleTest" };
-
- /**
- * The number of columns in the MockResultSet.
- */
- protected static final int COLS = columnNames.length;
-
- protected static final ResultSetMetaData metaData =
- MockResultSetMetaData.create(columnNames);
-
- private static final Object[] row1 =
- new Object[] {
- "1",
- "2",
- "3",
- " notInBean ",
- Integer.valueOf(1),
- Integer.valueOf(2),
- null,
- null,
- new Date(),
- BigInteger.valueOf(13)};
-
- private static final Object[] row2 =
- new Object[] {
- "4",
- "5",
- "6",
- " notInBean ",
- Integer.valueOf(3),
- Integer.valueOf(4),
- null,
- null,
- new Date(),
- BigInteger.valueOf(13)};
-
- private static final Object[][] rows = new Object[][] { row1, row2 };
-
- /**
- * The number of rows in the MockResultSet.
- */
- protected static final int ROWS = rows.length;
-
- /**
- * The ResultSet all test methods will use.
- */
- protected ResultSet rs = null;
-
- /**
- * A ResultSet with 0 rows.
- */
- protected ResultSet emptyResultSet = null;
-
- /**
- * This is called before each test method so ResultSet will be fresh each
- * time.
- * @see junit.framework.TestCase#setUp()
- */
- @Override
- protected void setUp() throws Exception {
- super.setUp();
-
- rs = this.createMockResultSet();
- emptyResultSet = MockResultSet.create(metaData, null);
- }
-
- /**
- * Creates a freshly initialized ResultSet.
- */
- protected ResultSet createMockResultSet() {
- return MockResultSet.create(metaData, rows);
- }
-
- // Test which allows Eclipse to be run on full project (avoids no tests found)
- // check that the rows are valid for the column definition
- public void testCheckDataSizes() {
- assertEquals("Row 1 must contain correct number of columns", columnNames.length, row1.length);
- assertEquals("Row 1 must contain correct number of columns", columnNames.length, row2.length);
- }
-
- public void testResultSets() throws Exception {
- assertFalse("emptyResultSet should be empty", emptyResultSet.next());
- // fails in SqlNullCheckedResultSetTest assertTrue("rs should not be empty", rs.next());
- }
-}
[42/58] [abbrv] commons-dbutils git commit: Add missing end-tag
Posted by th...@apache.org.
Add missing end-tag
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/dbutils/branches/2_0@1482094 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/commons-dbutils/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-dbutils/commit/2fd9b9d7
Tree: http://git-wip-us.apache.org/repos/asf/commons-dbutils/tree/2fd9b9d7
Diff: http://git-wip-us.apache.org/repos/asf/commons-dbutils/diff/2fd9b9d7
Branch: refs/heads/2_0
Commit: 2fd9b9d71c4b71a7f7cb7513f5344c9433c805cd
Parents: e8727b6
Author: Sebastian Bazley <se...@apache.org>
Authored: Mon May 13 20:44:13 2013 +0000
Committer: Sebastian Bazley <se...@apache.org>
Committed: Mon May 13 20:44:13 2013 +0000
----------------------------------------------------------------------
src/changes/changes.xml | 1 +
1 file changed, 1 insertion(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/2fd9b9d7/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index dd38c43..8c2f41c 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -47,6 +47,7 @@ The <action> type attribute can be add,update,fix,remove.
<action dev="wspeirs" type="add">
This is the first release of the 2.x branch of the Commons DbUtils package, DbUtils2.
The motivation for creating DbUtils2 was two-fold: a number of deprecated methods in the original DbUtils, and the desire to support named parameters (DBUTILS-105).
+ </action>
<action dev="wspeirs" type="add" issue="DBUTILS-105">
Added named parameter support with fluent API
</action>
[51/58] [abbrv] commons-dbutils git commit: Changed protected methods
to package private for AbstractExecutor
Posted by th...@apache.org.
Changed protected methods to package private for AbstractExecutor
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/dbutils/branches/2_0@1482407 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/commons-dbutils/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-dbutils/commit/c0dba072
Tree: http://git-wip-us.apache.org/repos/asf/commons-dbutils/tree/c0dba072
Diff: http://git-wip-us.apache.org/repos/asf/commons-dbutils/diff/c0dba072
Branch: refs/heads/2_0
Commit: c0dba072dfa319bd54c617eaffdd97eb85fc69ee
Parents: 8914548
Author: Bill Speirs <ws...@apache.org>
Authored: Tue May 14 15:45:33 2013 +0000
Committer: Bill Speirs <ws...@apache.org>
Committed: Tue May 14 15:45:33 2013 +0000
----------------------------------------------------------------------
.../commons/dbutils2/AbstractExecutor.java | 25 ++++++++++----------
1 file changed, 12 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/c0dba072/src/main/java/org/apache/commons/dbutils2/AbstractExecutor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/AbstractExecutor.java b/src/main/java/org/apache/commons/dbutils2/AbstractExecutor.java
index d7bcc96..89f99e7 100644
--- a/src/main/java/org/apache/commons/dbutils2/AbstractExecutor.java
+++ b/src/main/java/org/apache/commons/dbutils2/AbstractExecutor.java
@@ -87,7 +87,7 @@ abstract class AbstractExecutor<T extends AbstractExecutor<T>> {
*
* @return the SQL statement passed into the constructor.
*/
- protected String getSql() {
+ String getSql() {
return sql;
}
@@ -96,7 +96,7 @@ abstract class AbstractExecutor<T extends AbstractExecutor<T>> {
*
* @return the underlying prepared statement.
*/
- protected PreparedStatement getStatement() {
+ PreparedStatement getStatement() {
return stmt;
}
@@ -105,7 +105,7 @@ abstract class AbstractExecutor<T extends AbstractExecutor<T>> {
*
* @return the underlying connection.
*/
- protected Connection getConnection() {
+ Connection getConnection() {
return conn;
}
@@ -114,7 +114,7 @@ abstract class AbstractExecutor<T extends AbstractExecutor<T>> {
*
* @throws SQLException if there are unmapped params.
*/
- protected void throwIfUnmappedParams() throws SQLException {
+ void throwIfUnmappedParams() throws SQLException {
if (paramPosMap.size() != 0) {
final Set<String> unmappedParams = paramPosMap.keySet();
final StringBuilder sb = new StringBuilder("There are unbound parameters: ");
@@ -178,7 +178,7 @@ abstract class AbstractExecutor<T extends AbstractExecutor<T>> {
* @return this
* @throws SQLException if there is an SQLException during binding.
*/
- protected T bindNull(String name, int sqlType, boolean removeFromPosMap) throws SQLException {
+ T bindNull(String name, int sqlType, boolean removeFromPosMap) throws SQLException {
name = name.replace(COLON, ""); // so we can take ":name" or "name"
final List<Integer> pos = removeFromPosMap ? paramPosMap.remove(name) : paramPosMap.get(name);
@@ -211,7 +211,7 @@ abstract class AbstractExecutor<T extends AbstractExecutor<T>> {
* @return this
* @throws SQLException if there is an SQLException during binding.
*/
- protected T bind(String name, final Object value, boolean removeFromPosMap) throws SQLException {
+ T bind(String name, final Object value, boolean removeFromPosMap) throws SQLException {
name = name.replace(COLON, ""); // so we can take ":name" or "name"
final List<Integer> pos = removeFromPosMap ? paramPosMap.remove(name) : paramPosMap.get(name);
@@ -239,7 +239,7 @@ abstract class AbstractExecutor<T extends AbstractExecutor<T>> {
/**
* Used for batch calls so we can clear the map after the addBatch call.
*/
- protected void clearValueMap() {
+ void clearValueMap() {
paramValueMap.clear();
}
@@ -251,7 +251,7 @@ abstract class AbstractExecutor<T extends AbstractExecutor<T>> {
*
* @throws SQLException if a database access error occurs
*/
- protected void rethrow(SQLException cause) throws SQLException {
+ void rethrow(SQLException cause) throws SQLException {
String causeMessage = cause.getMessage();
if (causeMessage == null) {
@@ -286,7 +286,7 @@ abstract class AbstractExecutor<T extends AbstractExecutor<T>> {
* @param rs The <code>ResultSet</code> to decorate; never <code>null</code>.
* @return The <code>ResultSet</code> wrapped in some decorator.
*/
- protected ResultSet wrap(ResultSet rs) {
+ ResultSet wrap(ResultSet rs) {
return rs;
}
@@ -298,7 +298,7 @@ abstract class AbstractExecutor<T extends AbstractExecutor<T>> {
* @param conn Connection to close
* @throws SQLException if a database access error occurs
*/
- protected void close(Connection conn) throws SQLException {
+ void close(Connection conn) throws SQLException {
DbUtils.close(conn);
}
@@ -310,7 +310,7 @@ abstract class AbstractExecutor<T extends AbstractExecutor<T>> {
* @param stmt Statement to close
* @throws SQLException if a database access error occurs
*/
- protected void close(Statement stmt) throws SQLException {
+ void close(Statement stmt) throws SQLException {
DbUtils.close(stmt);
}
@@ -322,9 +322,8 @@ abstract class AbstractExecutor<T extends AbstractExecutor<T>> {
* @param rs ResultSet to close
* @throws SQLException if a database access error occurs
*/
- protected void close(ResultSet rs) throws SQLException {
+ void close(ResultSet rs) throws SQLException {
DbUtils.close(rs);
}
-
}
[20/58] [abbrv] commons-dbutils git commit: Explicit boxing
Posted by th...@apache.org.
Explicit boxing
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/dbutils/branches/2_0@1457563 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/commons-dbutils/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-dbutils/commit/946aadb4
Tree: http://git-wip-us.apache.org/repos/asf/commons-dbutils/tree/946aadb4
Diff: http://git-wip-us.apache.org/repos/asf/commons-dbutils/diff/946aadb4
Branch: refs/heads/2_0
Commit: 946aadb48169c21acdc0c7c367415a73592d37d3
Parents: 2d180b9
Author: Sebastian Bazley <se...@apache.org>
Authored: Sun Mar 17 20:55:53 2013 +0000
Committer: Sebastian Bazley <se...@apache.org>
Committed: Sun Mar 17 20:55:53 2013 +0000
----------------------------------------------------------------------
src/main/java/org/apache/commons/dbutils2/AbstractExecutor.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/946aadb4/src/main/java/org/apache/commons/dbutils2/AbstractExecutor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/AbstractExecutor.java b/src/main/java/org/apache/commons/dbutils2/AbstractExecutor.java
index da25cd7..db15bab 100644
--- a/src/main/java/org/apache/commons/dbutils2/AbstractExecutor.java
+++ b/src/main/java/org/apache/commons/dbutils2/AbstractExecutor.java
@@ -183,7 +183,7 @@ abstract class AbstractExecutor<T extends AbstractExecutor<T>> {
// go through and bind all of the positions for this name
for (Integer p:pos) {
- stmt.setNull(p, sqlType);
+ stmt.setNull(p.intValue(), sqlType);
}
// add the param and value to our map
@@ -216,7 +216,7 @@ abstract class AbstractExecutor<T extends AbstractExecutor<T>> {
// go through and bind all of the positions for this name
for (Integer p:pos) {
// TODO: need to figure out how to bind NULL
- stmt.setObject(p, value);
+ stmt.setObject(p.intValue(), value);
}
// add the param and value to our map
[33/58] [abbrv] commons-dbutils git commit: Added a blank line before
the lists of javadoc parameters Removed the unnecessary @inheritDoc tags
Posted by th...@apache.org.
Added a blank line before the lists of javadoc parameters
Removed the unnecessary @inheritDoc tags
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/dbutils/branches/2_0@1481740 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/commons-dbutils/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-dbutils/commit/f1e96c2c
Tree: http://git-wip-us.apache.org/repos/asf/commons-dbutils/tree/f1e96c2c
Diff: http://git-wip-us.apache.org/repos/asf/commons-dbutils/diff/f1e96c2c
Branch: refs/heads/2_0
Commit: f1e96c2cac5da05c9ce1ca38d18ae555cc26a45b
Parents: 1761b74
Author: Emmanuel Bourg <eb...@apache.org>
Authored: Mon May 13 09:10:16 2013 +0000
Committer: Emmanuel Bourg <eb...@apache.org>
Committed: Mon May 13 09:10:16 2013 +0000
----------------------------------------------------------------------
.../commons/dbutils2/AbstractExecutor.java | 8 ++++++++
.../apache/commons/dbutils2/AsyncExecutor.java | 5 +++++
.../commons/dbutils2/BaseResultSetHandler.java | 3 ---
.../commons/dbutils2/BasicRowProcessor.java | 12 +++++-------
.../apache/commons/dbutils2/BatchExecutor.java | 6 ++++++
.../apache/commons/dbutils2/BeanProcessor.java | 9 ++++++---
.../org/apache/commons/dbutils2/DbUtils.java | 19 +------------------
.../apache/commons/dbutils2/InsertExecutor.java | 2 ++
.../apache/commons/dbutils2/ProxyFactory.java | 7 +++++++
.../apache/commons/dbutils2/QueryExecutor.java | 1 +
.../org/apache/commons/dbutils2/QueryLoader.java | 3 +++
.../commons/dbutils2/ResultSetIterator.java | 6 ++++++
.../apache/commons/dbutils2/RowProcessor.java | 2 ++
.../apache/commons/dbutils2/UpdateExecutor.java | 2 ++
.../dbutils2/handlers/AbstractKeyedHandler.java | 3 +++
.../commons/dbutils2/handlers/ArrayHandler.java | 1 +
.../dbutils2/handlers/ArrayListHandler.java | 1 +
.../commons/dbutils2/handlers/BeanHandler.java | 1 +
.../dbutils2/handlers/BeanMapHandler.java | 1 +
.../dbutils2/handlers/ColumnListHandler.java | 5 ++++-
.../commons/dbutils2/handlers/KeyedHandler.java | 6 +++++-
.../commons/dbutils2/handlers/MapHandler.java | 1 +
.../dbutils2/handlers/MapListHandler.java | 1 +
.../commons/dbutils2/handlers/ScalarHandler.java | 5 ++++-
.../wrappers/StringTrimmedResultSet.java | 1 +
25 files changed, 77 insertions(+), 34 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/f1e96c2c/src/main/java/org/apache/commons/dbutils2/AbstractExecutor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/AbstractExecutor.java b/src/main/java/org/apache/commons/dbutils2/AbstractExecutor.java
index b1ac3f8..839bc10 100644
--- a/src/main/java/org/apache/commons/dbutils2/AbstractExecutor.java
+++ b/src/main/java/org/apache/commons/dbutils2/AbstractExecutor.java
@@ -84,6 +84,7 @@ abstract class AbstractExecutor<T extends AbstractExecutor<T>> {
/**
* Gets the SQL statement that was passed into the constructor.
+ *
* @return the SQL statement passed into the constructor.
*/
protected String getSql() {
@@ -92,6 +93,7 @@ abstract class AbstractExecutor<T extends AbstractExecutor<T>> {
/**
* Returns the underlying prepared statement.
+ *
* @return the underlying prepared statement.
*/
protected PreparedStatement getStatement() {
@@ -100,6 +102,7 @@ abstract class AbstractExecutor<T extends AbstractExecutor<T>> {
/**
* Returns the underlying connection.
+ *
* @return the underlying connection.
*/
protected Connection getConnection() {
@@ -108,6 +111,7 @@ abstract class AbstractExecutor<T extends AbstractExecutor<T>> {
/**
* Throws an exception if there are unmapped params.
+ *
* @throws SQLException if there are unmapped params.
*/
protected void throwIfUnmappedParams() throws SQLException {
@@ -144,6 +148,7 @@ abstract class AbstractExecutor<T extends AbstractExecutor<T>> {
* Binds null to a parameter.
* Types.VARCHAR is used as the type's parameter.
* This usually works, but fails with some Oracle and MS SQL drivers.
+ *
* @param name the name of the parameter.
* @return this execution object to provide the fluent style.
* @throws SQLException throw if the parameter is not found, already bound, or there is an issue binding null.
@@ -154,6 +159,7 @@ abstract class AbstractExecutor<T extends AbstractExecutor<T>> {
/**
* Binds null to a parameter, specifying the parameter's type.
+ *
* @param name the name of the parameter.
* @param sqlType the type of the parameter.
* @return this execution object to provide the fluent style.
@@ -165,6 +171,7 @@ abstract class AbstractExecutor<T extends AbstractExecutor<T>> {
/**
* Given a param name and sqlType, binds a null to that parameter.
+ *
* @param name the name of the parameter.
* @param sqlType the type of the parameter.
* @param removeFromPosMap if the param should be removed from the pos map.
@@ -197,6 +204,7 @@ abstract class AbstractExecutor<T extends AbstractExecutor<T>> {
/**
* Binds value to name, but does not do the bookkeeping.
+ *
* @param name the parameter name.
* @param value the value.
* @param removeFromPosMap if the param should be removed from the pos map.
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/f1e96c2c/src/main/java/org/apache/commons/dbutils2/AsyncExecutor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/AsyncExecutor.java b/src/main/java/org/apache/commons/dbutils2/AsyncExecutor.java
index afcfdb2..dcc58cf 100644
--- a/src/main/java/org/apache/commons/dbutils2/AsyncExecutor.java
+++ b/src/main/java/org/apache/commons/dbutils2/AsyncExecutor.java
@@ -41,6 +41,7 @@ public class AsyncExecutor {
/**
* Execute a {@link org.apache.commons.dbutils2.BatchExecutor}.
+ *
* @param executor The executor for this SQL statement.
* @return A <code>Future</code> which returns the result of the batch call.
* @throws SQLException if a database access error occurs
@@ -58,6 +59,7 @@ public class AsyncExecutor {
/**
* Execute a {@link org.apache.commons.dbutils2.QueryExecutor} given a handler.
+ *
* @param <T> The type of object that the handler returns
* @param executor The executor for this SQL statement.
* @param handler The handler that converts the results into an object.
@@ -77,6 +79,7 @@ public class AsyncExecutor {
/**
* Execute a {@link org.apache.commons.dbutils2.UpdateExecutor}.
+ *
* @param executor The executor for this SQL statement.
* @return A <code>Future</code> which returns the result of the query call.
* @throws SQLException if a database access error occurs
@@ -94,6 +97,7 @@ public class AsyncExecutor {
/**
* Execute a {@link org.apache.commons.dbutils2.InsertExecutor} given a handler.
+ *
* @param <T> The type of object that the handler returns
* @param executor The executor for this SQL statement.
* @param handler The handler that converts the results into an object.
@@ -113,6 +117,7 @@ public class AsyncExecutor {
/**
* Execute a {@link org.apache.commons.dbutils2.InsertExecutor} given a handler.
+ *
* @param executor The executor for this SQL statement.
* @return A <code>Future</code> which returns the number of rows inserted.
* @throws SQLException if a database access error occurs
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/f1e96c2c/src/main/java/org/apache/commons/dbutils2/BaseResultSetHandler.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/BaseResultSetHandler.java b/src/main/java/org/apache/commons/dbutils2/BaseResultSetHandler.java
index 1c32b40..8cf2673 100644
--- a/src/main/java/org/apache/commons/dbutils2/BaseResultSetHandler.java
+++ b/src/main/java/org/apache/commons/dbutils2/BaseResultSetHandler.java
@@ -58,9 +58,6 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
*/
private ResultSet rs;
- /**
- * {@inheritDoc}
- */
@Override
public final T handle(ResultSet rs) throws SQLException {
if (this.rs != null) {
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/f1e96c2c/src/main/java/org/apache/commons/dbutils2/BasicRowProcessor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/BasicRowProcessor.java b/src/main/java/org/apache/commons/dbutils2/BasicRowProcessor.java
index c8cc899..1b66dc9 100644
--- a/src/main/java/org/apache/commons/dbutils2/BasicRowProcessor.java
+++ b/src/main/java/org/apache/commons/dbutils2/BasicRowProcessor.java
@@ -56,8 +56,8 @@ public class BasicRowProcessor implements RowProcessor {
/**
* BasicRowProcessor constructor.
- * @param convert The BeanProcessor to use when converting columns to
- * bean properties.
+ *
+ * @param convert The BeanProcessor to use when converting columns to bean properties.
* @since 1.1
*/
public BasicRowProcessor(BeanProcessor convert) {
@@ -92,6 +92,7 @@ public class BasicRowProcessor implements RowProcessor {
/**
* Convert a <code>ResultSet</code> row into a JavaBean. This
* implementation delegates to a BeanProcessor instance.
+ *
* @see org.apache.commons.dbutils2.RowProcessor#toBean(java.sql.ResultSet, java.lang.Class)
* @see org.apache.commons.dbutils2.BeanProcessor#toBean(java.sql.ResultSet, java.lang.Class)
* @param <T> The type of bean to create
@@ -108,6 +109,7 @@ public class BasicRowProcessor implements RowProcessor {
/**
* Convert a <code>ResultSet</code> into a <code>List</code> of JavaBeans.
* This implementation delegates to a BeanProcessor instance.
+ *
* @see org.apache.commons.dbutils2.RowProcessor#toBeanList(java.sql.ResultSet, java.lang.Class)
* @see org.apache.commons.dbutils2.BeanProcessor#toBeanList(java.sql.ResultSet, java.lang.Class)
* @param <T> The type of bean to create
@@ -127,6 +129,7 @@ public class BasicRowProcessor implements RowProcessor {
* implementation returns a <code>Map</code> with case insensitive column
* names as keys. Calls to <code>map.get("COL")</code> and
* <code>map.get("col")</code> return the same value.
+ *
* @see org.apache.commons.dbutils2.RowProcessor#toMap(java.sql.ResultSet)
* @param rs ResultSet that supplies the map data
* @throws SQLException if a database access error occurs
@@ -184,7 +187,6 @@ public class BasicRowProcessor implements RowProcessor {
*/
private static final long serialVersionUID = -2848100435296897392L;
- /** {@inheritDoc} */
@Override
public boolean containsKey(Object key) {
Object realKey = lowerCaseMap.get(key.toString().toLowerCase(Locale.ENGLISH));
@@ -195,14 +197,12 @@ public class BasicRowProcessor implements RowProcessor {
// return lowerCaseMap.containsKey(key.toString().toLowerCase());
}
- /** {@inheritDoc} */
@Override
public Object get(Object key) {
Object realKey = lowerCaseMap.get(key.toString().toLowerCase(Locale.ENGLISH));
return super.get(realKey);
}
- /** {@inheritDoc} */
@Override
public Object put(String key, Object value) {
/*
@@ -218,7 +218,6 @@ public class BasicRowProcessor implements RowProcessor {
return oldValue;
}
- /** {@inheritDoc} */
@Override
public void putAll(Map<? extends String, ?> m) {
for (Map.Entry<? extends String, ?> entry : m.entrySet()) {
@@ -228,7 +227,6 @@ public class BasicRowProcessor implements RowProcessor {
}
}
- /** {@inheritDoc} */
@Override
public Object remove(Object key) {
Object realKey = lowerCaseMap.remove(key.toString().toLowerCase(Locale.ENGLISH));
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/f1e96c2c/src/main/java/org/apache/commons/dbutils2/BatchExecutor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/BatchExecutor.java b/src/main/java/org/apache/commons/dbutils2/BatchExecutor.java
index 8569873..e8b13a9 100644
--- a/src/main/java/org/apache/commons/dbutils2/BatchExecutor.java
+++ b/src/main/java/org/apache/commons/dbutils2/BatchExecutor.java
@@ -33,6 +33,7 @@ public class BatchExecutor extends AbstractExecutor<BatchExecutor> {
/**
* Constructs a BatchExecutor given a connection and SQL statement.
+ *
* @param conn The connection to use during execution.
* @param sql The SQL statement.
* @param closeConnection If the connection should be closed or not.
@@ -45,6 +46,7 @@ public class BatchExecutor extends AbstractExecutor<BatchExecutor> {
/**
* Binds a parameter name to a value for a given statement.
+ *
* @param name the name of the parameter.
* @param value the value to bind to the parameter.
* @return this object.
@@ -60,6 +62,7 @@ public class BatchExecutor extends AbstractExecutor<BatchExecutor> {
* Binds null to a parameter.
* Types.VARCHAR is used as the type's parameter.
* This usually works, but fails with some Oracle and MS SQL drivers.
+ *
* @param name the name of the parameter.
* @return this execution object to provide the fluent style.
* @throws SQLException throw if the parameter is not found, already bound, or there is an issue binding null.
@@ -71,6 +74,7 @@ public class BatchExecutor extends AbstractExecutor<BatchExecutor> {
/**
* Binds null to a parameter, specifying the parameter's type.
+ *
* @param name the name of the parameter.
* @param sqlType the type of the parameter.
* @return this execution object to provide the fluent style.
@@ -83,6 +87,7 @@ public class BatchExecutor extends AbstractExecutor<BatchExecutor> {
/**
* Adds the statement to the batch after binding all of the parameters.
+ *
* @return this object.
* @throws SQLException if a SQLException is thrown during the addBatch() call.
* @see java.sql.PreparedStatement#addBatch()
@@ -100,6 +105,7 @@ public class BatchExecutor extends AbstractExecutor<BatchExecutor> {
/**
* Calls batch after checking the parameters to ensure nothing is null.
+ *
* @return an array containing the number of rows updated for each statement.
* @throws SQLException If there are database or parameter errors.
* @see org.apache.commons.dbutils2.UpdateExecutor#execute()
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/f1e96c2c/src/main/java/org/apache/commons/dbutils2/BeanProcessor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/BeanProcessor.java b/src/main/java/org/apache/commons/dbutils2/BeanProcessor.java
index 1ee0ff6..53e8515 100644
--- a/src/main/java/org/apache/commons/dbutils2/BeanProcessor.java
+++ b/src/main/java/org/apache/commons/dbutils2/BeanProcessor.java
@@ -129,6 +129,7 @@ public class BeanProcessor {
* <code>null</code> when SQL NULL is returned. This is the same behavior
* as the <code>ResultSet</code> get* methods.
* </p>
+ *
* @param <T> The type of bean to create
* @param rs ResultSet that supplies the bean data
* @param type Class from which to create the bean instance
@@ -172,6 +173,7 @@ public class BeanProcessor {
* <code>null</code> when SQL NULL is returned. This is the same behavior
* as the <code>ResultSet</code> get* methods.
* </p>
+ *
* @param <T> The type of bean to create
* @param rs ResultSet that supplies the bean data
* @param type Class from which to create the bean instance
@@ -198,6 +200,7 @@ public class BeanProcessor {
/**
* Creates a new object and initializes its fields from the ResultSet.
+ *
* @param <T> The type of bean to create
* @param rs The result set.
* @param type The bean type (the return type of the object).
@@ -236,6 +239,7 @@ public class BeanProcessor {
/**
* Calls the setter method on the target object for the given property.
* If no setter method exists for the property, this method does nothing.
+ *
* @param target The object to set the property on.
* @param prop The property to set.
* @param value The value to pass into the setter.
@@ -340,6 +344,7 @@ public class BeanProcessor {
* is called at the start of the bean creation process and may be
* overridden to provide custom behavior like returning a cached bean
* instance.
+ *
* @param <T> The type of object to create
* @param c The Class to create an object from.
* @return A newly created object of the Class.
@@ -388,9 +393,7 @@ public class BeanProcessor {
* the column name. If no bean property was found for a column, the
* position is set to <code>PROPERTY_NOT_FOUND</code>.
*
- * @param rsmd The <code>ResultSetMetaData</code> containing column
- * information.
- *
+ * @param rsmd The <code>ResultSetMetaData</code> containing column information.
* @param props The bean property descriptors.
*
* @throws SQLException if a database access error occurs
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/f1e96c2c/src/main/java/org/apache/commons/dbutils2/DbUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/DbUtils.java b/src/main/java/org/apache/commons/dbutils2/DbUtils.java
index 37ff688..47f9ace 100644
--- a/src/main/java/org/apache/commons/dbutils2/DbUtils.java
+++ b/src/main/java/org/apache/commons/dbutils2/DbUtils.java
@@ -297,6 +297,7 @@ public final class DbUtils {
/**
* Rollback any changes made on the given connection.
+ *
* @param conn Connection to rollback. A null value is legal.
* @throws SQLException if a database access error occurs
*/
@@ -360,49 +361,31 @@ public final class DbUtils {
this.adapted = adapted;
}
- /**
- * {@inheritDoc}
- */
@Override
public boolean acceptsURL(String url) throws SQLException {
return adapted.acceptsURL(url);
}
- /**
- * {@inheritDoc}
- */
@Override
public Connection connect(String url, Properties info) throws SQLException {
return adapted.connect(url, info);
}
- /**
- * {@inheritDoc}
- */
@Override
public int getMajorVersion() {
return adapted.getMajorVersion();
}
- /**
- * {@inheritDoc}
- */
@Override
public int getMinorVersion() {
return adapted.getMinorVersion();
}
- /**
- * {@inheritDoc}
- */
@Override
public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException {
return adapted.getPropertyInfo(url, info);
}
- /**
- * {@inheritDoc}
- */
@Override
public boolean jdbcCompliant() {
return adapted.jdbcCompliant();
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/f1e96c2c/src/main/java/org/apache/commons/dbutils2/InsertExecutor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/InsertExecutor.java b/src/main/java/org/apache/commons/dbutils2/InsertExecutor.java
index f1aa78a..8fdd9db 100644
--- a/src/main/java/org/apache/commons/dbutils2/InsertExecutor.java
+++ b/src/main/java/org/apache/commons/dbutils2/InsertExecutor.java
@@ -32,6 +32,7 @@ public class InsertExecutor extends AbstractExecutor<InsertExecutor> {
/**
* Constructs an InsertExecutor given a connection and SQL statement.
+ *
* @param conn The connection to use during execution.
* @param sql The SQL statement.
* @param closeConnection If the connection should be closed or not.
@@ -88,6 +89,7 @@ public class InsertExecutor extends AbstractExecutor<InsertExecutor> {
/**
* Executes the given INSERT SQL statement.
+ *
* @return the number of rows updated.
* @throws SQLException If there are database or parameter errors.
*/
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/f1e96c2c/src/main/java/org/apache/commons/dbutils2/ProxyFactory.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/ProxyFactory.java b/src/main/java/org/apache/commons/dbutils2/ProxyFactory.java
index 9410f27..ac9e0db 100644
--- a/src/main/java/org/apache/commons/dbutils2/ProxyFactory.java
+++ b/src/main/java/org/apache/commons/dbutils2/ProxyFactory.java
@@ -71,6 +71,7 @@ public class ProxyFactory {
/**
* Creates a new proxy <code>CallableStatement</code> object.
+ *
* @param handler The handler that intercepts/overrides method calls.
* @return proxied CallableStatement
*/
@@ -80,6 +81,7 @@ public class ProxyFactory {
/**
* Creates a new proxy <code>Connection</code> object.
+ *
* @param handler The handler that intercepts/overrides method calls.
* @return proxied Connection
*/
@@ -89,6 +91,7 @@ public class ProxyFactory {
/**
* Creates a new proxy <code>Driver</code> object.
+ *
* @param handler The handler that intercepts/overrides method calls.
* @return proxied Driver
*/
@@ -98,6 +101,7 @@ public class ProxyFactory {
/**
* Creates a new proxy <code>PreparedStatement</code> object.
+ *
* @param handler The handler that intercepts/overrides method calls.
* @return proxied PreparedStatement
*/
@@ -107,6 +111,7 @@ public class ProxyFactory {
/**
* Creates a new proxy <code>ResultSet</code> object.
+ *
* @param handler The handler that intercepts/overrides method calls.
* @return proxied ResultSet
*/
@@ -116,6 +121,7 @@ public class ProxyFactory {
/**
* Creates a new proxy <code>ResultSetMetaData</code> object.
+ *
* @param handler The handler that intercepts/overrides method calls.
* @return proxied ResultSetMetaData
*/
@@ -125,6 +131,7 @@ public class ProxyFactory {
/**
* Creates a new proxy <code>Statement</code> object.
+ *
* @param handler The handler that intercepts/overrides method calls.
* @return proxied Statement
*/
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/f1e96c2c/src/main/java/org/apache/commons/dbutils2/QueryExecutor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/QueryExecutor.java b/src/main/java/org/apache/commons/dbutils2/QueryExecutor.java
index 5fc5c25..0af8b64 100644
--- a/src/main/java/org/apache/commons/dbutils2/QueryExecutor.java
+++ b/src/main/java/org/apache/commons/dbutils2/QueryExecutor.java
@@ -31,6 +31,7 @@ public class QueryExecutor extends AbstractExecutor<QueryExecutor> {
/**
* Constructs a QueryExecutor given a connection and SQL statement.
+ *
* @param conn The connection to use during execution.
* @param sql The SQL statement.
* @param closeConnection If the connection should be closed or not.
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/f1e96c2c/src/main/java/org/apache/commons/dbutils2/QueryLoader.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/QueryLoader.java b/src/main/java/org/apache/commons/dbutils2/QueryLoader.java
index e7b1f54..59c1152 100644
--- a/src/main/java/org/apache/commons/dbutils2/QueryLoader.java
+++ b/src/main/java/org/apache/commons/dbutils2/QueryLoader.java
@@ -37,6 +37,7 @@ public class QueryLoader {
/**
* Return an instance of this class.
+ *
* @return The Singleton instance.
*/
public static QueryLoader instance() {
@@ -84,6 +85,7 @@ public class QueryLoader {
/**
* Loads a set of named queries into a Map object. This implementation
* reads a properties file at the given path.
+ *
* @param path The path that the ClassLoader will use to find the file.
* @throws IOException if a file access error occurs
* @throws IllegalArgumentException if the ClassLoader can't find a file at
@@ -115,6 +117,7 @@ public class QueryLoader {
/**
* Removes the queries for the given path from the cache.
+ *
* @param path The path that the queries were loaded from.
*/
public synchronized void unload(String path) {
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/f1e96c2c/src/main/java/org/apache/commons/dbutils2/ResultSetIterator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/ResultSetIterator.java b/src/main/java/org/apache/commons/dbutils2/ResultSetIterator.java
index cd9ca53..ce49c26 100644
--- a/src/main/java/org/apache/commons/dbutils2/ResultSetIterator.java
+++ b/src/main/java/org/apache/commons/dbutils2/ResultSetIterator.java
@@ -46,6 +46,7 @@ public class ResultSetIterator implements Iterator<Object[]> {
/**
* Constructor for ResultSetIterator.
+ *
* @param rs Wrap this <code>ResultSet</code> in an <code>Iterator</code>.
*/
public ResultSetIterator(ResultSet rs) {
@@ -54,6 +55,7 @@ public class ResultSetIterator implements Iterator<Object[]> {
/**
* Constructor for ResultSetIterator.
+ *
* @param rs Wrap this <code>ResultSet</code> in an <code>Iterator</code>.
* @param convert The processor to use when converting a row into an
* <code>Object[]</code>. Defaults to a
@@ -66,6 +68,7 @@ public class ResultSetIterator implements Iterator<Object[]> {
/**
* Returns true if there are more rows in the ResultSet.
+ *
* @return boolean <code>true</code> if there are more rows
* @throws RuntimeException if an SQLException occurs.
*/
@@ -81,6 +84,7 @@ public class ResultSetIterator implements Iterator<Object[]> {
/**
* Returns the next row as an <code>Object[]</code>.
+ *
* @return An <code>Object[]</code> with the same number of elements as
* columns in the <code>ResultSet</code>.
* @see java.util.Iterator#next()
@@ -99,6 +103,7 @@ public class ResultSetIterator implements Iterator<Object[]> {
/**
* Deletes the current row from the <code>ResultSet</code>.
+ *
* @see java.util.Iterator#remove()
* @throws RuntimeException if an SQLException occurs.
*/
@@ -114,6 +119,7 @@ public class ResultSetIterator implements Iterator<Object[]> {
/**
* Rethrow the SQLException as a RuntimeException. This implementation
* creates a new RuntimeException with the SQLException's error message.
+ *
* @param e SQLException to rethrow
* @since 1.1
*/
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/f1e96c2c/src/main/java/org/apache/commons/dbutils2/RowProcessor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/RowProcessor.java b/src/main/java/org/apache/commons/dbutils2/RowProcessor.java
index b896b01..c21346f 100644
--- a/src/main/java/org/apache/commons/dbutils2/RowProcessor.java
+++ b/src/main/java/org/apache/commons/dbutils2/RowProcessor.java
@@ -49,6 +49,7 @@ public interface RowProcessor {
* row. The <code>ResultSet</code> should be positioned on a valid row before
* passing it to this method. Implementations of this method must not
* alter the row position of the <code>ResultSet</code>.
+ *
* @param <T> The type of bean to create
* @param rs ResultSet that supplies the bean data
* @param type Class from which to create the bean instance
@@ -61,6 +62,7 @@ public interface RowProcessor {
* Create a <code>List</code> of JavaBeans from the column values in all
* <code>ResultSet</code> rows. <code>ResultSet.next()</code> should
* <strong>not</strong> be called before passing it to this method.
+ *
* @param <T> The type of bean to create
* @param rs ResultSet that supplies the bean data
* @param type Class from which to create the bean instance
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/f1e96c2c/src/main/java/org/apache/commons/dbutils2/UpdateExecutor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/UpdateExecutor.java b/src/main/java/org/apache/commons/dbutils2/UpdateExecutor.java
index 7ee34f4..5f39687 100644
--- a/src/main/java/org/apache/commons/dbutils2/UpdateExecutor.java
+++ b/src/main/java/org/apache/commons/dbutils2/UpdateExecutor.java
@@ -30,6 +30,7 @@ public class UpdateExecutor extends AbstractExecutor<UpdateExecutor> {
/**
* Constructs an UpdateExecutor given a connection and SQL statement.
+ *
* @param conn The connection to use during execution.
* @param sql The SQL statement.
* @param closeConnection If the connection should be closed or not.
@@ -42,6 +43,7 @@ public class UpdateExecutor extends AbstractExecutor<UpdateExecutor> {
/**
* Calls update after checking the parameters to ensure nothing is null.
+ *
* @return The number of rows updated.
* @throws SQLException If there are database or parameter errors.
*/
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/f1e96c2c/src/main/java/org/apache/commons/dbutils2/handlers/AbstractKeyedHandler.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/handlers/AbstractKeyedHandler.java b/src/main/java/org/apache/commons/dbutils2/handlers/AbstractKeyedHandler.java
index a6372e1..b4116f7 100644
--- a/src/main/java/org/apache/commons/dbutils2/handlers/AbstractKeyedHandler.java
+++ b/src/main/java/org/apache/commons/dbutils2/handlers/AbstractKeyedHandler.java
@@ -41,6 +41,7 @@ public abstract class AbstractKeyedHandler<K, V> implements ResultSetHandler<Map
/**
* Convert each row's columns into a Map and store then
* in a <code>Map</code> under <code>ResultSet.getObject(key)</code> key.
+ *
* @param rs <code>ResultSet</code> to process.
* @return A <code>Map</code>, never <code>null</code>.
* @throws SQLException if a database access error occurs
@@ -69,6 +70,7 @@ public abstract class AbstractKeyedHandler<K, V> implements ResultSetHandler<Map
/**
* This factory method is called by <code>handle()</code> to retrieve the
* key value from the current <code>ResultSet</code> row.
+ *
* @param rs ResultSet to create a key from
* @return K from the configured key column name/index
* @throws SQLException if a database access error occurs
@@ -78,6 +80,7 @@ public abstract class AbstractKeyedHandler<K, V> implements ResultSetHandler<Map
/**
* This factory method is called by <code>handle()</code> to store the
* current <code>ResultSet</code> row in some object.
+ *
* @param rs ResultSet to create a row from
* @return V object created from the current row
* @throws SQLException if a database access error occurs
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/f1e96c2c/src/main/java/org/apache/commons/dbutils2/handlers/ArrayHandler.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/handlers/ArrayHandler.java b/src/main/java/org/apache/commons/dbutils2/handlers/ArrayHandler.java
index ddac362..5eef4ba 100644
--- a/src/main/java/org/apache/commons/dbutils2/handlers/ArrayHandler.java
+++ b/src/main/java/org/apache/commons/dbutils2/handlers/ArrayHandler.java
@@ -66,6 +66,7 @@ public class ArrayHandler<T> implements ResultSetHandler<T[]> {
/**
* Places the column values from the first row in an <code>T[]</code>.
+ *
* @param rs <code>ResultSet</code> to process.
* @return An T[] or <code>null</code> if there are no rows in the
* <code>ResultSet</code>.
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/f1e96c2c/src/main/java/org/apache/commons/dbutils2/handlers/ArrayListHandler.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/handlers/ArrayListHandler.java b/src/main/java/org/apache/commons/dbutils2/handlers/ArrayListHandler.java
index 6328c58..6b260a2 100644
--- a/src/main/java/org/apache/commons/dbutils2/handlers/ArrayListHandler.java
+++ b/src/main/java/org/apache/commons/dbutils2/handlers/ArrayListHandler.java
@@ -58,6 +58,7 @@ public class ArrayListHandler extends AbstractListHandler<Object[]> {
/**
* Convert row's columns into an <code>Object[]</code>.
+ *
* @param rs <code>ResultSet</code> to process.
* @return <code>Object[]</code>, never <code>null</code>.
*
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/f1e96c2c/src/main/java/org/apache/commons/dbutils2/handlers/BeanHandler.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/handlers/BeanHandler.java b/src/main/java/org/apache/commons/dbutils2/handlers/BeanHandler.java
index 9146bd0..e9b17f3 100644
--- a/src/main/java/org/apache/commons/dbutils2/handlers/BeanHandler.java
+++ b/src/main/java/org/apache/commons/dbutils2/handlers/BeanHandler.java
@@ -68,6 +68,7 @@ public class BeanHandler<T> implements ResultSetHandler<T> {
/**
* Convert the first row of the <code>ResultSet</code> into a bean with the
* <code>Class</code> given in the constructor.
+ *
* @param rs <code>ResultSet</code> to process.
* @return An initialized JavaBean or <code>null</code> if there were no
* rows in the <code>ResultSet</code>.
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/f1e96c2c/src/main/java/org/apache/commons/dbutils2/handlers/BeanMapHandler.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/handlers/BeanMapHandler.java b/src/main/java/org/apache/commons/dbutils2/handlers/BeanMapHandler.java
index a8edff0..7e8d5cd 100644
--- a/src/main/java/org/apache/commons/dbutils2/handlers/BeanMapHandler.java
+++ b/src/main/java/org/apache/commons/dbutils2/handlers/BeanMapHandler.java
@@ -158,6 +158,7 @@ public class BeanMapHandler<K, V> extends AbstractKeyedHandler<K, V> {
/**
* This factory method is called by <code>handle()</code> to retrieve the
* key value from the current <code>ResultSet</code> row.
+ *
* @param rs ResultSet to create a key from
*
* @return K from the configured key column name/index
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/f1e96c2c/src/main/java/org/apache/commons/dbutils2/handlers/ColumnListHandler.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/handlers/ColumnListHandler.java b/src/main/java/org/apache/commons/dbutils2/handlers/ColumnListHandler.java
index 39cf128..8cebaa5 100644
--- a/src/main/java/org/apache/commons/dbutils2/handlers/ColumnListHandler.java
+++ b/src/main/java/org/apache/commons/dbutils2/handlers/ColumnListHandler.java
@@ -69,7 +69,9 @@ public class ColumnListHandler<T> extends AbstractListHandler<T> {
this(1, columnName);
}
- /** Private Helper
+ /**
+ * Private Helper
+ *
* @param columnIndex The index of the column to retrieve from the
* <code>ResultSet</code>.
* @param columnName The name of the column to retrieve from the
@@ -83,6 +85,7 @@ public class ColumnListHandler<T> extends AbstractListHandler<T> {
/**
* Returns one <code>ResultSet</code> column value as <code>Object</code>.
+ *
* @param rs <code>ResultSet</code> to process.
* @return <code>Object</code>, never <code>null</code>.
*
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/f1e96c2c/src/main/java/org/apache/commons/dbutils2/handlers/KeyedHandler.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/handlers/KeyedHandler.java b/src/main/java/org/apache/commons/dbutils2/handlers/KeyedHandler.java
index 4089650..106edb0 100644
--- a/src/main/java/org/apache/commons/dbutils2/handlers/KeyedHandler.java
+++ b/src/main/java/org/apache/commons/dbutils2/handlers/KeyedHandler.java
@@ -107,7 +107,9 @@ public class KeyedHandler<K> extends AbstractKeyedHandler<K, Map<String, Object>
this(ArrayHandler.ROW_PROCESSOR, 1, columnName);
}
- /** Private Helper
+ /**
+ * Private Helper
+ *
* @param convert The <code>RowProcessor</code> implementation
* to use when converting rows into Maps
* @param columnIndex The values to use as keys in the Map are
@@ -127,6 +129,7 @@ public class KeyedHandler<K> extends AbstractKeyedHandler<K, Map<String, Object>
* key value from the current <code>ResultSet</code> row. This
* implementation returns <code>ResultSet.getObject()</code> for the
* configured key column name or index.
+ *
* @param rs ResultSet to create a key from
* @return Object from the configured key column name/index
*
@@ -149,6 +152,7 @@ public class KeyedHandler<K> extends AbstractKeyedHandler<K, Map<String, Object>
* implementation returns a <code>Map</code> with case insensitive column
* names as keys. Calls to <code>map.get("COL")</code> and
* <code>map.get("col")</code> return the same value.
+ *
* @param rs ResultSet to create a row from
* @return Object typed Map containing column names to values
* @throws SQLException if a database access error occurs
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/f1e96c2c/src/main/java/org/apache/commons/dbutils2/handlers/MapHandler.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/handlers/MapHandler.java b/src/main/java/org/apache/commons/dbutils2/handlers/MapHandler.java
index c767948..990619e 100644
--- a/src/main/java/org/apache/commons/dbutils2/handlers/MapHandler.java
+++ b/src/main/java/org/apache/commons/dbutils2/handlers/MapHandler.java
@@ -60,6 +60,7 @@ public class MapHandler implements ResultSetHandler<Map<String, Object>> {
/**
* Converts the first row in the <code>ResultSet</code> into a
* <code>Map</code>.
+ *
* @param rs <code>ResultSet</code> to process.
* @return A <code>Map</code> with the values from the first row or
* <code>null</code> if there are no rows in the <code>ResultSet</code>.
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/f1e96c2c/src/main/java/org/apache/commons/dbutils2/handlers/MapListHandler.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/handlers/MapListHandler.java b/src/main/java/org/apache/commons/dbutils2/handlers/MapListHandler.java
index f557f59..665632a 100644
--- a/src/main/java/org/apache/commons/dbutils2/handlers/MapListHandler.java
+++ b/src/main/java/org/apache/commons/dbutils2/handlers/MapListHandler.java
@@ -58,6 +58,7 @@ public class MapListHandler extends AbstractListHandler<Map<String, Object>> {
/**
* Converts the <code>ResultSet</code> row into a <code>Map</code> object.
+ *
* @param rs <code>ResultSet</code> to process.
* @return A <code>Map</code>, never null.
*
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/f1e96c2c/src/main/java/org/apache/commons/dbutils2/handlers/ScalarHandler.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/handlers/ScalarHandler.java b/src/main/java/org/apache/commons/dbutils2/handlers/ScalarHandler.java
index 902c380..1ed8f12 100644
--- a/src/main/java/org/apache/commons/dbutils2/handlers/ScalarHandler.java
+++ b/src/main/java/org/apache/commons/dbutils2/handlers/ScalarHandler.java
@@ -69,7 +69,9 @@ public class ScalarHandler<T> implements ResultSetHandler<T> {
this(1, columnName);
}
- /** Helper constructor
+ /**
+ * Helper constructor
+ *
* @param columnIndex The index of the column to retrieve from the
* <code>ResultSet</code>.
* @param columnName The name of the column to retrieve from the
@@ -84,6 +86,7 @@ public class ScalarHandler<T> implements ResultSetHandler<T> {
* Returns one <code>ResultSet</code> column as an object via the
* <code>ResultSet.getObject()</code> method that performs type
* conversions.
+ *
* @param rs <code>ResultSet</code> to process.
* @return The column or <code>null</code> if there are no rows in
* the <code>ResultSet</code>.
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/f1e96c2c/src/main/java/org/apache/commons/dbutils2/wrappers/StringTrimmedResultSet.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/wrappers/StringTrimmedResultSet.java b/src/main/java/org/apache/commons/dbutils2/wrappers/StringTrimmedResultSet.java
index c65dbb6..0648f9c 100644
--- a/src/main/java/org/apache/commons/dbutils2/wrappers/StringTrimmedResultSet.java
+++ b/src/main/java/org/apache/commons/dbutils2/wrappers/StringTrimmedResultSet.java
@@ -72,6 +72,7 @@ public class StringTrimmedResultSet implements InvocationHandler {
/**
* Constructs a new instance of <code>StringTrimmedResultSet</code>
* to wrap the specified <code>ResultSet</code>.
+ *
* @param rs ResultSet to wrap
*/
public StringTrimmedResultSet(ResultSet rs) {
[46/58] [abbrv] commons-dbutils git commit: Use multi-line
description rather than dummy action to provide the info.
Posted by th...@apache.org.
Use multi-line description rather than dummy action to provide the info.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/dbutils/branches/2_0@1482102 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/commons-dbutils/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-dbutils/commit/70b01582
Tree: http://git-wip-us.apache.org/repos/asf/commons-dbutils/tree/70b01582
Diff: http://git-wip-us.apache.org/repos/asf/commons-dbutils/diff/70b01582
Branch: refs/heads/2_0
Commit: 70b01582f6e3205fb6c46d504922b2425704e7e1
Parents: 9c8f3b0
Author: Sebastian Bazley <se...@apache.org>
Authored: Mon May 13 20:57:38 2013 +0000
Committer: Sebastian Bazley <se...@apache.org>
Committed: Mon May 13 20:57:38 2013 +0000
----------------------------------------------------------------------
RELEASE-NOTES.txt | 12 +++++++-----
src/changes/changes.xml | 10 +++++-----
2 files changed, 12 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/70b01582/RELEASE-NOTES.txt
----------------------------------------------------------------------
diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt
index 13fdbf8..d23946b 100644
--- a/RELEASE-NOTES.txt
+++ b/RELEASE-NOTES.txt
@@ -1,5 +1,5 @@
- Apache Commons DbUtils
+ Apache Commons DbUtils
Version 2.0
RELEASE NOTES
@@ -8,17 +8,19 @@ The Commons DbUtils team is pleased to announce the release of Commons DbUtils 2
The Apache Commons-DbUtils package is a set of
Java utility classes for easing JDBC development.
-Complete re-write of QueryRunner to use a fluent API and provide named bindings.
-*Note: This version is NOT backwards compatible with 1.x versions.
+Backwards incompatible update of Commons DBUtils
+
+This is the first release of the 2.x branch of the Commons DbUtils package, DbUtils2.
+The motivation for creating DbUtils2 was two-fold: a number of deprecated methods in the original DbUtils, and the desire to support named parameters (DBUTILS-105).
Changes in this version include:
New features:
-o DBUTILS-105: Add Named Parameter Support
+o DBUTILS-105: Added named parameter support with fluent API
Fixed Bugs:
+o DBUTILS-109: AbstractExecutor.currentPosition should be an int
-Changes:
For complete information on Commons DbUtils, including instructions on how to submit bug reports,
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/70b01582/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 04a3b04..a19d1ed 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -43,11 +43,11 @@ The <action> type attribute can be add,update,fix,remove.
<title>Release Notes</title>
</properties>
<body>
- <release version="2.0" date="2013-??-??" description="Backwards incompatible update of Commons DBUtils">
- <action dev="wspeirs" type="add">
- This is the first release of the 2.x branch of the Commons DbUtils package, DbUtils2.
- The motivation for creating DbUtils2 was two-fold: a number of deprecated methods in the original DbUtils, and the desire to support named parameters (DBUTILS-105).
- </action>
+ <release version="2.0" date="2013-??-??" description="Backwards incompatible update of Commons DBUtils
+
+ This is the first release of the 2.x branch of the Commons DbUtils package, DbUtils2.
+ The motivation for creating DbUtils2 was two-fold: a number of deprecated methods in the original DbUtils, and the desire to support named parameters (DBUTILS-105).
+ ">
<action dev="sebb" type="fix" issue="DBUTILS-109">
AbstractExecutor.currentPosition should be an int
</action>
[26/58] [abbrv] commons-dbutils git commit: Removed @author tags and
updated notice file
Posted by th...@apache.org.
Removed @author tags and updated notice file
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/dbutils/branches/2_0@1481163 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/commons-dbutils/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-dbutils/commit/3f4dcc9d
Tree: http://git-wip-us.apache.org/repos/asf/commons-dbutils/tree/3f4dcc9d
Diff: http://git-wip-us.apache.org/repos/asf/commons-dbutils/diff/3f4dcc9d
Branch: refs/heads/2_0
Commit: 3f4dcc9d79c280583d9b2f66f49c2eb60acaca58
Parents: f3951b9
Author: Bill Speirs <ws...@apache.org>
Authored: Fri May 10 19:49:40 2013 +0000
Committer: Bill Speirs <ws...@apache.org>
Committed: Fri May 10 19:49:40 2013 +0000
----------------------------------------------------------------------
NOTICE.txt | 2 +-
src/main/java/org/apache/commons/dbutils2/AbstractExecutor.java | 1 -
src/main/java/org/apache/commons/dbutils2/AsyncExecutor.java | 1 -
src/main/java/org/apache/commons/dbutils2/BatchExecutor.java | 1 -
src/main/java/org/apache/commons/dbutils2/InsertExecutor.java | 1 -
src/main/java/org/apache/commons/dbutils2/QueryExecutor.java | 1 -
src/main/java/org/apache/commons/dbutils2/UpdateExecutor.java | 1 -
7 files changed, 1 insertion(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/3f4dcc9d/NOTICE.txt
----------------------------------------------------------------------
diff --git a/NOTICE.txt b/NOTICE.txt
index 6c2e300..25b3c88 100644
--- a/NOTICE.txt
+++ b/NOTICE.txt
@@ -1,5 +1,5 @@
Apache Commons DbUtils
-Copyright 2002-2012 The Apache Software Foundation
+Copyright 2002-2013 The Apache Software Foundation
This product includes software developed at
The Apache Software Foundation (http://www.apache.org/).
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/3f4dcc9d/src/main/java/org/apache/commons/dbutils2/AbstractExecutor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/AbstractExecutor.java b/src/main/java/org/apache/commons/dbutils2/AbstractExecutor.java
index 25a9ab8..c8cb578 100644
--- a/src/main/java/org/apache/commons/dbutils2/AbstractExecutor.java
+++ b/src/main/java/org/apache/commons/dbutils2/AbstractExecutor.java
@@ -34,7 +34,6 @@ import java.util.regex.Pattern;
* Abstract class for executing a query, insert, update, or batch.
*
* @since 2.0
- * @author William Speirs <ws...@apache.org>
*/
abstract class AbstractExecutor<T extends AbstractExecutor<T>> {
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/3f4dcc9d/src/main/java/org/apache/commons/dbutils2/AsyncExecutor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/AsyncExecutor.java b/src/main/java/org/apache/commons/dbutils2/AsyncExecutor.java
index 298ed62..afcfdb2 100644
--- a/src/main/java/org/apache/commons/dbutils2/AsyncExecutor.java
+++ b/src/main/java/org/apache/commons/dbutils2/AsyncExecutor.java
@@ -24,7 +24,6 @@ import java.util.concurrent.Future;
/**
* Convenience class for executing QueryExecutor, InsertExecutor, or UpdateExecutors asynchronously.
*
- * @author William Speirs <ws...@apache.org>
* @since 2.0
*/
public class AsyncExecutor {
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/3f4dcc9d/src/main/java/org/apache/commons/dbutils2/BatchExecutor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/BatchExecutor.java b/src/main/java/org/apache/commons/dbutils2/BatchExecutor.java
index d25d435..8569873 100644
--- a/src/main/java/org/apache/commons/dbutils2/BatchExecutor.java
+++ b/src/main/java/org/apache/commons/dbutils2/BatchExecutor.java
@@ -26,7 +26,6 @@ import java.sql.Types;
* It is really just a facade to an array of UpdateExecutors.
*
* @since 2.0
- * @author William Speirs <ws...@apache.org>
*/
public class BatchExecutor extends AbstractExecutor<BatchExecutor> {
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/3f4dcc9d/src/main/java/org/apache/commons/dbutils2/InsertExecutor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/InsertExecutor.java b/src/main/java/org/apache/commons/dbutils2/InsertExecutor.java
index 73c1b30..f1aa78a 100644
--- a/src/main/java/org/apache/commons/dbutils2/InsertExecutor.java
+++ b/src/main/java/org/apache/commons/dbutils2/InsertExecutor.java
@@ -25,7 +25,6 @@ import java.sql.SQLException;
* Fluent class for executing inserts.
*
* @since 2.0
- * @author William Speirs <ws...@apache.org>
*/
public class InsertExecutor extends AbstractExecutor<InsertExecutor> {
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/3f4dcc9d/src/main/java/org/apache/commons/dbutils2/QueryExecutor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/QueryExecutor.java b/src/main/java/org/apache/commons/dbutils2/QueryExecutor.java
index 0b29dc3..fe59db1 100644
--- a/src/main/java/org/apache/commons/dbutils2/QueryExecutor.java
+++ b/src/main/java/org/apache/commons/dbutils2/QueryExecutor.java
@@ -24,7 +24,6 @@ import java.sql.SQLException;
* Fluent class for executing a query.
*
* @since 2.0
- * @author William Speirs <ws...@apache.org>
*/
class QueryExecutor extends AbstractExecutor<QueryExecutor> {
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/3f4dcc9d/src/main/java/org/apache/commons/dbutils2/UpdateExecutor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/UpdateExecutor.java b/src/main/java/org/apache/commons/dbutils2/UpdateExecutor.java
index 580736b..7ee34f4 100644
--- a/src/main/java/org/apache/commons/dbutils2/UpdateExecutor.java
+++ b/src/main/java/org/apache/commons/dbutils2/UpdateExecutor.java
@@ -23,7 +23,6 @@ import java.sql.SQLException;
* Fluent class for executing updates.
*
* @since 2.0
- * @author William Speirs <ws...@apache.org>
*/
public class UpdateExecutor extends AbstractExecutor<UpdateExecutor> {
[55/58] [abbrv] commons-dbutils git commit: DBUTILS-103 fix
Dependencies documentation to reference correct Java version
Posted by th...@apache.org.
DBUTILS-103 fix Dependencies documentation to reference correct Java version
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/dbutils/branches/2_0@1482469 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/commons-dbutils/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-dbutils/commit/c5d4dd86
Tree: http://git-wip-us.apache.org/repos/asf/commons-dbutils/tree/c5d4dd86
Diff: http://git-wip-us.apache.org/repos/asf/commons-dbutils/diff/c5d4dd86
Branch: refs/heads/2_0
Commit: c5d4dd8646932c44ec68ed06ffb453e27c5f7768
Parents: d9e63ee
Author: Sebastian Bazley <se...@apache.org>
Authored: Tue May 14 17:10:33 2013 +0000
Committer: Sebastian Bazley <se...@apache.org>
Committed: Tue May 14 17:10:33 2013 +0000
----------------------------------------------------------------------
src/site/xdoc/index.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/c5d4dd86/src/site/xdoc/index.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/index.xml b/src/site/xdoc/index.xml
index 597bdd1..5d02a94 100644
--- a/src/site/xdoc/index.xml
+++ b/src/site/xdoc/index.xml
@@ -115,7 +115,7 @@ Please see <a href="examples.html">Examples Page</a>.
<section name="Dependencies">
<p>
DbUtils is intentionally a single jar distribution and relies only on
- a standard Java 1.5 or later JRE.
+ a standard Java 1.6 or later JRE.
</p>
</section>
[36/58] [abbrv] commons-dbutils git commit: Added a foreach loop
Posted by th...@apache.org.
Added a foreach loop
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/dbutils/branches/2_0@1481745 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/commons-dbutils/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-dbutils/commit/392c9fb1
Tree: http://git-wip-us.apache.org/repos/asf/commons-dbutils/tree/392c9fb1
Diff: http://git-wip-us.apache.org/repos/asf/commons-dbutils/diff/392c9fb1
Branch: refs/heads/2_0
Commit: 392c9fb1e69b2337365e4ac1d04c78470ca984b1
Parents: c05691b
Author: Emmanuel Bourg <eb...@apache.org>
Authored: Mon May 13 09:18:10 2013 +0000
Committer: Emmanuel Bourg <eb...@apache.org>
Committed: Mon May 13 09:18:10 2013 +0000
----------------------------------------------------------------------
.../commons/dbutils2/wrappers/SqlNullCheckedResultSet.java | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/392c9fb1/src/main/java/org/apache/commons/dbutils2/wrappers/SqlNullCheckedResultSet.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/wrappers/SqlNullCheckedResultSet.java b/src/main/java/org/apache/commons/dbutils2/wrappers/SqlNullCheckedResultSet.java
index 71e6661..86a3799 100644
--- a/src/main/java/org/apache/commons/dbutils2/wrappers/SqlNullCheckedResultSet.java
+++ b/src/main/java/org/apache/commons/dbutils2/wrappers/SqlNullCheckedResultSet.java
@@ -83,13 +83,12 @@ public class SqlNullCheckedResultSet implements InvocationHandler {
private static final String GET_NULL_PREFIX = "getNull";
static {
- Method[] methods = SqlNullCheckedResultSet.class.getMethods();
- for (int i = 0; i < methods.length; i++) {
- String methodName = methods[i].getName();
+ for (Method method : SqlNullCheckedResultSet.class.getMethods()) {
+ String methodName = method.getName();
if (methodName.startsWith(GET_NULL_PREFIX)) {
String normalName = "get" + methodName.substring(GET_NULL_PREFIX.length());
- nullMethods.put(normalName, methods[i]);
+ nullMethods.put(normalName, method);
}
}
}
[12/58] [abbrv] commons-dbutils git commit: Fixed a number of
FindBugs and Checkstyle issues
Posted by th...@apache.org.
Fixed a number of FindBugs and Checkstyle issues
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/dbutils/branches/2_0@1454865 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/commons-dbutils/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-dbutils/commit/3535b10b
Tree: http://git-wip-us.apache.org/repos/asf/commons-dbutils/tree/3535b10b
Diff: http://git-wip-us.apache.org/repos/asf/commons-dbutils/diff/3535b10b
Branch: refs/heads/2_0
Commit: 3535b10b8f0da0313b74ca4c4e8e1535cb2528b7
Parents: 41d6d58
Author: Bill Speirs <ws...@apache.org>
Authored: Sun Mar 10 15:39:45 2013 +0000
Committer: Bill Speirs <ws...@apache.org>
Committed: Sun Mar 10 15:39:45 2013 +0000
----------------------------------------------------------------------
pom.xml | 4 +-
src/changes/changes.xml | 7 +-
.../commons/dbutils2/AbstractExecutor.java | 88 ++---
.../apache/commons/dbutils2/AsyncExecutor.java | 13 +-
.../commons/dbutils2/BaseResultSetHandler.java | 384 +++++++++----------
.../apache/commons/dbutils2/BatchExecutor.java | 29 +-
.../org/apache/commons/dbutils2/DbUtils.java | 20 +-
.../commons/dbutils2/GenerousBeanProcessor.java | 18 +-
.../apache/commons/dbutils2/InsertExecutor.java | 28 +-
.../apache/commons/dbutils2/QueryExecutor.java | 15 +-
.../apache/commons/dbutils2/QueryRunner.java | 56 +--
.../apache/commons/dbutils2/UpdateExecutor.java | 18 +-
.../commons/dbutils2/handlers/KeyedHandler.java | 10 +-
.../wrappers/SqlNullCheckedResultSet.java | 14 +-
14 files changed, 383 insertions(+), 321 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/3535b10b/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 064e30c..ac487de 100644
--- a/pom.xml
+++ b/pom.xml
@@ -225,8 +225,8 @@
<maven.compile.source>1.6</maven.compile.source>
<maven.compile.target>1.6</maven.compile.target>
<commons.componentid>dbutils</commons.componentid>
- <commons.release.version>1.5</commons.release.version>
- <commons.rc.version>RC2</commons.rc.version>
+ <commons.release.version>2.0</commons.release.version>
+ <commons.rc.version>RC1</commons.rc.version>
<commons.jira.id>DBUTILS</commons.jira.id>
<commons.jira.pid>12310470</commons.jira.pid>
</properties>
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/3535b10b/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index b40ef42..311c99f 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -43,7 +43,12 @@ The <action> type attribute can be add,update,fix,remove.
<title>Release Notes</title>
</properties>
<body>
- <release version="1.6" date="201?-??-??" description="Bugfixes and addition of insert methods">
+ <release version="2.0" date="2013-??-??" description="Backwards incompatible update of Commons DBUtils">
+ <action dev="wspeirs" type="add" issue="DBUTILS-105">
+ Added named parameter support with fluent API
+ </action>
+ </release>
+ <release version="1.6" date="2013-??-??" description="Bugfixes and addition of insert methods">
<action dev="simonetripodi" due-to="Moandji Ezana" type="add" issue="DBUTILS-98">
Add missing JavaDoc to QueryRunner#insert
</action>
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/3535b10b/src/main/java/org/apache/commons/dbutils2/AbstractExecutor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/AbstractExecutor.java b/src/main/java/org/apache/commons/dbutils2/AbstractExecutor.java
index be0e2ac..da25cd7 100644
--- a/src/main/java/org/apache/commons/dbutils2/AbstractExecutor.java
+++ b/src/main/java/org/apache/commons/dbutils2/AbstractExecutor.java
@@ -32,12 +32,12 @@ import java.util.regex.Pattern;
/**
* Abstract class for executing a query, insert, update, or batch.
- *
+ *
* @since 2.0
* @author William Speirs <ws...@apache.org>
*/
abstract class AbstractExecutor<T extends AbstractExecutor<T>> {
-
+
private static final String COLON = ":"; // TODO: change this to any character
private final Connection conn;
@@ -47,42 +47,42 @@ abstract class AbstractExecutor<T extends AbstractExecutor<T>> {
private final Map<String, List<Integer>> paramPosMap;
private final Map<String, Object> paramValueMap;
private Integer currentPosition = Integer.valueOf(0);
-
+
public AbstractExecutor(final Connection conn, final String sql) throws SQLException {
this.conn = conn;
this.sql = sql;
this.paramPosMap = new HashMap<String, List<Integer>>();
this.paramValueMap = new HashMap<String, Object>();
-
+
final Pattern paramPattern = Pattern.compile("(:\\w+)");
final Matcher matcher = paramPattern.matcher(sql);
// go through finding params
- while(matcher.find()) {
+ while (matcher.find()) {
insertParamPosition(matcher.group().replace(COLON, ""));
}
-
+
// replace all of the :names with ?, and create a prepared statement
stmt = conn.prepareStatement(sql.replaceAll(":\\w+", "\\?"));
}
-
+
/**
* Helper method to insert params and the current position into the map.
* @param param the SQL param.
*/
private void insertParamPosition(final String param) {
List<Integer> posList = paramPosMap.get(param);
-
+
// create a new list if we need to
- if(posList == null) {
+ if (posList == null) {
posList = new ArrayList<Integer>();
paramPosMap.put(param, posList);
}
-
+
// increment first, so we match SQL numbering
posList.add(++currentPosition);
}
-
+
/**
* Gets the SQL statement that was passed into the constructor.
* @return the SQL statement passed into the constructor.
@@ -90,7 +90,7 @@ abstract class AbstractExecutor<T extends AbstractExecutor<T>> {
protected String getSql() {
return sql;
}
-
+
/**
* Returns the underlying prepared statement.
* @return the underlying prepared statement.
@@ -98,7 +98,7 @@ abstract class AbstractExecutor<T extends AbstractExecutor<T>> {
protected PreparedStatement getStatement() {
return stmt;
}
-
+
/**
* Returns the underlying connection.
* @return the underlying connection.
@@ -106,32 +106,32 @@ abstract class AbstractExecutor<T extends AbstractExecutor<T>> {
protected Connection getConnection() {
return conn;
}
-
+
/**
* Throws an exception if there are unmapped params.
* @throws SQLException if there are unmapped params.
*/
- protected void throwIfUnmappedParams() throws SQLException {
- if(paramPosMap.size() != 0) {
+ protected void throwIfUnmappedParams() throws SQLException {
+ if (paramPosMap.size() != 0) {
final Set<String> unmappedParams = paramPosMap.keySet();
final StringBuilder sb = new StringBuilder("There are unbound parameters: ");
-
- for(String param:unmappedParams) {
+
+ for (String param:unmappedParams) {
sb.append(param);
sb.append(", ");
}
-
+
// remove the last comma
- sb.delete(sb.length()-2, sb.length());
-
+ sb.delete(sb.length() - 2, sb.length());
+
// throw our exception
throw new SQLException(sb.toString());
}
}
-
+
/**
* Binds a named parameter to a value.
- *
+ *
* @param name the name of the parameter in the SQL statement.
* @param value the value of the parameter in the SQL statement.
* @return this execution object to provide the fluent style.
@@ -140,7 +140,7 @@ abstract class AbstractExecutor<T extends AbstractExecutor<T>> {
public T bind(final String name, final Object value) throws SQLException {
return bind(name, value, true);
}
-
+
/**
* Binds null to a parameter.
* Types.VARCHAR is used as the type's parameter.
@@ -152,7 +152,7 @@ abstract class AbstractExecutor<T extends AbstractExecutor<T>> {
public T bindNull(final String name) throws SQLException {
return bindNull(name, Types.VARCHAR, true);
}
-
+
/**
* Binds null to a parameter, specifying the parameter's type.
* @param name the name of the parameter.
@@ -163,7 +163,7 @@ abstract class AbstractExecutor<T extends AbstractExecutor<T>> {
public T bindNull(final String name, final int sqlType) throws SQLException {
return bindNull(name, sqlType, true);
}
-
+
/**
* Given a param name and sqlType, binds a null to that parameter.
* @param name the name of the parameter.
@@ -176,23 +176,23 @@ abstract class AbstractExecutor<T extends AbstractExecutor<T>> {
name = name.replace(COLON, ""); // so we can take ":name" or "name"
final List<Integer> pos = removeFromPosMap ? paramPosMap.remove(name) : paramPosMap.get(name);
-
- if(pos == null) {
+
+ if (pos == null) {
throw new SQLException(name + " is not found in the SQL statement");
}
-
+
// go through and bind all of the positions for this name
- for(Integer p:pos) {
+ for (Integer p:pos) {
stmt.setNull(p, sqlType);
}
-
+
// add the param and value to our map
paramValueMap.put(name, null);
-
+
// suppressed because the casting will always work here
@SuppressWarnings("unchecked")
final T ret = (T) this;
-
+
return ret;
}
@@ -208,27 +208,27 @@ abstract class AbstractExecutor<T extends AbstractExecutor<T>> {
name = name.replace(COLON, ""); // so we can take ":name" or "name"
final List<Integer> pos = removeFromPosMap ? paramPosMap.remove(name) : paramPosMap.get(name);
-
- if(pos == null) {
+
+ if (pos == null) {
throw new SQLException(name + " is not found in the SQL statement");
}
-
+
// go through and bind all of the positions for this name
- for(Integer p:pos) {
+ for (Integer p:pos) {
// TODO: need to figure out how to bind NULL
stmt.setObject(p, value);
}
-
+
// add the param and value to our map
paramValueMap.put(name, value);
-
+
// suppressed because the casting will always work here
@SuppressWarnings("unchecked")
final T ret = (T) this;
-
+
return ret;
}
-
+
/**
* Used for batch calls so we can clear the map after the addBatch call.
*/
@@ -246,11 +246,11 @@ abstract class AbstractExecutor<T extends AbstractExecutor<T>> {
*/
protected void rethrow(SQLException cause) throws SQLException {
String causeMessage = cause.getMessage();
-
+
if (causeMessage == null) {
causeMessage = "";
}
-
+
final StringBuffer msg = new StringBuffer(causeMessage);
msg.append(" Query: ");
@@ -258,7 +258,7 @@ abstract class AbstractExecutor<T extends AbstractExecutor<T>> {
msg.append(" Parameters: ");
// loop through adding the parameter to value mappings
- for(Map.Entry<String, Object> param:paramValueMap.entrySet()) {
+ for (Map.Entry<String, Object> param:paramValueMap.entrySet()) {
msg.append(param.getKey());
msg.append("=");
msg.append(param.getValue());
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/3535b10b/src/main/java/org/apache/commons/dbutils2/AsyncExecutor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/AsyncExecutor.java b/src/main/java/org/apache/commons/dbutils2/AsyncExecutor.java
index 41cb990..298ed62 100644
--- a/src/main/java/org/apache/commons/dbutils2/AsyncExecutor.java
+++ b/src/main/java/org/apache/commons/dbutils2/AsyncExecutor.java
@@ -35,31 +35,32 @@ public class AsyncExecutor {
* Constructor for AsyncQueryRunner which uses a provided ExecutorService and underlying QueryRunner.
*
* @param executorService the {@code ExecutorService} instance used to run JDBC invocations concurrently.
- * @param queryRunner the {@code QueryRunner} instance to use for the queries.
*/
public AsyncExecutor(ExecutorService executorService) {
this.executorService = executorService;
}
-
+
/**
* Execute a {@link org.apache.commons.dbutils2.BatchExecutor}.
+ * @param executor The executor for this SQL statement.
* @return A <code>Future</code> which returns the result of the batch call.
* @throws SQLException if a database access error occurs
*/
public Future<int[]> execute(final BatchExecutor executor) throws SQLException {
return executorService.submit(new Callable<int[]>() {
-
+
@Override
public int[] call() throws Exception {
return executor.execute();
}
-
+
});
}
/**
* Execute a {@link org.apache.commons.dbutils2.QueryExecutor} given a handler.
* @param <T> The type of object that the handler returns
+ * @param executor The executor for this SQL statement.
* @param handler The handler that converts the results into an object.
* @return A <code>Future</code> which returns the result of the query call.
* @throws SQLException if a database access error occurs
@@ -77,7 +78,7 @@ public class AsyncExecutor {
/**
* Execute a {@link org.apache.commons.dbutils2.UpdateExecutor}.
- * @param <T> The type of object that the handler returns
+ * @param executor The executor for this SQL statement.
* @return A <code>Future</code> which returns the result of the query call.
* @throws SQLException if a database access error occurs
*/
@@ -95,6 +96,7 @@ public class AsyncExecutor {
/**
* Execute a {@link org.apache.commons.dbutils2.InsertExecutor} given a handler.
* @param <T> The type of object that the handler returns
+ * @param executor The executor for this SQL statement.
* @param handler The handler that converts the results into an object.
* @return A <code>Future</code> which returns the result of the query call.
* @throws SQLException if a database access error occurs
@@ -112,6 +114,7 @@ public class AsyncExecutor {
/**
* Execute a {@link org.apache.commons.dbutils2.InsertExecutor} given a handler.
+ * @param executor The executor for this SQL statement.
* @return A <code>Future</code> which returns the number of rows inserted.
* @throws SQLException if a database access error occurs
*/
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/3535b10b/src/main/java/org/apache/commons/dbutils2/BaseResultSetHandler.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/BaseResultSetHandler.java b/src/main/java/org/apache/commons/dbutils2/BaseResultSetHandler.java
index 361f9fa..ef29b32 100644
--- a/src/main/java/org/apache/commons/dbutils2/BaseResultSetHandler.java
+++ b/src/main/java/org/apache/commons/dbutils2/BaseResultSetHandler.java
@@ -86,9 +86,9 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
protected abstract T handle() throws SQLException;
/**
- * @param row
- * @return
- * @throws SQLException
+ * @param row the row.
+ * @return true if absolute.
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#absolute(int)
*/
protected final boolean absolute(int row) throws SQLException {
@@ -96,7 +96,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#afterLast()
*/
protected final void afterLast() throws SQLException {
@@ -104,7 +104,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#beforeFirst()
*/
protected final void beforeFirst() throws SQLException {
@@ -112,7 +112,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#cancelRowUpdates()
*/
protected final void cancelRowUpdates() throws SQLException {
@@ -120,7 +120,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#clearWarnings()
*/
protected final void clearWarnings() throws SQLException {
@@ -128,7 +128,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#close()
*/
protected final void close() throws SQLException {
@@ -136,7 +136,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#deleteRow()
*/
protected final void deleteRow() throws SQLException {
@@ -144,9 +144,9 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnLabel
- * @return
- * @throws SQLException
+ * @param columnLabel the column's label.
+ * @return the column number.
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#findColumn(java.lang.String)
*/
protected final int findColumn(String columnLabel) throws SQLException {
@@ -154,8 +154,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @return
- * @throws SQLException
+ * @return true if it's the first row in the ResultSet.
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#first()
*/
protected final boolean first() throws SQLException {
@@ -163,9 +163,9 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnIndex
- * @return
- * @throws SQLException
+ * @param columnIndex the index of the column.
+ * @return an array of values from the ResultSet.
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getArray(int)
*/
protected final Array getArray(int columnIndex) throws SQLException {
@@ -175,7 +175,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnLabel
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getArray(java.lang.String)
*/
protected final Array getArray(String columnLabel) throws SQLException {
@@ -185,7 +185,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnIndex
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getAsciiStream(int)
*/
protected final InputStream getAsciiStream(int columnIndex) throws SQLException {
@@ -195,7 +195,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnLabel
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getAsciiStream(java.lang.String)
*/
protected final InputStream getAsciiStream(String columnLabel) throws SQLException {
@@ -205,7 +205,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnIndex
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getBigDecimal(int)
*/
protected final BigDecimal getBigDecimal(int columnIndex) throws SQLException {
@@ -215,7 +215,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnLabel
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getBigDecimal(java.lang.String)
*/
protected final BigDecimal getBigDecimal(String columnLabel) throws SQLException {
@@ -225,7 +225,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnIndex
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getBinaryStream(int)
*/
protected final InputStream getBinaryStream(int columnIndex) throws SQLException {
@@ -235,7 +235,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnLabel
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getBinaryStream(java.lang.String)
*/
protected final InputStream getBinaryStream(String columnLabel) throws SQLException {
@@ -245,7 +245,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnIndex
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getBlob(int)
*/
protected final Blob getBlob(int columnIndex) throws SQLException {
@@ -255,7 +255,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnLabel
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getBlob(java.lang.String)
*/
protected final Blob getBlob(String columnLabel) throws SQLException {
@@ -265,7 +265,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnIndex
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getBoolean(int)
*/
protected final boolean getBoolean(int columnIndex) throws SQLException {
@@ -275,7 +275,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnLabel
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getBoolean(java.lang.String)
*/
protected final boolean getBoolean(String columnLabel) throws SQLException {
@@ -285,7 +285,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnIndex
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getByte(int)
*/
protected final byte getByte(int columnIndex) throws SQLException {
@@ -295,7 +295,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnLabel
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getByte(java.lang.String)
*/
protected final byte getByte(String columnLabel) throws SQLException {
@@ -305,7 +305,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnIndex
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getBytes(int)
*/
protected final byte[] getBytes(int columnIndex) throws SQLException {
@@ -315,7 +315,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnLabel
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getBytes(java.lang.String)
*/
protected final byte[] getBytes(String columnLabel) throws SQLException {
@@ -325,7 +325,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnIndex
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getCharacterStream(int)
*/
protected final Reader getCharacterStream(int columnIndex) throws SQLException {
@@ -335,7 +335,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnLabel
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getCharacterStream(java.lang.String)
*/
protected final Reader getCharacterStream(String columnLabel) throws SQLException {
@@ -345,7 +345,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnIndex
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getClob(int)
*/
protected final Clob getClob(int columnIndex) throws SQLException {
@@ -355,7 +355,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnLabel
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getClob(java.lang.String)
*/
protected final Clob getClob(String columnLabel) throws SQLException {
@@ -364,7 +364,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getConcurrency()
*/
protected final int getConcurrency() throws SQLException {
@@ -373,7 +373,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getCursorName()
*/
protected final String getCursorName() throws SQLException {
@@ -384,7 +384,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
* @param columnIndex
* @param cal
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getDate(int, java.util.Calendar)
*/
protected final Date getDate(int columnIndex, Calendar cal) throws SQLException {
@@ -394,7 +394,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnIndex
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getDate(int)
*/
protected final Date getDate(int columnIndex) throws SQLException {
@@ -405,7 +405,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
* @param columnLabel
* @param cal
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getDate(java.lang.String, java.util.Calendar)
*/
protected final Date getDate(String columnLabel, Calendar cal) throws SQLException {
@@ -415,7 +415,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnLabel
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getDate(java.lang.String)
*/
protected final Date getDate(String columnLabel) throws SQLException {
@@ -425,7 +425,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnIndex
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getDouble(int)
*/
protected final double getDouble(int columnIndex) throws SQLException {
@@ -435,7 +435,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnLabel
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getDouble(java.lang.String)
*/
protected final double getDouble(String columnLabel) throws SQLException {
@@ -444,7 +444,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getFetchDirection()
*/
protected final int getFetchDirection() throws SQLException {
@@ -453,7 +453,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getFetchSize()
*/
protected final int getFetchSize() throws SQLException {
@@ -463,7 +463,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnIndex
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getFloat(int)
*/
protected final float getFloat(int columnIndex) throws SQLException {
@@ -473,7 +473,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnLabel
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getFloat(java.lang.String)
*/
protected final float getFloat(String columnLabel) throws SQLException {
@@ -482,7 +482,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getHoldability()
*/
protected final int getHoldability() throws SQLException {
@@ -492,7 +492,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnIndex
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getInt(int)
*/
protected final int getInt(int columnIndex) throws SQLException {
@@ -502,7 +502,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnLabel
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getInt(java.lang.String)
*/
protected final int getInt(String columnLabel) throws SQLException {
@@ -512,7 +512,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnIndex
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getLong(int)
*/
protected final long getLong(int columnIndex) throws SQLException {
@@ -522,7 +522,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnLabel
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getLong(java.lang.String)
*/
protected final long getLong(String columnLabel) throws SQLException {
@@ -531,7 +531,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getMetaData()
*/
protected final ResultSetMetaData getMetaData() throws SQLException {
@@ -541,7 +541,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnIndex
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getNCharacterStream(int)
*/
protected final Reader getNCharacterStream(int columnIndex) throws SQLException {
@@ -551,7 +551,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnLabel
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getNCharacterStream(java.lang.String)
*/
protected final Reader getNCharacterStream(String columnLabel) throws SQLException {
@@ -561,7 +561,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnIndex
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getNClob(int)
*/
protected final NClob getNClob(int columnIndex) throws SQLException {
@@ -571,7 +571,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnLabel
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getNClob(java.lang.String)
*/
protected final NClob getNClob(String columnLabel) throws SQLException {
@@ -581,7 +581,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnIndex
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getNString(int)
*/
protected final String getNString(int columnIndex) throws SQLException {
@@ -591,7 +591,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnLabel
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getNString(java.lang.String)
*/
protected final String getNString(String columnLabel) throws SQLException {
@@ -602,7 +602,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
* @param columnIndex
* @param map
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getObject(int, java.util.Map)
*/
protected final Object getObject(int columnIndex, Map<String, Class<?>> map) throws SQLException {
@@ -612,7 +612,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnIndex
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getObject(int)
*/
protected final Object getObject(int columnIndex) throws SQLException {
@@ -623,7 +623,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
* @param columnLabel
* @param map
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getObject(java.lang.String, java.util.Map)
*/
protected final Object getObject(String columnLabel, Map<String, Class<?>> map) throws SQLException {
@@ -633,7 +633,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnLabel
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getObject(java.lang.String)
*/
protected final Object getObject(String columnLabel) throws SQLException {
@@ -643,7 +643,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnIndex
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getRef(int)
*/
protected final Ref getRef(int columnIndex) throws SQLException {
@@ -653,7 +653,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnLabel
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getRef(java.lang.String)
*/
protected final Ref getRef(String columnLabel) throws SQLException {
@@ -662,7 +662,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getRow()
*/
protected final int getRow() throws SQLException {
@@ -672,7 +672,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnIndex
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getRowId(int)
*/
protected final RowId getRowId(int columnIndex) throws SQLException {
@@ -682,7 +682,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnLabel
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getRowId(java.lang.String)
*/
protected final RowId getRowId(String columnLabel) throws SQLException {
@@ -692,7 +692,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnIndex
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getSQLXML(int)
*/
protected final SQLXML getSQLXML(int columnIndex) throws SQLException {
@@ -702,7 +702,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnLabel
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getSQLXML(java.lang.String)
*/
protected final SQLXML getSQLXML(String columnLabel) throws SQLException {
@@ -712,7 +712,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnIndex
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getShort(int)
*/
protected final short getShort(int columnIndex) throws SQLException {
@@ -722,7 +722,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnLabel
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getShort(java.lang.String)
*/
protected final short getShort(String columnLabel) throws SQLException {
@@ -731,7 +731,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getStatement()
*/
protected final Statement getStatement() throws SQLException {
@@ -741,7 +741,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnIndex
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getString(int)
*/
protected final String getString(int columnIndex) throws SQLException {
@@ -751,7 +751,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnLabel
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getString(java.lang.String)
*/
protected final String getString(String columnLabel) throws SQLException {
@@ -762,7 +762,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
* @param columnIndex
* @param cal
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getTime(int, java.util.Calendar)
*/
protected final Time getTime(int columnIndex, Calendar cal) throws SQLException {
@@ -772,7 +772,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnIndex
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getTime(int)
*/
protected final Time getTime(int columnIndex) throws SQLException {
@@ -783,7 +783,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
* @param columnLabel
* @param cal
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getTime(java.lang.String, java.util.Calendar)
*/
protected final Time getTime(String columnLabel, Calendar cal) throws SQLException {
@@ -793,7 +793,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnLabel
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getTime(java.lang.String)
*/
protected final Time getTime(String columnLabel) throws SQLException {
@@ -804,7 +804,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
* @param columnIndex
* @param cal
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getTimestamp(int, java.util.Calendar)
*/
protected final Timestamp getTimestamp(int columnIndex, Calendar cal) throws SQLException {
@@ -814,7 +814,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnIndex
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getTimestamp(int)
*/
protected final Timestamp getTimestamp(int columnIndex) throws SQLException {
@@ -825,7 +825,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
* @param columnLabel
* @param cal
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getTimestamp(java.lang.String, java.util.Calendar)
*/
protected final Timestamp getTimestamp(String columnLabel, Calendar cal) throws SQLException {
@@ -835,7 +835,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnLabel
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getTimestamp(java.lang.String)
*/
protected final Timestamp getTimestamp(String columnLabel) throws SQLException {
@@ -844,7 +844,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getType()
*/
protected final int getType() throws SQLException {
@@ -854,7 +854,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnIndex
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getURL(int)
*/
protected final URL getURL(int columnIndex) throws SQLException {
@@ -864,7 +864,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnLabel
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getURL(java.lang.String)
*/
protected final URL getURL(String columnLabel) throws SQLException {
@@ -873,7 +873,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getWarnings()
*/
protected final SQLWarning getWarnings() throws SQLException {
@@ -881,7 +881,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#insertRow()
*/
protected final void insertRow() throws SQLException {
@@ -890,7 +890,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#isAfterLast()
*/
protected final boolean isAfterLast() throws SQLException {
@@ -899,7 +899,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#isBeforeFirst()
*/
protected final boolean isBeforeFirst() throws SQLException {
@@ -908,7 +908,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#isClosed()
*/
protected final boolean isClosed() throws SQLException {
@@ -917,7 +917,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#isFirst()
*/
protected final boolean isFirst() throws SQLException {
@@ -926,7 +926,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#isLast()
*/
protected final boolean isLast() throws SQLException {
@@ -936,7 +936,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param iface
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.Wrapper#isWrapperFor(java.lang.Class)
*/
protected final boolean isWrapperFor(Class<?> iface) throws SQLException {
@@ -945,7 +945,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#last()
*/
protected final boolean last() throws SQLException {
@@ -953,7 +953,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#moveToCurrentRow()
*/
protected final void moveToCurrentRow() throws SQLException {
@@ -961,7 +961,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#moveToInsertRow()
*/
protected final void moveToInsertRow() throws SQLException {
@@ -970,7 +970,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#next()
*/
protected final boolean next() throws SQLException {
@@ -979,7 +979,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#previous()
*/
protected final boolean previous() throws SQLException {
@@ -987,7 +987,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#refreshRow()
*/
protected final void refreshRow() throws SQLException {
@@ -997,7 +997,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param rows
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#relative(int)
*/
protected final boolean relative(int rows) throws SQLException {
@@ -1006,7 +1006,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#rowDeleted()
*/
protected final boolean rowDeleted() throws SQLException {
@@ -1015,7 +1015,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#rowInserted()
*/
protected final boolean rowInserted() throws SQLException {
@@ -1024,7 +1024,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#rowUpdated()
*/
protected final boolean rowUpdated() throws SQLException {
@@ -1033,7 +1033,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param direction
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#setFetchDirection(int)
*/
protected final void setFetchDirection(int direction) throws SQLException {
@@ -1042,7 +1042,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param rows
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#setFetchSize(int)
*/
protected final void setFetchSize(int rows) throws SQLException {
@@ -1052,7 +1052,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param iface
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.Wrapper#unwrap(java.lang.Class)
*/
protected final <E> E unwrap(Class<E> iface) throws SQLException {
@@ -1062,7 +1062,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnIndex
* @param x
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateArray(int, java.sql.Array)
*/
protected final void updateArray(int columnIndex, Array x) throws SQLException {
@@ -1072,7 +1072,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnLabel
* @param x
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateArray(java.lang.String, java.sql.Array)
*/
protected final void updateArray(String columnLabel, Array x) throws SQLException {
@@ -1083,7 +1083,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
* @param columnIndex
* @param x
* @param length
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateAsciiStream(int, java.io.InputStream, int)
*/
protected final void updateAsciiStream(int columnIndex, InputStream x, int length) throws SQLException {
@@ -1094,7 +1094,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
* @param columnIndex
* @param x
* @param length
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateAsciiStream(int, java.io.InputStream, long)
*/
protected final void updateAsciiStream(int columnIndex, InputStream x, long length) throws SQLException {
@@ -1104,7 +1104,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnIndex
* @param x
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateAsciiStream(int, java.io.InputStream)
*/
protected final void updateAsciiStream(int columnIndex, InputStream x) throws SQLException {
@@ -1115,7 +1115,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
* @param columnLabel
* @param x
* @param length
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateAsciiStream(java.lang.String, java.io.InputStream, int)
*/
protected final void updateAsciiStream(String columnLabel, InputStream x, int length) throws SQLException {
@@ -1126,7 +1126,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
* @param columnLabel
* @param x
* @param length
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateAsciiStream(java.lang.String, java.io.InputStream, long)
*/
protected final void updateAsciiStream(String columnLabel, InputStream x, long length) throws SQLException {
@@ -1136,7 +1136,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnLabel
* @param x
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateAsciiStream(java.lang.String, java.io.InputStream)
*/
protected final void updateAsciiStream(String columnLabel, InputStream x) throws SQLException {
@@ -1146,7 +1146,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnIndex
* @param x
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateBigDecimal(int, java.math.BigDecimal)
*/
protected final void updateBigDecimal(int columnIndex, BigDecimal x) throws SQLException {
@@ -1156,7 +1156,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnLabel
* @param x
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateBigDecimal(java.lang.String, java.math.BigDecimal)
*/
protected final void updateBigDecimal(String columnLabel, BigDecimal x) throws SQLException {
@@ -1167,7 +1167,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
* @param columnIndex
* @param x
* @param length
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateBinaryStream(int, java.io.InputStream, int)
*/
protected final void updateBinaryStream(int columnIndex, InputStream x, int length) throws SQLException {
@@ -1178,7 +1178,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
* @param columnIndex
* @param x
* @param length
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateBinaryStream(int, java.io.InputStream, long)
*/
protected final void updateBinaryStream(int columnIndex, InputStream x, long length) throws SQLException {
@@ -1188,7 +1188,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnIndex
* @param x
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateBinaryStream(int, java.io.InputStream)
*/
protected final void updateBinaryStream(int columnIndex, InputStream x) throws SQLException {
@@ -1199,7 +1199,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
* @param columnLabel
* @param x
* @param length
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateBinaryStream(java.lang.String, java.io.InputStream, int)
*/
protected final void updateBinaryStream(String columnLabel, InputStream x, int length) throws SQLException {
@@ -1210,7 +1210,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
* @param columnLabel
* @param x
* @param length
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateBinaryStream(java.lang.String, java.io.InputStream, long)
*/
protected final void updateBinaryStream(String columnLabel, InputStream x, long length) throws SQLException {
@@ -1220,7 +1220,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnLabel
* @param x
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateBinaryStream(java.lang.String, java.io.InputStream)
*/
protected final void updateBinaryStream(String columnLabel, InputStream x) throws SQLException {
@@ -1230,7 +1230,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnIndex
* @param x
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateBlob(int, java.sql.Blob)
*/
protected final void updateBlob(int columnIndex, Blob x) throws SQLException {
@@ -1241,7 +1241,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
* @param columnIndex
* @param inputStream
* @param length
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateBlob(int, java.io.InputStream, long)
*/
protected final void updateBlob(int columnIndex, InputStream inputStream, long length) throws SQLException {
@@ -1251,7 +1251,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnIndex
* @param inputStream
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateBlob(int, java.io.InputStream)
*/
protected final void updateBlob(int columnIndex, InputStream inputStream) throws SQLException {
@@ -1261,7 +1261,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnLabel
* @param x
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateBlob(java.lang.String, java.sql.Blob)
*/
protected final void updateBlob(String columnLabel, Blob x) throws SQLException {
@@ -1272,7 +1272,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
* @param columnLabel
* @param inputStream
* @param length
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateBlob(java.lang.String, java.io.InputStream, long)
*/
protected final void updateBlob(String columnLabel, InputStream inputStream, long length) throws SQLException {
@@ -1282,7 +1282,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnLabel
* @param inputStream
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateBlob(java.lang.String, java.io.InputStream)
*/
protected final void updateBlob(String columnLabel, InputStream inputStream) throws SQLException {
@@ -1292,7 +1292,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnIndex
* @param x
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateBoolean(int, boolean)
*/
protected final void updateBoolean(int columnIndex, boolean x) throws SQLException {
@@ -1302,7 +1302,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnLabel
* @param x
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateBoolean(java.lang.String, boolean)
*/
protected final void updateBoolean(String columnLabel, boolean x) throws SQLException {
@@ -1312,7 +1312,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnIndex
* @param x
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateByte(int, byte)
*/
protected final void updateByte(int columnIndex, byte x) throws SQLException {
@@ -1322,7 +1322,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnLabel
* @param x
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateByte(java.lang.String, byte)
*/
protected final void updateByte(String columnLabel, byte x) throws SQLException {
@@ -1332,7 +1332,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnIndex
* @param x
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateBytes(int, byte[])
*/
protected final void updateBytes(int columnIndex, byte[] x) throws SQLException {
@@ -1342,7 +1342,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnLabel
* @param x
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateBytes(java.lang.String, byte[])
*/
protected final void updateBytes(String columnLabel, byte[] x) throws SQLException {
@@ -1353,7 +1353,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
* @param columnIndex
* @param x
* @param length
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateCharacterStream(int, java.io.Reader, int)
*/
protected final void updateCharacterStream(int columnIndex, Reader x, int length) throws SQLException {
@@ -1364,7 +1364,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
* @param columnIndex
* @param x
* @param length
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateCharacterStream(int, java.io.Reader, long)
*/
protected final void updateCharacterStream(int columnIndex, Reader x, long length) throws SQLException {
@@ -1374,7 +1374,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnIndex
* @param x
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateCharacterStream(int, java.io.Reader)
*/
protected final void updateCharacterStream(int columnIndex, Reader x) throws SQLException {
@@ -1385,7 +1385,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
* @param columnLabel
* @param reader
* @param length
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateCharacterStream(java.lang.String, java.io.Reader, int)
*/
protected final void updateCharacterStream(String columnLabel, Reader reader, int length) throws SQLException {
@@ -1396,7 +1396,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
* @param columnLabel
* @param reader
* @param length
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateCharacterStream(java.lang.String, java.io.Reader, long)
*/
protected final void updateCharacterStream(String columnLabel, Reader reader, long length) throws SQLException {
@@ -1406,7 +1406,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnLabel
* @param reader
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateCharacterStream(java.lang.String, java.io.Reader)
*/
protected final void updateCharacterStream(String columnLabel, Reader reader) throws SQLException {
@@ -1416,7 +1416,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnIndex
* @param x
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateClob(int, java.sql.Clob)
*/
protected final void updateClob(int columnIndex, Clob x) throws SQLException {
@@ -1427,7 +1427,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
* @param columnIndex
* @param reader
* @param length
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateClob(int, java.io.Reader, long)
*/
protected final void updateClob(int columnIndex, Reader reader, long length) throws SQLException {
@@ -1437,7 +1437,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnIndex
* @param reader
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateClob(int, java.io.Reader)
*/
protected final void updateClob(int columnIndex, Reader reader) throws SQLException {
@@ -1447,7 +1447,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnLabel
* @param x
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateClob(java.lang.String, java.sql.Clob)
*/
protected final void updateClob(String columnLabel, Clob x) throws SQLException {
@@ -1458,7 +1458,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
* @param columnLabel
* @param reader
* @param length
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateClob(java.lang.String, java.io.Reader, long)
*/
protected final void updateClob(String columnLabel, Reader reader, long length) throws SQLException {
@@ -1468,7 +1468,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnLabel
* @param reader
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateClob(java.lang.String, java.io.Reader)
*/
protected final void updateClob(String columnLabel, Reader reader) throws SQLException {
@@ -1478,7 +1478,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnIndex
* @param x
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateDate(int, java.sql.Date)
*/
protected final void updateDate(int columnIndex, Date x) throws SQLException {
@@ -1488,7 +1488,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnLabel
* @param x
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateDate(java.lang.String, java.sql.Date)
*/
protected final void updateDate(String columnLabel, Date x) throws SQLException {
@@ -1498,7 +1498,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnIndex
* @param x
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateDouble(int, double)
*/
protected final void updateDouble(int columnIndex, double x) throws SQLException {
@@ -1508,7 +1508,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnLabel
* @param x
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateDouble(java.lang.String, double)
*/
protected final void updateDouble(String columnLabel, double x) throws SQLException {
@@ -1518,7 +1518,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnIndex
* @param x
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateFloat(int, float)
*/
protected final void updateFloat(int columnIndex, float x) throws SQLException {
@@ -1528,7 +1528,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnLabel
* @param x
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateFloat(java.lang.String, float)
*/
protected final void updateFloat(String columnLabel, float x) throws SQLException {
@@ -1538,7 +1538,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnIndex
* @param x
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateInt(int, int)
*/
protected final void updateInt(int columnIndex, int x) throws SQLException {
@@ -1548,7 +1548,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnLabel
* @param x
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateInt(java.lang.String, int)
*/
protected final void updateInt(String columnLabel, int x) throws SQLException {
@@ -1558,7 +1558,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnIndex
* @param x
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateLong(int, long)
*/
protected final void updateLong(int columnIndex, long x) throws SQLException {
@@ -1568,7 +1568,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnLabel
* @param x
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateLong(java.lang.String, long)
*/
protected final void updateLong(String columnLabel, long x) throws SQLException {
@@ -1579,7 +1579,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
* @param columnIndex
* @param x
* @param length
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateNCharacterStream(int, java.io.Reader, long)
*/
protected final void updateNCharacterStream(int columnIndex, Reader x, long length) throws SQLException {
@@ -1589,7 +1589,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnIndex
* @param x
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateNCharacterStream(int, java.io.Reader)
*/
protected final void updateNCharacterStream(int columnIndex, Reader x) throws SQLException {
@@ -1600,7 +1600,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
* @param columnLabel
* @param reader
* @param length
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateNCharacterStream(java.lang.String, java.io.Reader, long)
*/
protected final void updateNCharacterStream(String columnLabel, Reader reader, long length) throws SQLException {
@@ -1610,7 +1610,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnLabel
* @param reader
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateNCharacterStream(java.lang.String, java.io.Reader)
*/
protected final void updateNCharacterStream(String columnLabel, Reader reader) throws SQLException {
@@ -1620,7 +1620,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnIndex
* @param nClob
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateNClob(int, java.sql.NClob)
*/
protected final void updateNClob(int columnIndex, NClob nClob) throws SQLException {
@@ -1631,7 +1631,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
* @param columnIndex
* @param reader
* @param length
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateNClob(int, java.io.Reader, long)
*/
protected final void updateNClob(int columnIndex, Reader reader, long length) throws SQLException {
@@ -1641,7 +1641,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnIndex
* @param reader
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateNClob(int, java.io.Reader)
*/
protected final void updateNClob(int columnIndex, Reader reader) throws SQLException {
@@ -1651,7 +1651,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnLabel
* @param nClob
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateNClob(java.lang.String, java.sql.NClob)
*/
protected final void updateNClob(String columnLabel, NClob nClob) throws SQLException {
@@ -1662,7 +1662,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
* @param columnLabel
* @param reader
* @param length
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateNClob(java.lang.String, java.io.Reader, long)
*/
protected final void updateNClob(String columnLabel, Reader reader, long length) throws SQLException {
@@ -1672,7 +1672,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnLabel
* @param reader
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateNClob(java.lang.String, java.io.Reader)
*/
protected final void updateNClob(String columnLabel, Reader reader) throws SQLException {
@@ -1682,7 +1682,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnIndex
* @param nString
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateNString(int, java.lang.String)
*/
protected final void updateNString(int columnIndex, String nString) throws SQLException {
@@ -1692,7 +1692,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnLabel
* @param nString
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateNString(java.lang.String, java.lang.String)
*/
protected final void updateNString(String columnLabel, String nString) throws SQLException {
@@ -1701,7 +1701,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnIndex
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateNull(int)
*/
protected final void updateNull(int columnIndex) throws SQLException {
@@ -1710,7 +1710,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnLabel
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateNull(java.lang.String)
*/
protected final void updateNull(String columnLabel) throws SQLException {
@@ -1721,7 +1721,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
* @param columnIndex
* @param x
* @param scaleOrLength
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateObject(int, java.lang.Object, int)
*/
protected final void updateObject(int columnIndex, Object x, int scaleOrLength) throws SQLException {
@@ -1731,7 +1731,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnIndex
* @param x
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateObject(int, java.lang.Object)
*/
protected final void updateObject(int columnIndex, Object x) throws SQLException {
@@ -1742,7 +1742,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
* @param columnLabel
* @param x
* @param scaleOrLength
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateObject(java.lang.String, java.lang.Object, int)
*/
protected final void updateObject(String columnLabel, Object x, int scaleOrLength) throws SQLException {
@@ -1752,7 +1752,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnLabel
* @param x
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateObject(java.lang.String, java.lang.Object)
*/
protected final void updateObject(String columnLabel, Object x) throws SQLException {
@@ -1762,7 +1762,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnIndex
* @param x
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateRef(int, java.sql.Ref)
*/
protected final void updateRef(int columnIndex, Ref x) throws SQLException {
@@ -1772,7 +1772,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnLabel
* @param x
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateRef(java.lang.String, java.sql.Ref)
*/
protected final void updateRef(String columnLabel, Ref x) throws SQLException {
@@ -1780,7 +1780,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateRow()
*/
protected final void updateRow() throws SQLException {
@@ -1790,7 +1790,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnIndex
* @param x
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateRowId(int, java.sql.RowId)
*/
protected final void updateRowId(int columnIndex, RowId x) throws SQLException {
@@ -1800,7 +1800,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnLabel
* @param x
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateRowId(java.lang.String, java.sql.RowId)
*/
protected final void updateRowId(String columnLabel, RowId x) throws SQLException {
@@ -1810,7 +1810,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnIndex
* @param xmlObject
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateSQLXML(int, java.sql.SQLXML)
*/
protected final void updateSQLXML(int columnIndex, SQLXML xmlObject) throws SQLException {
@@ -1820,7 +1820,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnLabel
* @param xmlObject
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateSQLXML(java.lang.String, java.sql.SQLXML)
*/
protected final void updateSQLXML(String columnLabel, SQLXML xmlObject) throws SQLException {
@@ -1830,7 +1830,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnIndex
* @param x
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateShort(int, short)
*/
protected final void updateShort(int columnIndex, short x) throws SQLException {
@@ -1840,7 +1840,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnLabel
* @param x
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateShort(java.lang.String, short)
*/
protected final void updateShort(String columnLabel, short x) throws SQLException {
@@ -1850,7 +1850,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnIndex
* @param x
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateString(int, java.lang.String)
*/
protected final void updateString(int columnIndex, String x) throws SQLException {
@@ -1860,7 +1860,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnLabel
* @param x
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateString(java.lang.String, java.lang.String)
*/
protected final void updateString(String columnLabel, String x) throws SQLException {
@@ -1870,7 +1870,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnIndex
* @param x
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateTime(int, java.sql.Time)
*/
protected final void updateTime(int columnIndex, Time x) throws SQLException {
@@ -1880,7 +1880,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnLabel
* @param x
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateTime(java.lang.String, java.sql.Time)
*/
protected final void updateTime(String columnLabel, Time x) throws SQLException {
@@ -1890,7 +1890,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnIndex
* @param x
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateTimestamp(int, java.sql.Timestamp)
*/
protected final void updateTimestamp(int columnIndex, Timestamp x) throws SQLException {
@@ -1900,7 +1900,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @param columnLabel
* @param x
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateTimestamp(java.lang.String, java.sql.Timestamp)
*/
protected final void updateTimestamp(String columnLabel, Timestamp x) throws SQLException {
@@ -1909,7 +1909,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
/**
* @return
- * @throws SQLException
+ * @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#wasNull()
*/
protected final boolean wasNull() throws SQLException {
[49/58] [abbrv] commons-dbutils git commit: Unused imports
Posted by th...@apache.org.
Unused imports
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/dbutils/branches/2_0@1482108 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/commons-dbutils/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-dbutils/commit/f2fba8d5
Tree: http://git-wip-us.apache.org/repos/asf/commons-dbutils/tree/f2fba8d5
Diff: http://git-wip-us.apache.org/repos/asf/commons-dbutils/diff/f2fba8d5
Branch: refs/heads/2_0
Commit: f2fba8d51576807c6ad67cc8cc0f441e0f5e72ba
Parents: 144fad9
Author: Sebastian Bazley <se...@apache.org>
Authored: Mon May 13 21:05:52 2013 +0000
Committer: Sebastian Bazley <se...@apache.org>
Committed: Mon May 13 21:05:52 2013 +0000
----------------------------------------------------------------------
src/main/java/org/apache/commons/dbutils2/BatchExecutor.java | 1 -
.../java/org/apache/commons/dbutils2/BatchInsertExecutorTest.java | 3 ---
2 files changed, 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/f2fba8d5/src/main/java/org/apache/commons/dbutils2/BatchExecutor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/BatchExecutor.java b/src/main/java/org/apache/commons/dbutils2/BatchExecutor.java
index 4ee5d16..f175a9b 100644
--- a/src/main/java/org/apache/commons/dbutils2/BatchExecutor.java
+++ b/src/main/java/org/apache/commons/dbutils2/BatchExecutor.java
@@ -17,7 +17,6 @@
package org.apache.commons.dbutils2;
import java.sql.Connection;
-import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Types;
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/f2fba8d5/src/test/java/org/apache/commons/dbutils2/BatchInsertExecutorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils2/BatchInsertExecutorTest.java b/src/test/java/org/apache/commons/dbutils2/BatchInsertExecutorTest.java
index 7bb3a85..919374e 100644
--- a/src/test/java/org/apache/commons/dbutils2/BatchInsertExecutorTest.java
+++ b/src/test/java/org/apache/commons/dbutils2/BatchInsertExecutorTest.java
@@ -16,7 +16,6 @@
*/
package org.apache.commons.dbutils2;
-import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.times;
@@ -26,8 +25,6 @@ import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
-import java.util.List;
-import org.apache.commons.dbutils2.handlers.ArrayListHandler;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
[34/58] [abbrv] commons-dbutils git commit: Replaced StringBuffer
with StringBuilder
Posted by th...@apache.org.
Replaced StringBuffer with StringBuilder
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/dbutils/branches/2_0@1481743 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/commons-dbutils/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-dbutils/commit/dfeead1a
Tree: http://git-wip-us.apache.org/repos/asf/commons-dbutils/tree/dfeead1a
Diff: http://git-wip-us.apache.org/repos/asf/commons-dbutils/diff/dfeead1a
Branch: refs/heads/2_0
Commit: dfeead1ac9e05506f3f2a702df180c521447ece2
Parents: f1e96c2
Author: Emmanuel Bourg <eb...@apache.org>
Authored: Mon May 13 09:17:12 2013 +0000
Committer: Emmanuel Bourg <eb...@apache.org>
Committed: Mon May 13 09:17:12 2013 +0000
----------------------------------------------------------------------
src/main/java/org/apache/commons/dbutils2/AbstractExecutor.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/dfeead1a/src/main/java/org/apache/commons/dbutils2/AbstractExecutor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/AbstractExecutor.java b/src/main/java/org/apache/commons/dbutils2/AbstractExecutor.java
index 839bc10..d7bcc96 100644
--- a/src/main/java/org/apache/commons/dbutils2/AbstractExecutor.java
+++ b/src/main/java/org/apache/commons/dbutils2/AbstractExecutor.java
@@ -258,7 +258,7 @@ abstract class AbstractExecutor<T extends AbstractExecutor<T>> {
causeMessage = "";
}
- final StringBuffer msg = new StringBuffer(causeMessage);
+ final StringBuilder msg = new StringBuilder(causeMessage);
msg.append(" Query: ");
msg.append(sql);
[02/58] [abbrv] commons-dbutils git commit: Changed the package names
so dbutils and dbutils2 won't conflict if both loaded
Posted by th...@apache.org.
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/test/java/org/apache/commons/dbutils2/DbUtilsTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils2/DbUtilsTest.java b/src/test/java/org/apache/commons/dbutils2/DbUtilsTest.java
new file mode 100644
index 0000000..3623689
--- /dev/null
+++ b/src/test/java/org/apache/commons/dbutils2/DbUtilsTest.java
@@ -0,0 +1,273 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.dbutils2;
+
+import static org.junit.Assert.fail;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+import org.apache.commons.dbutils2.DbUtils;
+import org.junit.Test;
+
+public class DbUtilsTest {
+
+ @Test
+ public void closeNullConnection() throws Exception {
+ DbUtils.close((Connection) null);
+ }
+
+ @Test
+ public void closeConnection() throws Exception {
+ Connection mockCon = mock(Connection.class);
+ DbUtils.close(mockCon);
+ verify(mockCon).close();
+ }
+
+ @Test
+ public void closeNullResultSet() throws Exception {
+ DbUtils.close((ResultSet) null);
+ }
+
+ @Test
+ public void closeResultSet() throws Exception {
+ ResultSet mockResultSet = mock(ResultSet.class);
+ DbUtils.close(mockResultSet);
+ verify(mockResultSet).close();
+ }
+
+ @Test
+ public void closeNullStatement() throws Exception {
+ DbUtils.close((Statement) null);
+ }
+
+ @Test
+ public void closeStatement() throws Exception {
+ Statement mockStatement = mock(Statement.class);
+ DbUtils.close(mockStatement);
+ verify(mockStatement).close();
+ }
+
+ @Test
+ public void closeQuietlyNullConnection() throws Exception {
+ DbUtils.closeQuietly((Connection) null);
+ }
+
+ @Test
+ public void closeQuietlyConnection() throws Exception {
+ Connection mockConnection = mock(Connection.class);
+ DbUtils.closeQuietly(mockConnection);
+ verify(mockConnection).close();
+ }
+
+ @Test
+ public void closeQuietlyConnectionThrowingException() throws Exception {
+ Connection mockConnection = mock(Connection.class);
+ doThrow(SQLException.class).when(mockConnection).close();
+ DbUtils.closeQuietly(mockConnection);
+ }
+
+ @Test
+ public void closeQuietlyNullResultSet() throws Exception {
+ DbUtils.closeQuietly((ResultSet) null);
+ }
+
+ @Test
+ public void closeQuietlyResultSet() throws Exception {
+ ResultSet mockResultSet = mock(ResultSet.class);
+ DbUtils.closeQuietly(mockResultSet);
+ verify(mockResultSet).close();
+ }
+
+ @Test
+ public void closeQuietlyResultSetThrowingException() throws Exception {
+ ResultSet mockResultSet = mock(ResultSet.class);
+ doThrow(SQLException.class).when(mockResultSet).close();
+ DbUtils.closeQuietly(mockResultSet);
+ }
+
+ @Test
+ public void closeQuietlyNullStatement() throws Exception {
+ DbUtils.closeQuietly((Statement) null);
+ }
+
+ @Test
+ public void closeQuietlyStatement() throws Exception {
+ Statement mockStatement = mock(Statement.class);
+ DbUtils.closeQuietly(mockStatement);
+ verify(mockStatement).close();
+ }
+
+ @Test
+ public void closeQuietlyStatementThrowingException() throws Exception {
+ Statement mockStatement = mock(Statement.class);
+ doThrow(SQLException.class).when(mockStatement).close();
+ DbUtils.closeQuietly(mockStatement);
+ }
+
+ @Test
+ public void closeQuietlyConnectionResultSetStatement() throws Exception {
+ Connection mockConnection = mock(Connection.class);
+ ResultSet mockResultSet = mock(ResultSet.class);
+ Statement mockStatement = mock(Statement.class);
+ DbUtils.closeQuietly(mockConnection, mockStatement, mockResultSet);
+ verify(mockConnection).close();
+ verify(mockResultSet).close();
+ verify(mockStatement).close();
+ }
+
+ @Test
+ public void closeQuietlyConnectionThrowingExceptionResultSetStatement() throws Exception {
+ Connection mockConnection = mock(Connection.class);
+ doThrow(SQLException.class).when(mockConnection).close();
+ ResultSet mockResultSet = mock(ResultSet.class);
+ Statement mockStatement = mock(Statement.class);
+ DbUtils.closeQuietly(mockConnection, mockStatement, mockResultSet);
+ verify(mockConnection).close();
+ verify(mockResultSet).close();
+ verify(mockStatement).close();
+ }
+
+ @Test
+ public void closeQuietlyConnectionResultSetThrowingExceptionStatement() throws Exception {
+ Connection mockConnection = mock(Connection.class);
+ ResultSet mockResultSet = mock(ResultSet.class);
+ doThrow(SQLException.class).when(mockResultSet).close();
+ Statement mockStatement = mock(Statement.class);
+ DbUtils.closeQuietly(mockConnection, mockStatement, mockResultSet);
+ verify(mockConnection).close();
+ verify(mockResultSet).close();
+ verify(mockStatement).close();
+ }
+
+ @Test
+ public void closeQuietlyConnectionResultSetStatementThrowingException() throws Exception {
+ Connection mockConnection = mock(Connection.class);
+ ResultSet mockResultSet = mock(ResultSet.class);
+ Statement mockStatement = mock(Statement.class);
+ doThrow(SQLException.class).when(mockStatement).close();
+ DbUtils.closeQuietly(mockConnection, mockStatement, mockResultSet);
+ verify(mockConnection).close();
+ verify(mockResultSet).close();
+ verify(mockStatement).close();
+ }
+
+ @Test
+ public void commitAndClose() throws Exception {
+ Connection mockConnection = mock(Connection.class);
+ DbUtils.commitAndClose(mockConnection);
+ verify(mockConnection).commit();
+ verify(mockConnection).close();
+ }
+
+ @Test
+ public void commitAndCloseWithException() throws Exception {
+ Connection mockConnection = mock(Connection.class);
+ doThrow(SQLException.class).when(mockConnection).commit();
+ try {
+ DbUtils.commitAndClose(mockConnection);
+ fail("DbUtils.commitAndClose() swallowed SQLEception!");
+ } catch (SQLException e) {
+ // we expect this exception
+ }
+ verify(mockConnection).close();
+ }
+
+ @Test
+ public void commitAndCloseQuietly() throws Exception {
+ Connection mockConnection = mock(Connection.class);
+ DbUtils.commitAndClose(mockConnection);
+ verify(mockConnection).commit();
+ verify(mockConnection).close();
+ }
+
+ @Test
+ public void commitAndCloseQuietlyWithException() throws Exception {
+ Connection mockConnection = mock(Connection.class);
+ doThrow(SQLException.class).when(mockConnection).close();
+ DbUtils.commitAndCloseQuietly(mockConnection);
+ verify(mockConnection).commit();
+ verify(mockConnection).close();
+ }
+
+ @Test
+ public void rollbackNull() throws Exception {
+ DbUtils.rollback(null);
+ }
+
+ @Test
+ public void rollback() throws Exception {
+ Connection mockConnection = mock(Connection.class);
+ DbUtils.rollback(mockConnection);
+ verify(mockConnection).rollback();
+ }
+
+ @Test
+ public void rollbackAndCloseNull() throws Exception {
+ DbUtils.rollbackAndClose(null);
+ }
+
+ @Test
+ public void rollbackAndClose() throws Exception {
+ Connection mockConnection = mock(Connection.class);
+ DbUtils.rollbackAndClose(mockConnection);
+ verify(mockConnection).rollback();
+ verify(mockConnection).close();
+ }
+
+ @Test
+ public void rollbackAndCloseWithException() throws Exception {
+ Connection mockConnection = mock(Connection.class);
+ doThrow(SQLException.class).when(mockConnection).rollback();
+ try {
+ DbUtils.rollbackAndClose(mockConnection);
+ fail("DbUtils.rollbackAndClose() swallowed SQLException!");
+ } catch (SQLException e) {
+ // we expect this exeption
+ }
+ verify(mockConnection).rollback();
+ verify(mockConnection).close();
+ }
+
+ @Test
+ public void rollbackAndCloseQuietlyNull() throws Exception {
+ DbUtils.rollbackAndCloseQuietly(null);
+ }
+
+ @Test
+ public void rollbackAndCloseQuietly() throws Exception {
+ Connection mockConnection = mock(Connection.class);
+ DbUtils.rollbackAndCloseQuietly(mockConnection);
+ verify(mockConnection).rollback();
+ verify(mockConnection).close();
+ }
+
+ @Test
+ public void rollbackAndCloseQuietlyWithException() throws Exception {
+ Connection mockConnection = mock(Connection.class);
+ doThrow(SQLException.class).when(mockConnection).rollback();
+ DbUtils.rollbackAndCloseQuietly(mockConnection);
+ verify(mockConnection).rollback();
+ verify(mockConnection).close();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/test/java/org/apache/commons/dbutils2/GenerousBeanProcessorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils2/GenerousBeanProcessorTest.java b/src/test/java/org/apache/commons/dbutils2/GenerousBeanProcessorTest.java
new file mode 100644
index 0000000..11d0394
--- /dev/null
+++ b/src/test/java/org/apache/commons/dbutils2/GenerousBeanProcessorTest.java
@@ -0,0 +1,115 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.dbutils2;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Mockito.when;
+import java.beans.PropertyDescriptor;
+import java.sql.ResultSetMetaData;
+
+import org.apache.commons.dbutils2.GenerousBeanProcessor;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+
+public class GenerousBeanProcessorTest {
+
+ GenerousBeanProcessor processor = new GenerousBeanProcessor();
+ @Mock ResultSetMetaData metaData;
+ PropertyDescriptor[] propDescriptors;
+
+ @Before
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+
+ propDescriptors = new PropertyDescriptor[3];
+
+ propDescriptors[0] = new PropertyDescriptor("one", TestBean.class);
+ propDescriptors[1] = new PropertyDescriptor("two", TestBean.class);
+ propDescriptors[2] = new PropertyDescriptor("three", TestBean.class);
+ }
+
+ @Test
+ public void testMapColumnsToPropertiesWithOutUnderscores() throws Exception {
+ when(metaData.getColumnCount()).thenReturn(3);
+
+ when(metaData.getColumnLabel(1)).thenReturn("three");
+ when(metaData.getColumnLabel(2)).thenReturn("one");
+ when(metaData.getColumnLabel(3)).thenReturn("two");
+
+ int[] ret = processor.mapColumnsToProperties(metaData, propDescriptors);
+
+ assertNotNull(ret);
+ assertEquals(4, ret.length);
+ assertEquals(-1, ret[0]);
+ assertEquals(2, ret[1]);
+ assertEquals(0, ret[2]);
+ assertEquals(1, ret[3]);
+ }
+
+ @Test
+ public void testMapColumnsToPropertiesWithUnderscores() throws Exception {
+ when(metaData.getColumnCount()).thenReturn(3);
+
+ when(metaData.getColumnLabel(1)).thenReturn("t_h_r_e_e");
+ when(metaData.getColumnLabel(2)).thenReturn("o_n_e");
+ when(metaData.getColumnLabel(3)).thenReturn("t_w_o");
+
+ int[] ret = processor.mapColumnsToProperties(metaData, propDescriptors);
+
+ assertNotNull(ret);
+ assertEquals(4, ret.length);
+ assertEquals(-1, ret[0]);
+ assertEquals(2, ret[1]);
+ assertEquals(0, ret[2]);
+ assertEquals(1, ret[3]);
+ }
+
+ static class TestBean {
+ private String one;
+ private int two;
+ private long three;
+
+ public String getOne() {
+ return one;
+ }
+
+ public void setOne(String one) {
+ this.one = one;
+ }
+
+ public int getTwo() {
+ return two;
+ }
+
+ public void setTwo(int two) {
+ this.two = two;
+ }
+
+ public long getThree() {
+ return three;
+ }
+
+ public void setThree(long three) {
+ this.three = three;
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/test/java/org/apache/commons/dbutils2/InsertExecutorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils2/InsertExecutorTest.java b/src/test/java/org/apache/commons/dbutils2/InsertExecutorTest.java
new file mode 100644
index 0000000..ee7bf11
--- /dev/null
+++ b/src/test/java/org/apache/commons/dbutils2/InsertExecutorTest.java
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.dbutils2;
+
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+import org.apache.commons.dbutils2.InsertExecutor;
+import org.apache.commons.dbutils2.ResultSetHandler;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+
+public class InsertExecutorTest {
+
+ private InsertExecutor executor;
+
+ @Mock private ResultSetHandler<Object> handler;
+ @Mock private Connection conn;
+ @Mock private PreparedStatement stmt;
+ @Mock private ResultSet resultSet;
+
+ @Before
+ public void setup() throws SQLException {
+ MockitoAnnotations.initMocks(this);
+
+ when(conn.prepareStatement(any(String.class))).thenReturn(stmt);
+ when(stmt.getGeneratedKeys()).thenReturn(resultSet);
+ when(handler.handle(any(ResultSet.class))).thenReturn(new Object());
+ }
+
+ protected void createExecutor(String sql) throws Exception {
+ executor = new InsertExecutor(conn, sql, true);
+ }
+
+ @Test
+ public void testGoodSQL() throws Exception {
+ createExecutor("insert into blah");
+
+ Object ret = executor.execute(handler);
+
+ assertNotNull(ret);
+ verify(handler, times(1)).handle(resultSet);
+ verify(conn, times(1)).close();
+ verify(stmt, times(1)).close();
+ }
+
+ @Test(expected=SQLException.class)
+ public void testUnmappedParams() throws Exception {
+ createExecutor("insert into blah (:something)");
+
+ Object ret = executor.execute(handler);
+
+ assertNotNull(ret);
+ verify(handler, times(1)).handle(resultSet);
+ verify(conn, times(1)).close();
+ verify(stmt, times(1)).close();
+ }
+
+ @Test(expected=SQLException.class)
+ public void testNullHandler() throws Exception {
+ createExecutor("insert into blah");
+
+ Object ret = executor.execute(null);
+
+ assertNotNull(ret);
+ verify(handler, times(1)).handle(resultSet);
+ verify(conn, times(1)).close();
+ verify(stmt, times(1)).close();
+ }
+}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/test/java/org/apache/commons/dbutils2/MockResultSet.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils2/MockResultSet.java b/src/test/java/org/apache/commons/dbutils2/MockResultSet.java
new file mode 100644
index 0000000..6944dd1
--- /dev/null
+++ b/src/test/java/org/apache/commons/dbutils2/MockResultSet.java
@@ -0,0 +1,365 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.dbutils2;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.commons.dbutils2.ProxyFactory;
+
+/**
+ * MockResultSet dynamically implements the ResultSet interface.
+ */
+public class MockResultSet implements InvocationHandler {
+
+ /**
+ * Create a <code>MockResultSet</code> proxy object. This is equivalent to:
+ * <pre>
+ * ProxyFactory.instance().createResultSet(new MockResultSet(metaData, rows));
+ * </pre>
+ *
+ * @param metaData
+ * @param rows A null value indicates an empty <code>ResultSet</code>.
+ */
+ public static ResultSet create(ResultSetMetaData metaData,
+ Object[][] rows) {
+ return ProxyFactory.instance().createResultSet(
+ new MockResultSet(metaData, rows));
+ }
+
+ private Object[] currentRow = null;
+
+ private Iterator<Object[]> iter = null;
+
+ private ResultSetMetaData metaData = null;
+
+ private Boolean wasNull = Boolean.FALSE;
+
+ /**
+ * MockResultSet constructor.
+ * @param metaData
+ * @param rows A null value indicates an empty <code>ResultSet</code>.
+ */
+ public MockResultSet(ResultSetMetaData metaData, Object[][] rows) {
+ super();
+ this.metaData = metaData;
+ if (rows == null) {
+ List<Object[]> empty = Collections.emptyList();
+ this.iter = empty.iterator();
+ } else {
+ this.iter = Arrays.asList(rows).iterator();
+ }
+ }
+
+ /**
+ * The get* methods can have an int column index or a String column name as
+ * the parameter. This method handles both cases and returns the column
+ * index that the client is trying to get at.
+ * @param args
+ * @return A column index.
+ * @throws SQLException if a database access error occurs
+ */
+ private int columnIndex(Object[] args) throws SQLException {
+
+ if (args[0] instanceof Integer) {
+ return ((Integer) args[0]).intValue();
+
+ } else if (args[0] instanceof String) {
+ return this.columnNameToIndex((String) args[0]);
+
+ } else {
+ throw new SQLException(args[0] + " must be Integer or String");
+ }
+ }
+
+ /**
+ * Returns the column index for the given column name.
+ * @return A 1 based index
+ * @throws SQLException if the column name is invalid
+ */
+ private int columnNameToIndex(String columnName) throws SQLException {
+ for (int i = 0; i < this.currentRow.length; i++) {
+ int c = i + 1;
+ if (this.metaData.getColumnName(c).equalsIgnoreCase(columnName)) {
+ return c;
+ }
+ }
+
+ throw new SQLException(columnName + " is not a valid column name.");
+ }
+
+ /**
+ * Gets the boolean value at the given column index.
+ * @param columnIndex A 1 based index.
+ * @throws SQLException if a database access error occurs
+ */
+ protected Object getBoolean(int columnIndex) throws SQLException {
+ Object obj = this.currentRow[columnIndex - 1];
+ this.setWasNull(obj);
+
+ try {
+ return (obj == null)
+ ? Boolean.FALSE
+ : Boolean.valueOf(obj.toString());
+
+ } catch (NumberFormatException e) {
+ throw new SQLException(e.getMessage());
+ }
+ }
+
+ /**
+ * Gets the byte value at the given column index.
+ * @param columnIndex A 1 based index.
+ * @throws SQLException if a database access error occurs
+ */
+ protected Object getByte(int columnIndex) throws SQLException {
+ Object obj = this.currentRow[columnIndex - 1];
+ this.setWasNull(obj);
+
+ try {
+ return (obj == null)
+ ? Byte.valueOf((byte) 0)
+ : Byte.valueOf(obj.toString());
+
+ } catch (NumberFormatException e) {
+ throw new SQLException(e.getMessage());
+ }
+ }
+
+ /**
+ * Gets the double value at the given column index.
+ * @param columnIndex A 1 based index.
+ * @throws SQLException if a database access error occurs
+ */
+ protected Object getDouble(int columnIndex) throws SQLException {
+ Object obj = this.currentRow[columnIndex - 1];
+ this.setWasNull(obj);
+
+ try {
+ return (obj == null)
+ ? new Double(0)
+ : Double.valueOf(obj.toString());
+
+ } catch (NumberFormatException e) {
+ throw new SQLException(e.getMessage());
+ }
+ }
+
+ /**
+ * Gets the float value at the given column index.
+ * @param columnIndex A 1 based index.
+ * @throws SQLException if a database access error occurs
+ */
+ protected Object getFloat(int columnIndex) throws SQLException {
+ Object obj = this.currentRow[columnIndex - 1];
+ this.setWasNull(obj);
+
+ try {
+ return (obj == null) ? new Float(0) : Float.valueOf(obj.toString());
+
+ } catch (NumberFormatException e) {
+ throw new SQLException(e.getMessage());
+ }
+ }
+
+ /**
+ * Gets the int value at the given column index.
+ * @param columnIndex A 1 based index.
+ * @throws SQLException if a database access error occurs
+ */
+ protected Object getInt(int columnIndex) throws SQLException {
+ Object obj = this.currentRow[columnIndex - 1];
+ this.setWasNull(obj);
+
+ try {
+ return (obj == null)
+ ? Integer.valueOf(0)
+ : Integer.valueOf(obj.toString());
+
+ } catch (NumberFormatException e) {
+ throw new SQLException(e.getMessage());
+ }
+ }
+
+ /**
+ * Gets the long value at the given column index.
+ * @param columnIndex A 1 based index.
+ * @throws SQLException if a database access error occurs
+ */
+ protected Object getLong(int columnIndex) throws SQLException {
+ Object obj = this.currentRow[columnIndex - 1];
+ this.setWasNull(obj);
+
+ try {
+ return (obj == null) ? Long.valueOf(0) : Long.valueOf(obj.toString());
+
+ } catch (NumberFormatException e) {
+ throw new SQLException(e.getMessage());
+ }
+ }
+
+ /**
+ * @throws SQLException
+ */
+ protected ResultSetMetaData getMetaData() throws SQLException {
+ return this.metaData;
+ }
+
+ /**
+ * Gets the object at the given column index.
+ * @param columnIndex A 1 based index.
+ * @throws SQLException if a database access error occurs
+ */
+ protected Object getObject(int columnIndex) throws SQLException {
+ Object obj = this.currentRow[columnIndex - 1];
+ this.setWasNull(obj);
+ return obj;
+ }
+
+ /**
+ * Gets the short value at the given column index.
+ * @param columnIndex A 1 based index.
+ * @throws SQLException if a database access error occurs
+ */
+ protected Object getShort(int columnIndex) throws SQLException {
+ Object obj = this.currentRow[columnIndex - 1];
+ this.setWasNull(obj);
+
+ try {
+ return (obj == null)
+ ? Short.valueOf((short) 0)
+ : Short.valueOf(obj.toString());
+
+ } catch (NumberFormatException e) {
+ throw new SQLException(e.getMessage());
+ }
+ }
+
+ /**
+ * Gets the String at the given column index.
+ * @param columnIndex A 1 based index.
+ * @throws SQLException if a database access error occurs
+ */
+ protected String getString(int columnIndex) throws SQLException {
+ Object obj = this.getObject(columnIndex);
+ this.setWasNull(obj);
+ return (obj == null) ? null : obj.toString();
+ }
+
+ @Override
+ public Object invoke(Object proxy, Method method, Object[] args)
+ throws Throwable {
+
+ String methodName = method.getName();
+
+ if (methodName.equals("getMetaData")) {
+ return this.getMetaData();
+
+ } else if (methodName.equals("next")) {
+ return this.next();
+
+ } else if (methodName.equals("previous")) {
+
+ } else if (methodName.equals("close")) {
+
+ } else if (methodName.equals("getBoolean")) {
+ return this.getBoolean(columnIndex(args));
+
+ } else if (methodName.equals("getByte")) {
+ return this.getByte(columnIndex(args));
+
+ } else if (methodName.equals("getDouble")) {
+ return this.getDouble(columnIndex(args));
+
+ } else if (methodName.equals("getFloat")) {
+ return this.getFloat(columnIndex(args));
+
+ } else if (methodName.equals("getInt")) {
+ return this.getInt(columnIndex(args));
+
+ } else if (methodName.equals("getLong")) {
+ return this.getLong(columnIndex(args));
+
+ } else if (methodName.equals("getObject")) {
+ return this.getObject(columnIndex(args));
+
+ } else if (methodName.equals("getShort")) {
+ return this.getShort(columnIndex(args));
+
+ } else if (methodName.equals("getString")) {
+ return this.getString(columnIndex(args));
+
+ } else if (methodName.equals("wasNull")) {
+ return this.wasNull();
+
+ } else if (methodName.equals("isLast")) {
+ return this.isLast();
+
+ } else if (methodName.equals("hashCode")) {
+ return Integer.valueOf(System.identityHashCode(proxy));
+
+ } else if (methodName.equals("toString")) {
+ return "MockResultSet " + System.identityHashCode(proxy);
+
+ } else if (methodName.equals("equals")) {
+ return Boolean.valueOf(proxy == args[0]);
+ }
+
+ throw new UnsupportedOperationException("Unsupported method: " + methodName);
+ }
+
+ /**
+ * @throws SQLException
+ */
+ protected Boolean isLast() throws SQLException {
+ return this.iter.hasNext() ? Boolean.FALSE : Boolean.TRUE;
+ }
+
+ /**
+ * @throws SQLException
+ */
+ protected Boolean next() throws SQLException {
+ if (!this.iter.hasNext()) {
+ return Boolean.FALSE;
+ } else {
+ this.currentRow = iter.next();
+ return Boolean.TRUE;
+ }
+ }
+
+ /**
+ * Assigns this.wasNull a Boolean value based on the object passed in.
+ * @param isNull
+ */
+ private void setWasNull(Object isNull) {
+ this.wasNull = (isNull == null) ? Boolean.TRUE : Boolean.FALSE;
+ }
+
+ /**
+ * @throws SQLException
+ */
+ protected Boolean wasNull() throws SQLException {
+ return this.wasNull;
+ }
+}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/test/java/org/apache/commons/dbutils2/MockResultSetMetaData.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils2/MockResultSetMetaData.java b/src/test/java/org/apache/commons/dbutils2/MockResultSetMetaData.java
new file mode 100644
index 0000000..d67a19e
--- /dev/null
+++ b/src/test/java/org/apache/commons/dbutils2/MockResultSetMetaData.java
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.dbutils2;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.sql.ResultSetMetaData;
+
+import org.apache.commons.dbutils2.ProxyFactory;
+
+/**
+ * MockResultSetMetaData dynamically implements the ResultSetMetaData
+ * interface.
+ */
+public class MockResultSetMetaData implements InvocationHandler {
+
+ private String[] columnNames = null;
+ private String[] columnLabels = null;
+
+ /**
+ * Create a <code>MockResultSetMetaData</code> proxy object. This is
+ * equivalent to:
+ * <pre>
+ * ProxyFactory.instance().createResultSetMetaData(new MockResultSetMetaData(columnNames));
+ * </pre>
+ *
+ * @param columnNames
+ * @return the proxy object
+ */
+ public static ResultSetMetaData create(String[] columnNames) {
+ return ProxyFactory.instance().createResultSetMetaData(
+ new MockResultSetMetaData(columnNames));
+ }
+
+ public MockResultSetMetaData(String[] columnNames) {
+ super();
+ this.columnNames = columnNames;
+ this.columnLabels = new String[columnNames.length];
+
+ }
+
+ public MockResultSetMetaData(String[] columnNames, String[] columnLabels) {
+ super();
+ this.columnNames = columnNames;
+ this.columnLabels = columnLabels;
+
+ }
+
+ @Override
+ public Object invoke(Object proxy, Method method, Object[] args)
+ throws Throwable {
+
+ String methodName = method.getName();
+
+ if (methodName.equals("getColumnCount")) {
+ return Integer.valueOf(this.columnNames.length);
+
+ } else if (
+ methodName.equals("getColumnName")) {
+
+ int col = ((Integer) args[0]).intValue() - 1;
+ return this.columnNames[col];
+
+ } else if (
+ methodName.equals("getColumnLabel")) {
+
+ int col = ((Integer) args[0]).intValue() - 1;
+ return this.columnLabels[col];
+
+ } else if (methodName.equals("hashCode")) {
+ return Integer.valueOf(System.identityHashCode(proxy));
+
+ } else if (methodName.equals("toString")) {
+ return "MockResultSetMetaData " + System.identityHashCode(proxy);
+
+ } else if (methodName.equals("equals")) {
+ return Boolean.valueOf(proxy == args[0]);
+
+ } else {
+ throw new UnsupportedOperationException("Unsupported method: " + methodName);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/test/java/org/apache/commons/dbutils2/ProxyFactoryTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils2/ProxyFactoryTest.java b/src/test/java/org/apache/commons/dbutils2/ProxyFactoryTest.java
new file mode 100644
index 0000000..f4125f2
--- /dev/null
+++ b/src/test/java/org/apache/commons/dbutils2/ProxyFactoryTest.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.dbutils2;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+
+import org.apache.commons.dbutils2.ProxyFactory;
+
+/**
+ * ProxyFactoryTest performs simple type checking on proxy objects returned
+ * from a ProxyFactory.
+ */
+public class ProxyFactoryTest extends BaseTestCase {
+
+ private static final InvocationHandler stub = new InvocationHandler() {
+
+ @Override
+ public Object invoke(Object proxy, Method method, Object[] args)
+ throws Throwable {
+
+ return null;
+ }
+ };
+
+ public void testCreateConnection() {
+ assertNotNull(ProxyFactory.instance().createConnection(stub));
+ }
+
+ public void testCreateDriver() {
+ assertNotNull(ProxyFactory.instance().createDriver(stub));
+ }
+
+ public void testCreatePreparedStatement() {
+ assertNotNull(ProxyFactory.instance().createPreparedStatement(stub));
+ }
+
+ public void testCreateResultSet() {
+ assertNotNull(ProxyFactory.instance().createResultSet(stub));
+ }
+
+ public void testCreateResultSetMetaData() {
+ assertNotNull(ProxyFactory.instance().createResultSetMetaData(stub));
+ }
+
+ public void testCreateStatement() {
+ assertNotNull(ProxyFactory.instance().createStatement(stub));
+ }
+
+ public void testCreateCallableStatement() {
+ assertNotNull(ProxyFactory.instance().createCallableStatement(stub));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/test/java/org/apache/commons/dbutils2/QueryExecutorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils2/QueryExecutorTest.java b/src/test/java/org/apache/commons/dbutils2/QueryExecutorTest.java
new file mode 100644
index 0000000..9b7b1e8
--- /dev/null
+++ b/src/test/java/org/apache/commons/dbutils2/QueryExecutorTest.java
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.dbutils2;
+
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+import org.apache.commons.dbutils2.QueryExecutor;
+import org.apache.commons.dbutils2.ResultSetHandler;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+
+public class QueryExecutorTest {
+
+ private QueryExecutor executor;
+
+ @Mock private ResultSetHandler<Object> handler;
+ @Mock private Connection conn;
+ @Mock private PreparedStatement stmt;
+ @Mock private ResultSet resultSet;
+
+ @Before
+ public void setup() throws SQLException {
+ MockitoAnnotations.initMocks(this);
+
+ when(conn.prepareStatement(any(String.class))).thenReturn(stmt);
+ when(stmt.executeQuery()).thenReturn(resultSet);
+ when(handler.handle(any(ResultSet.class))).thenReturn(new Object());
+ }
+
+ protected void createExecutor(String sql) throws Exception {
+ executor = new QueryExecutor(conn, sql, true);
+ }
+
+ @Test
+ public void testGoodSQL() throws Exception {
+ createExecutor("insert into blah");
+
+ Object ret = executor.execute(handler);
+
+ assertNotNull(ret);
+ verify(handler, times(1)).handle(resultSet);
+ verify(conn, times(1)).close();
+ verify(stmt, times(1)).close();
+ }
+
+ @Test(expected=SQLException.class)
+ public void testUnmappedParams() throws Exception {
+ createExecutor("insert into blah (:something)");
+
+ Object ret = executor.execute(handler);
+
+ assertNotNull(ret);
+ verify(handler, times(1)).handle(resultSet);
+ verify(conn, times(1)).close();
+ verify(stmt, times(1)).close();
+ }
+
+ @Test(expected=SQLException.class)
+ public void testNullHandler() throws Exception {
+ createExecutor("insert into blah");
+
+ Object ret = executor.execute(null);
+
+ assertNotNull(ret);
+ verify(handler, times(1)).handle(resultSet);
+ verify(conn, times(1)).close();
+ verify(stmt, times(1)).close();
+ }
+}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/test/java/org/apache/commons/dbutils2/QueryLoaderTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils2/QueryLoaderTest.java b/src/test/java/org/apache/commons/dbutils2/QueryLoaderTest.java
new file mode 100644
index 0000000..ff09a2c
--- /dev/null
+++ b/src/test/java/org/apache/commons/dbutils2/QueryLoaderTest.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.dbutils2;
+
+import java.io.IOException;
+import java.util.Map;
+
+import org.apache.commons.dbutils2.QueryLoader;
+
+/**
+ * QueryLoaderTest
+ */
+public class QueryLoaderTest extends BaseTestCase {
+
+ private static final String QUERIES =
+ "/org/apache/commons/dbutils/TestQueries.properties";
+
+ public void testLoad() throws IOException {
+ try {
+ QueryLoader loader = QueryLoader.instance();
+ Map<String,String> q = loader.load(QUERIES);
+ Map<String,String> q2 = loader.load(QUERIES);
+ assertTrue(q == q2); // pointer comparison should return true
+ assertEquals("SELECT * FROM SomeTable", q.get("test.query"));
+
+ loader.unload(QUERIES);
+ Map<String,String> q3 = loader.load(QUERIES);
+ assertTrue(q != q3); // pointer comparison should return false
+
+ } catch (IllegalArgumentException e) {
+ // TODO Figure out why the Maven build can't find the properties
+ // file. The tests run fine in Eclipse so just catch this
+ // exception for now.
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/test/java/org/apache/commons/dbutils2/QueryRunnerTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils2/QueryRunnerTest.java b/src/test/java/org/apache/commons/dbutils2/QueryRunnerTest.java
new file mode 100644
index 0000000..9944972
--- /dev/null
+++ b/src/test/java/org/apache/commons/dbutils2/QueryRunnerTest.java
@@ -0,0 +1,161 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.dbutils2;
+
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import java.sql.Connection;
+import java.sql.SQLException;
+import javax.sql.DataSource;
+
+import org.apache.commons.dbutils2.QueryRunner;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+@SuppressWarnings("boxing") // test code
+public class QueryRunnerTest {
+ QueryRunner runner;
+
+ @Mock DataSource dataSource;
+ @Mock Connection conn;
+
+ @Before
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this); // init the mocks
+
+ when(dataSource.getConnection()).thenReturn(conn);
+ runner = new QueryRunner(dataSource);
+ }
+
+ // batch tests
+
+ @Test
+ public void testBatchSQL() throws SQLException {
+ assertNotNull(runner.batch("select * from blah where :first=first"));
+ verify(dataSource, times(1)).getConnection();
+ }
+
+ @Test
+ public void testBatchConnSQL() throws SQLException {
+ assertNotNull(runner.batch(conn, "select * from blah where :first=first"));
+ }
+
+ @Test
+ public void testBatchConnSQLBoolean() throws SQLException {
+ assertNotNull(runner.batch(conn, true, "select * from blah where :first=first"));
+ }
+
+ @Test(expected=SQLException.class)
+ public void testBatchNullConn() throws SQLException {
+ assertNotNull(runner.batch(null, true, "select"));
+ }
+
+ @Test(expected=SQLException.class)
+ public void testBatchNullSQL() throws SQLException {
+ assertNotNull(runner.batch(conn, true, null));
+ }
+
+ // query tests
+
+ @Test
+ public void testQuerySQL() throws SQLException {
+ assertNotNull(runner.query("select * from blah where :first=first"));
+ verify(dataSource, times(1)).getConnection();
+ }
+
+ @Test
+ public void testQueryConnSQL() throws SQLException {
+ assertNotNull(runner.query(conn, "select * from blah where :first=first"));
+ }
+
+ @Test
+ public void testQueryConnSQLBoolean() throws SQLException {
+ assertNotNull(runner.query(conn, true, "select * from blah where :first=first"));
+ }
+
+ @Test(expected=SQLException.class)
+ public void testQueryNullConn() throws SQLException {
+ assertNotNull(runner.query(null, true, "select"));
+ }
+
+ @Test(expected=SQLException.class)
+ public void testQueryNullSQL() throws SQLException {
+ assertNotNull(runner.query(conn, true, null));
+ }
+
+ // insert tests
+
+ @Test
+ public void testInsertSQL() throws SQLException {
+ assertNotNull(runner.insert("insert * from blah where :first=first"));
+ verify(dataSource, times(1)).getConnection();
+ }
+
+ @Test
+ public void testInsertConnSQL() throws SQLException {
+ assertNotNull(runner.insert(conn, "insert * from blah where :first=first"));
+ }
+
+ @Test
+ public void testInsertConnSQLBoolean() throws SQLException {
+ assertNotNull(runner.insert(conn, true, "insert * from blah where :first=first"));
+ }
+
+ @Test(expected=SQLException.class)
+ public void testInsertNullConn() throws SQLException {
+ assertNotNull(runner.insert(null, true, "select"));
+ }
+
+ @Test(expected=SQLException.class)
+ public void testInsertNullSQL() throws SQLException {
+ assertNotNull(runner.insert(conn, true, null));
+ }
+
+ // update tests
+
+ @Test
+ public void testUpdateSQL() throws SQLException {
+ assertNotNull(runner.update("select * from blah where :first=first"));
+ verify(dataSource, times(1)).getConnection();
+ }
+
+ @Test
+ public void testUpdateConnSQL() throws SQLException {
+ assertNotNull(runner.update(conn, "select * from blah where :first=first"));
+ }
+
+ @Test
+ public void testUpdateConnSQLBoolean() throws SQLException {
+ assertNotNull(runner.update(conn, true, "select * from blah where :first=first"));
+ }
+
+ @Test(expected=SQLException.class)
+ public void testUpdateNullConn() throws SQLException {
+ assertNotNull(runner.update(null, true, "select"));
+ }
+
+ @Test(expected=SQLException.class)
+ public void testUpdateNullSQL() throws SQLException {
+ assertNotNull(runner.update(conn, true, null));
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/test/java/org/apache/commons/dbutils2/ResultSetIteratorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils2/ResultSetIteratorTest.java b/src/test/java/org/apache/commons/dbutils2/ResultSetIteratorTest.java
new file mode 100644
index 0000000..89070a9
--- /dev/null
+++ b/src/test/java/org/apache/commons/dbutils2/ResultSetIteratorTest.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.dbutils2;
+
+import java.util.Iterator;
+
+import org.apache.commons.dbutils2.ResultSetIterator;
+
+/**
+ * ResultSetIteratorTest
+ */
+public class ResultSetIteratorTest extends BaseTestCase {
+
+ public void testNext() {
+
+ Iterator<Object[]> iter = new ResultSetIterator(this.rs);
+
+ Object[] row = null;
+ assertTrue(iter.hasNext());
+ row = iter.next();
+ assertEquals(COLS, row.length);
+ assertEquals("1", row[0]);
+ assertEquals("2", row[1]);
+ assertEquals("3", row[2]);
+
+ assertTrue(iter.hasNext());
+ row = iter.next();
+ assertEquals(COLS, row.length);
+
+ assertEquals("4", row[0]);
+ assertEquals("5", row[1]);
+ assertEquals("6", row[2]);
+
+ assertFalse(iter.hasNext());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/test/java/org/apache/commons/dbutils2/TestBean.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils2/TestBean.java b/src/test/java/org/apache/commons/dbutils2/TestBean.java
new file mode 100644
index 0000000..fc3f8e6
--- /dev/null
+++ b/src/test/java/org/apache/commons/dbutils2/TestBean.java
@@ -0,0 +1,148 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.dbutils2;
+
+/**
+ * A bean to use in testing toBean() and toBeanList().
+ */
+public class TestBean {
+
+ private String one = null;
+
+ private String two = null;
+
+ private String three = null;
+
+ private int intTest = 0;
+
+ private Integer integerTest = Integer.valueOf(0);
+
+ private String doNotSet = "not set";
+
+ /**
+ * toBean() should set primitive fields to their defaults (ie. 0) when
+ * null is returned from the ResultSet.
+ */
+ private int nullPrimitiveTest = 7;
+
+ /**
+ * toBean() should set Object fields to null when null is returned from the
+ * ResultSet
+ */
+ private Object nullObjectTest = "overwrite";
+
+ /**
+ * A Date will be returned from the ResultSet but the property is a String.
+ * BeanProcessor should create a String from the Date and set this property.
+ */
+ private String notDate = "not a date";
+
+ /**
+ * The ResultSet will have a BigDecimal in this column and the
+ * BasicColumnProcessor should convert that to a double and store the value
+ * in this property.
+ */
+ private double columnProcessorDoubleTest = -1;
+
+ /**
+ * Constructor for TestBean.
+ */
+ public TestBean() {
+ super();
+ }
+
+ public String getOne() {
+ return one;
+ }
+
+ public String getThree() {
+ return three;
+ }
+
+ public String getTwo() {
+ return two;
+ }
+
+ public void setOne(String string) {
+ one = string;
+ }
+
+ public void setThree(String string) {
+ three = string;
+ }
+
+ public void setTwo(String string) {
+ two = string;
+ }
+
+ public String getDoNotSet() {
+ return doNotSet;
+ }
+
+ public void setDoNotSet(String string) {
+ doNotSet = string;
+ }
+
+ public Integer getIntegerTest() {
+ return integerTest;
+ }
+
+ public int getIntTest() {
+ return intTest;
+ }
+
+ public void setIntegerTest(Integer integer) {
+ integerTest = integer;
+ }
+
+ public void setIntTest(int i) {
+ intTest = i;
+ }
+
+ public Object getNullObjectTest() {
+ return nullObjectTest;
+ }
+
+ public int getNullPrimitiveTest() {
+ return nullPrimitiveTest;
+ }
+
+ public void setNullObjectTest(Object object) {
+ nullObjectTest = object;
+ }
+
+ public void setNullPrimitiveTest(int i) {
+ nullPrimitiveTest = i;
+ }
+
+ public String getNotDate() {
+ return notDate;
+ }
+
+ public void setNotDate(String string) {
+ notDate = string;
+ }
+
+ public double getColumnProcessorDoubleTest() {
+ return columnProcessorDoubleTest;
+ }
+
+ public void setColumnProcessorDoubleTest(double d) {
+ columnProcessorDoubleTest = d;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/test/java/org/apache/commons/dbutils2/UpdateExecutorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils2/UpdateExecutorTest.java b/src/test/java/org/apache/commons/dbutils2/UpdateExecutorTest.java
new file mode 100644
index 0000000..462fa4d
--- /dev/null
+++ b/src/test/java/org/apache/commons/dbutils2/UpdateExecutorTest.java
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.dbutils2;
+
+import static org.junit.Assert.*;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+
+import org.apache.commons.dbutils2.UpdateExecutor;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+
+public class UpdateExecutorTest {
+
+ private UpdateExecutor executor;
+
+ @Mock private Connection conn;
+ @Mock private PreparedStatement stmt;
+
+ @Before
+ public void setup() throws SQLException {
+ MockitoAnnotations.initMocks(this);
+
+ when(conn.prepareStatement(any(String.class))).thenReturn(stmt);
+ when(stmt.executeUpdate()).thenReturn(20);
+ }
+
+ protected void createExecutor(String sql) throws Exception {
+ executor = new UpdateExecutor(conn, sql, true);
+ }
+
+ @Test
+ public void testGoodSQL() throws Exception {
+ createExecutor("insert into blah");
+
+ int ret = executor.execute();
+
+ assertEquals(20, ret);
+ verify(conn, times(1)).close();
+ verify(stmt, times(1)).close();
+ }
+
+ @Test(expected=SQLException.class)
+ public void testUnmappedParams() throws Exception {
+ createExecutor("insert into blah (:something)");
+
+ int ret = executor.execute();
+
+ assertEquals(20, ret);
+ verify(conn, times(1)).close();
+ verify(stmt, times(1)).close();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/test/java/org/apache/commons/dbutils2/handlers/ArrayHandlerTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils2/handlers/ArrayHandlerTest.java b/src/test/java/org/apache/commons/dbutils2/handlers/ArrayHandlerTest.java
new file mode 100644
index 0000000..b893b89
--- /dev/null
+++ b/src/test/java/org/apache/commons/dbutils2/handlers/ArrayHandlerTest.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.dbutils2.handlers;
+
+import java.sql.SQLException;
+
+import org.apache.commons.dbutils2.BaseTestCase;
+import org.apache.commons.dbutils2.ResultSetHandler;
+import org.apache.commons.dbutils2.handlers.ArrayHandler;
+
+/**
+ * ArrayHandlerTest
+ */
+public class ArrayHandlerTest extends BaseTestCase {
+
+ public void testHandle() throws SQLException {
+ ResultSetHandler<Object[]> h = new ArrayHandler();
+ Object[] results = h.handle(this.rs);
+
+ assertNotNull(results);
+ assertEquals(COLS, results.length);
+ assertEquals("1", results[0]);
+ assertEquals("2", results[1]);
+ assertEquals("3", results[2]);
+ }
+
+ public void testEmptyResultSetHandle() throws SQLException {
+ ResultSetHandler<Object[]> h = new ArrayHandler();
+ Object[] results = h.handle(this.emptyResultSet);
+
+ assertNull(results);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/test/java/org/apache/commons/dbutils2/handlers/ArrayListHandlerTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils2/handlers/ArrayListHandlerTest.java b/src/test/java/org/apache/commons/dbutils2/handlers/ArrayListHandlerTest.java
new file mode 100644
index 0000000..e252acd
--- /dev/null
+++ b/src/test/java/org/apache/commons/dbutils2/handlers/ArrayListHandlerTest.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.dbutils2.handlers;
+
+import java.sql.SQLException;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.commons.dbutils2.BaseTestCase;
+import org.apache.commons.dbutils2.ResultSetHandler;
+import org.apache.commons.dbutils2.handlers.ArrayListHandler;
+
+/**
+ * ArrayListHandlerTest
+ */
+public class ArrayListHandlerTest extends BaseTestCase {
+
+ public void testHandle() throws SQLException {
+ ResultSetHandler<List<Object[]>> h = new ArrayListHandler();
+ List<Object[]> results = h.handle(this.rs);
+
+ assertNotNull(results);
+ assertEquals(ROWS, results.size());
+
+ Iterator<Object[]> iter = results.iterator();
+ Object[] row = null;
+ assertTrue(iter.hasNext());
+ row = iter.next();
+ assertEquals(COLS, row.length);
+ assertEquals("1", row[0]);
+ assertEquals("2", row[1]);
+ assertEquals("3", row[2]);
+
+ assertTrue(iter.hasNext());
+ row = iter.next();
+ assertEquals(COLS, row.length);
+
+ assertEquals("4", row[0]);
+ assertEquals("5", row[1]);
+ assertEquals("6", row[2]);
+
+ assertFalse(iter.hasNext());
+ }
+
+ public void testEmptyResultSetHandle() throws SQLException {
+ ResultSetHandler<List<Object[]>> h = new ArrayListHandler();
+ List<Object[]> results = h.handle(this.emptyResultSet);
+
+ assertNotNull(results);
+ assertTrue(results.isEmpty());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/test/java/org/apache/commons/dbutils2/handlers/BeanHandlerTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils2/handlers/BeanHandlerTest.java b/src/test/java/org/apache/commons/dbutils2/handlers/BeanHandlerTest.java
new file mode 100644
index 0000000..feaab77
--- /dev/null
+++ b/src/test/java/org/apache/commons/dbutils2/handlers/BeanHandlerTest.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.dbutils2.handlers;
+
+import java.sql.SQLException;
+
+import org.apache.commons.dbutils2.BaseTestCase;
+import org.apache.commons.dbutils2.ResultSetHandler;
+import org.apache.commons.dbutils2.TestBean;
+import org.apache.commons.dbutils2.handlers.BeanHandler;
+
+/**
+ * BeanHandlerTest
+ */
+public class BeanHandlerTest extends BaseTestCase {
+
+ public void testHandle() throws SQLException {
+ ResultSetHandler<TestBean> h = new BeanHandler<TestBean>(TestBean.class);
+ TestBean results = h.handle(this.rs);
+
+ assertNotNull(results);
+ assertEquals("1", results.getOne());
+ assertEquals("2", results.getTwo());
+ assertEquals("3", results.getThree());
+ assertEquals("not set", results.getDoNotSet());
+ }
+
+ public void testEmptyResultSetHandle() throws SQLException {
+ ResultSetHandler<TestBean> h = new BeanHandler<TestBean>(TestBean.class);
+ TestBean results = h.handle(this.emptyResultSet);
+
+ assertNull(results);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/test/java/org/apache/commons/dbutils2/handlers/BeanListHandlerTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils2/handlers/BeanListHandlerTest.java b/src/test/java/org/apache/commons/dbutils2/handlers/BeanListHandlerTest.java
new file mode 100644
index 0000000..1c12b1d
--- /dev/null
+++ b/src/test/java/org/apache/commons/dbutils2/handlers/BeanListHandlerTest.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.dbutils2.handlers;
+
+import java.sql.SQLException;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.commons.dbutils2.BaseTestCase;
+import org.apache.commons.dbutils2.ResultSetHandler;
+import org.apache.commons.dbutils2.TestBean;
+import org.apache.commons.dbutils2.handlers.BeanListHandler;
+
+/**
+ * BeanListHandlerTest
+ */
+public class BeanListHandlerTest extends BaseTestCase {
+
+ public void testHandle() throws SQLException {
+ ResultSetHandler<List<TestBean>> h = new BeanListHandler<TestBean>(TestBean.class);
+ List<TestBean> results = h.handle(this.rs);
+
+ assertNotNull(results);
+ assertEquals(ROWS, results.size());
+
+ Iterator<TestBean> iter = results.iterator();
+ TestBean row = null;
+ assertTrue(iter.hasNext());
+ row = iter.next();
+ assertEquals("1", row.getOne());
+ assertEquals("2", row.getTwo());
+ assertEquals("3", row.getThree());
+ assertEquals("not set", row.getDoNotSet());
+
+ assertTrue(iter.hasNext());
+ row = iter.next();
+
+ assertEquals("4", row.getOne());
+ assertEquals("5", row.getTwo());
+ assertEquals("6", row.getThree());
+ assertEquals("not set", row.getDoNotSet());
+
+ assertFalse(iter.hasNext());
+ }
+
+ public void testEmptyResultSetHandle() throws SQLException {
+ ResultSetHandler<List<TestBean>> h = new BeanListHandler<TestBean>(TestBean.class);
+ List<TestBean> results = h.handle(this.emptyResultSet);
+
+ assertNotNull(results);
+ assertTrue(results.isEmpty());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/test/java/org/apache/commons/dbutils2/handlers/BeanMapHandlerTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils2/handlers/BeanMapHandlerTest.java b/src/test/java/org/apache/commons/dbutils2/handlers/BeanMapHandlerTest.java
new file mode 100644
index 0000000..c14951c
--- /dev/null
+++ b/src/test/java/org/apache/commons/dbutils2/handlers/BeanMapHandlerTest.java
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.dbutils2.handlers;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.when;
+
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.util.Map;
+
+import org.apache.commons.dbutils2.RowProcessor;
+import org.apache.commons.dbutils2.TestBean;
+import org.apache.commons.dbutils2.handlers.BeanMapHandler;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+public class BeanMapHandlerTest {
+
+ private BeanMapHandler<Long, TestBean> bmh;
+ private Map<Long, TestBean> res;
+ @Mock private ResultSet rs;
+ @Mock private ResultSetMetaData rsmd;
+ @Mock private RowProcessor rp;
+
+ @Before
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+
+ when(Boolean.valueOf(rs.next())).thenReturn(Boolean.TRUE, Boolean.FALSE);
+ when(rs.getObject(1)).thenReturn(Long.valueOf(23L));
+ when(rs.getObject(2)).thenReturn(Long.valueOf(23L));
+ when(rs.getObject("id")).thenReturn(Long.valueOf(23L));
+ when(rs.getMetaData()).thenReturn(rsmd);
+ when(rp.toBean(rs, TestBean.class)).thenReturn(new TestBean());
+ }
+
+ private void handle() throws Exception {
+ res = bmh.handle(rs);
+ assertNotNull(res.get(Long.valueOf(23L)));
+ }
+
+ @Test
+ public void testBeanMapHandlerClassOfV() throws Exception {
+ bmh = new BeanMapHandler<Long, TestBean>(TestBean.class);
+ handle();
+ }
+
+ @Test
+ public void testBeanMapHandlerClassOfVRowProcessor() throws Exception {
+ bmh = new BeanMapHandler<Long, TestBean>(TestBean.class, rp);
+ handle();
+ }
+
+ @Test
+ public void testBeanMapHandlerClassOfVInt() throws Exception {
+ bmh = new BeanMapHandler<Long, TestBean>(TestBean.class, 2);
+ handle();
+ }
+
+ @Test
+ public void testBeanMapHandlerClassOfVString() throws Exception {
+ bmh = new BeanMapHandler<Long, TestBean>(TestBean.class, "id");
+ handle();
+ }
+
+ @Test
+ public void testEmptyResultSet() throws Exception {
+ when(Boolean.valueOf(rs.next())).thenReturn(Boolean.FALSE);
+ bmh = new BeanMapHandler<Long, TestBean>(TestBean.class);
+ res = bmh.handle(rs);
+ assertNull(res.get(Long.valueOf(23L)));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/test/java/org/apache/commons/dbutils2/handlers/ColumnListHandlerTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils2/handlers/ColumnListHandlerTest.java b/src/test/java/org/apache/commons/dbutils2/handlers/ColumnListHandlerTest.java
new file mode 100644
index 0000000..4686e53
--- /dev/null
+++ b/src/test/java/org/apache/commons/dbutils2/handlers/ColumnListHandlerTest.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.dbutils2.handlers;
+
+import java.sql.SQLException;
+import java.util.List;
+
+import org.apache.commons.dbutils2.BaseTestCase;
+import org.apache.commons.dbutils2.ResultSetHandler;
+import org.apache.commons.dbutils2.handlers.ColumnListHandler;
+
+/**
+ * ColumnListHandlerTest
+ */
+public class ColumnListHandlerTest extends BaseTestCase {
+
+ public void testHandle() throws SQLException {
+ ResultSetHandler<List<String>> h = new ColumnListHandler<String>();
+ List<String> results = h.handle(this.rs);
+
+ assertNotNull(results);
+ assertEquals(ROWS, results.size());
+
+ assertEquals("1", results.get(0));
+ assertEquals("4", results.get(1));
+ }
+
+ public void testColumnIndexHandle() throws SQLException {
+ ResultSetHandler<List<String>> h = new ColumnListHandler<String>(2);
+ List<String> results = h.handle(this.rs);
+
+ assertNotNull(results);
+ assertEquals(ROWS, results.size());
+
+ assertEquals("2", results.get(0));
+ assertEquals("5", results.get(1));
+ }
+
+ public void testColumnNameHandle() throws SQLException {
+ ResultSetHandler<List<Integer>> h = new ColumnListHandler<Integer>("intTest");
+ List<Integer> results = h.handle(this.rs);
+
+ assertNotNull(results);
+ assertEquals(ROWS, results.size());
+
+ assertEquals(new Integer(1), results.get(0));
+ assertEquals(new Integer(3), results.get(1));
+ }
+
+ public void testEmptyResultSetHandle() throws SQLException {
+ ResultSetHandler<List<String>> h = new ColumnListHandler<String>();
+ List<String> results = h.handle(this.emptyResultSet);
+
+ assertNotNull(results);
+ assertTrue(results.isEmpty());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/test/java/org/apache/commons/dbutils2/handlers/KeyedHandlerTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils2/handlers/KeyedHandlerTest.java b/src/test/java/org/apache/commons/dbutils2/handlers/KeyedHandlerTest.java
new file mode 100644
index 0000000..f0cedc0
--- /dev/null
+++ b/src/test/java/org/apache/commons/dbutils2/handlers/KeyedHandlerTest.java
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.dbutils2.handlers;
+
+import java.sql.SQLException;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.apache.commons.dbutils2.BaseTestCase;
+import org.apache.commons.dbutils2.ResultSetHandler;
+import org.apache.commons.dbutils2.handlers.KeyedHandler;
+
+public class KeyedHandlerTest extends BaseTestCase {
+
+ public void testHandle() throws SQLException {
+ ResultSetHandler<Map<String,Map<String,Object>>> h = new KeyedHandler<String>();
+
+ Map<String,Map<String,Object>> results = h.handle(this.rs);
+
+ assertNotNull(results);
+ assertEquals(ROWS, results.size());
+
+ Map<String,Object> row = null;
+ for(Entry<String, Map<String, Object>> entry : results.entrySet())
+ {
+ Object key = entry.getKey();
+ assertNotNull(key);
+ row = entry.getValue();
+ assertNotNull(row);
+ assertEquals(COLS, row.keySet().size());
+ }
+ row = results.get("1");
+ assertEquals("1", row.get("one"));
+ assertEquals("2", row.get("TWO"));
+ assertEquals("3", row.get("Three"));
+ }
+
+ public void testColumnIndexHandle() throws SQLException {
+ ResultSetHandler<Map<String,Map<String,Object>>> h = new KeyedHandler<String>(2);
+ Map<String,Map<String,Object>> results = h.handle(this.rs);
+
+ assertNotNull(results);
+ assertEquals(ROWS, results.size());
+
+ Map<String,Object> row = null;
+ for(Entry<String, Map<String, Object>> entry : results.entrySet())
+ {
+ Object key = entry.getKey();
+ assertNotNull(key);
+ row = entry.getValue();
+ assertNotNull(row);
+ assertEquals(COLS, row.keySet().size());
+ }
+ row = results.get("5");
+ assertEquals("4", row.get("one"));
+ assertEquals("5", row.get("TWO"));
+ assertEquals("6", row.get("Three"));
+ }
+
+ public void testColumnNameHandle() throws SQLException {
+ ResultSetHandler<Map<Integer,Map<String,Object>>> h = new KeyedHandler<Integer>("intTest");
+ Map<Integer,Map<String,Object>> results = h.handle(this.rs);
+
+ assertNotNull(results);
+ assertEquals(ROWS, results.size());
+
+ Map<String,Object> row = null;
+ for(Entry<Integer, Map<String, Object>> entry : results.entrySet())
+ {
+ Object key = entry.getKey();
+ assertNotNull(key);
+ row = entry.getValue();
+ assertNotNull(row);
+ assertEquals(COLS, row.keySet().size());
+ }
+ row = results.get(Integer.valueOf(3));
+ assertEquals("4", row.get("one"));
+ assertEquals("5", row.get("TWO"));
+ assertEquals("6", row.get("Three"));
+ }
+
+ public void testEmptyResultSetHandle() throws SQLException {
+ ResultSetHandler<Map<String,Map<String,Object>>> h = new KeyedHandler<String>();
+ Map<String,Map<String,Object>> results = h.handle(this.emptyResultSet);
+ assertNotNull(results);
+ assertTrue(results.isEmpty());
+ }
+}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/test/java/org/apache/commons/dbutils2/handlers/MapHandlerTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils2/handlers/MapHandlerTest.java b/src/test/java/org/apache/commons/dbutils2/handlers/MapHandlerTest.java
new file mode 100644
index 0000000..d8dbf33
--- /dev/null
+++ b/src/test/java/org/apache/commons/dbutils2/handlers/MapHandlerTest.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.dbutils2.handlers;
+
+import java.sql.SQLException;
+import java.util.Map;
+
+import org.apache.commons.dbutils2.BaseTestCase;
+import org.apache.commons.dbutils2.ResultSetHandler;
+import org.apache.commons.dbutils2.handlers.MapHandler;
+
+/**
+ * MapHandlerTest
+ */
+public class MapHandlerTest extends BaseTestCase {
+
+ public void testHandle() throws SQLException {
+ ResultSetHandler<Map<String,Object>> h = new MapHandler();
+ Map<String,Object> results = h.handle(this.rs);
+
+ assertNotNull(results);
+ assertEquals(COLS, results.keySet().size());
+ assertEquals("1", results.get("ONE"));
+ assertEquals("2", results.get("two"));
+ assertEquals("3", results.get("Three"));
+ }
+
+ public void testEmptyResultSetHandle() throws SQLException {
+ ResultSetHandler<Map<String,Object>> h = new MapHandler();
+ Map<String,Object> results = h.handle(this.emptyResultSet);
+
+ assertNull(results);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/test/java/org/apache/commons/dbutils2/handlers/MapListHandlerTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils2/handlers/MapListHandlerTest.java b/src/test/java/org/apache/commons/dbutils2/handlers/MapListHandlerTest.java
new file mode 100644
index 0000000..d14a7c3
--- /dev/null
+++ b/src/test/java/org/apache/commons/dbutils2/handlers/MapListHandlerTest.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.dbutils2.handlers;
+
+import java.sql.SQLException;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.dbutils2.BaseTestCase;
+import org.apache.commons.dbutils2.ResultSetHandler;
+import org.apache.commons.dbutils2.handlers.MapListHandler;
+
+/**
+ * MapListHandlerTest
+ */
+public class MapListHandlerTest extends BaseTestCase {
+
+ public void testHandle() throws SQLException {
+ ResultSetHandler<List<Map<String,Object>>> h = new MapListHandler();
+ List<Map<String,Object>> results = h.handle(this.rs);
+
+ assertNotNull(results);
+ assertEquals(ROWS, results.size());
+
+ Iterator<Map<String,Object>> iter = results.iterator();
+ Map<String,Object> row = null;
+ assertTrue(iter.hasNext());
+ row = iter.next();
+ assertEquals(COLS, row.keySet().size());
+ assertEquals("1", row.get("one"));
+ assertEquals("2", row.get("TWO"));
+ assertEquals("3", row.get("Three"));
+
+ assertTrue(iter.hasNext());
+ row = iter.next();
+ assertEquals(COLS, row.keySet().size());
+
+ assertEquals("4", row.get("one"));
+ assertEquals("5", row.get("TWO"));
+ assertEquals("6", row.get("Three"));
+
+ assertFalse(iter.hasNext());
+ }
+
+ public void testEmptyResultSetHandle() throws SQLException {
+ ResultSetHandler<List<Map<String,Object>>> h = new MapListHandler();
+ List<Map<String,Object>> results = h.handle(this.emptyResultSet);
+
+ assertNotNull(results);
+ assertTrue(results.isEmpty());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/test/java/org/apache/commons/dbutils2/handlers/ScalarHandlerTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils2/handlers/ScalarHandlerTest.java b/src/test/java/org/apache/commons/dbutils2/handlers/ScalarHandlerTest.java
new file mode 100644
index 0000000..f44592f
--- /dev/null
+++ b/src/test/java/org/apache/commons/dbutils2/handlers/ScalarHandlerTest.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.dbutils2.handlers;
+
+import java.sql.SQLException;
+
+import org.apache.commons.dbutils2.BaseTestCase;
+import org.apache.commons.dbutils2.ResultSetHandler;
+import org.apache.commons.dbutils2.handlers.ScalarHandler;
+
+public class ScalarHandlerTest extends BaseTestCase {
+
+ public void testHandle() throws SQLException {
+ ResultSetHandler<String> h = new ScalarHandler<String>();
+ Object results = h.handle(this.rs);
+ assertNotNull(results);
+ assertEquals("1", results);
+ }
+
+ public void testColumnIndexHandle() throws SQLException {
+ ResultSetHandler<String> h = new ScalarHandler<String>(2);
+ Object results = h.handle(this.rs);
+ assertNotNull(results);
+ assertEquals("2", results);
+ }
+
+ public void testColumnNameHandle() throws SQLException {
+ ResultSetHandler<Integer> h = new ScalarHandler<Integer>("intTest");
+ Object results = h.handle(this.rs);
+ assertNotNull(results);
+ assertEquals(Integer.valueOf(1), results);
+ }
+
+ public void testEmptyResultSetHandle() throws SQLException {
+ ResultSetHandler<String> h = new ScalarHandler<String>();
+ Object results = h.handle(this.emptyResultSet);
+ assertNull(results);
+ }
+
+}
[13/58] [abbrv] commons-dbutils git commit: - Fixed a few FindBug
issues in SqlNullCheckResultSet - Updated parent pom version - Added JavaDocs
to BaseResultSetHandler
Posted by th...@apache.org.
- Fixed a few FindBug issues in SqlNullCheckResultSet
- Updated parent pom version
- Added JavaDocs to BaseResultSetHandler
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/dbutils/branches/2_0@1457532 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/commons-dbutils/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-dbutils/commit/9319b07b
Tree: http://git-wip-us.apache.org/repos/asf/commons-dbutils/tree/9319b07b
Diff: http://git-wip-us.apache.org/repos/asf/commons-dbutils/diff/9319b07b
Branch: refs/heads/2_0
Commit: 9319b07ba23284e5821092e7d9af57bb6a8ae9fd
Parents: 3535b10
Author: Bill Speirs <ws...@apache.org>
Authored: Sun Mar 17 19:33:58 2013 +0000
Committer: Bill Speirs <ws...@apache.org>
Committed: Sun Mar 17 19:33:58 2013 +0000
----------------------------------------------------------------------
pom.xml | 4 +-
.../commons/dbutils2/BaseResultSetHandler.java | 559 +++++++++----------
.../wrappers/SqlNullCheckedResultSet.java | 4 +-
3 files changed, 283 insertions(+), 284 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/9319b07b/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index ac487de..096f6a0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -19,10 +19,10 @@
<parent>
<groupId>org.apache.commons</groupId>
<artifactId>commons-parent</artifactId>
- <version>26</version>
+ <version>28</version>
</parent>
<modelVersion>4.0.0</modelVersion>
- <groupId>commons-dbutils</groupId>
+ <groupId>org.apache.commons</groupId>
<artifactId>commons-dbutils</artifactId>
<version>2.0-SNAPSHOT</version>
<name>Commons DbUtils</name>
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/9319b07b/src/main/java/org/apache/commons/dbutils2/BaseResultSetHandler.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/BaseResultSetHandler.java b/src/main/java/org/apache/commons/dbutils2/BaseResultSetHandler.java
index ef29b32..1c32b40 100644
--- a/src/main/java/org/apache/commons/dbutils2/BaseResultSetHandler.java
+++ b/src/main/java/org/apache/commons/dbutils2/BaseResultSetHandler.java
@@ -173,8 +173,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnLabel
- * @return
+ * @param columnLabel the name of the column.
+ * @return an array of values from the ResultSet.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getArray(java.lang.String)
*/
@@ -183,8 +183,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnIndex
- * @return
+ * @param columnIndex the index of the column.
+ * @return the InputStream.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getAsciiStream(int)
*/
@@ -193,8 +193,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnLabel
- * @return
+ * @param columnLabel the column's label.
+ * @return the InputStream.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getAsciiStream(java.lang.String)
*/
@@ -203,8 +203,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnIndex
- * @return
+ * @param columnIndex the index of the column.
+ * @return the BigDecimal.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getBigDecimal(int)
*/
@@ -213,8 +213,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnLabel
- * @return
+ * @param columnLabel the column's label.
+ * @return the BigDecimal.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getBigDecimal(java.lang.String)
*/
@@ -223,8 +223,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnIndex
- * @return
+ * @param columnIndex the index of the column.
+ * @return the InputStream.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getBinaryStream(int)
*/
@@ -233,8 +233,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnLabel
- * @return
+ * @param columnLabel the column's label.
+ * @return the InputStream.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getBinaryStream(java.lang.String)
*/
@@ -243,8 +243,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnIndex
- * @return
+ * @param columnIndex the index of the column.
+ * @return the Blob.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getBlob(int)
*/
@@ -253,8 +253,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnLabel
- * @return
+ * @param columnLabel the column's label.
+ * @return the Blob.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getBlob(java.lang.String)
*/
@@ -263,8 +263,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnIndex
- * @return
+ * @param columnIndex the index of the column.
+ * @return the boolean.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getBoolean(int)
*/
@@ -273,8 +273,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnLabel
- * @return
+ * @param columnLabel the column's label.
+ * @return the boolean.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getBoolean(java.lang.String)
*/
@@ -283,8 +283,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnIndex
- * @return
+ * @param columnIndex the index of the column.
+ * @return the byte.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getByte(int)
*/
@@ -293,8 +293,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnLabel
- * @return
+ * @param columnLabel the column's label.
+ * @return the byte.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getByte(java.lang.String)
*/
@@ -303,8 +303,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnIndex
- * @return
+ * @param columnIndex the index of the column.
+ * @return the byte array.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getBytes(int)
*/
@@ -313,8 +313,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnLabel
- * @return
+ * @param columnLabel the column's label.
+ * @return the byte array.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getBytes(java.lang.String)
*/
@@ -323,7 +323,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnIndex
+ * @param columnIndex the index of the column.
* @return
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getCharacterStream(int)
@@ -333,8 +333,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnLabel
- * @return
+ * @param columnLabel the column's label.
+ * @return the Reader.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getCharacterStream(java.lang.String)
*/
@@ -343,8 +343,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnIndex
- * @return
+ * @param columnIndex the index of the column.
+ * @return the Clob.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getClob(int)
*/
@@ -353,8 +353,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnLabel
- * @return
+ * @param columnLabel the column's label.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getClob(java.lang.String)
*/
@@ -363,7 +362,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @return
+ * @return the concurrency.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getConcurrency()
*/
@@ -372,7 +371,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @return
+ * @return the cursor name.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getCursorName()
*/
@@ -381,8 +380,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnIndex
- * @param cal
+ * @param columnIndex the index of the column.
+ * @param cal the Calendar.
* @return
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getDate(int, java.util.Calendar)
@@ -392,8 +391,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnIndex
- * @return
+ * @param columnIndex the index of the column.
+ * @return the date.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getDate(int)
*/
@@ -402,9 +401,9 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnLabel
- * @param cal
- * @return
+ * @param columnLabel the column's label.
+ * @param cal the Calendar.
+ * @return the date.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getDate(java.lang.String, java.util.Calendar)
*/
@@ -413,8 +412,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnLabel
- * @return
+ * @param columnLabel the column's label.
+ * @return the date.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getDate(java.lang.String)
*/
@@ -423,8 +422,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnIndex
- * @return
+ * @param columnIndex the index of the column.
+ * @return the Double.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getDouble(int)
*/
@@ -433,8 +432,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnLabel
- * @return
+ * @param columnLabel the column's label.
+ * @return the Double.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getDouble(java.lang.String)
*/
@@ -443,7 +442,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @return
+ * @return the fetch direction.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getFetchDirection()
*/
@@ -452,7 +451,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @return
+ * @return the fetch size.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getFetchSize()
*/
@@ -461,8 +460,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnIndex
- * @return
+ * @param columnIndex the index of the column.
+ * @return the float.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getFloat(int)
*/
@@ -471,8 +470,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnLabel
- * @return
+ * @param columnLabel the column's label.
+ * @return the float.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getFloat(java.lang.String)
*/
@@ -481,7 +480,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @return
+ * @return the holdability.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getHoldability()
*/
@@ -490,8 +489,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnIndex
- * @return
+ * @param columnIndex the index of the column.
+ * @return the int.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getInt(int)
*/
@@ -500,8 +499,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnLabel
- * @return
+ * @param columnLabel the column's label.
+ * @return the int.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getInt(java.lang.String)
*/
@@ -510,8 +509,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnIndex
- * @return
+ * @param columnIndex the index of the column.
+ * @return the long.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getLong(int)
*/
@@ -520,8 +519,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnLabel
- * @return
+ * @param columnLabel the column's label.
+ * @return the long.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getLong(java.lang.String)
*/
@@ -530,7 +529,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @return
+ * @return the ResultSetMetaData.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getMetaData()
*/
@@ -539,8 +538,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnIndex
- * @return
+ * @param columnIndex the index of the column.
+ * @return the N character stream.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getNCharacterStream(int)
*/
@@ -549,8 +548,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnLabel
- * @return
+ * @param columnLabel the column's label.
+ * @return the N character stream.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getNCharacterStream(java.lang.String)
*/
@@ -559,8 +558,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnIndex
- * @return
+ * @param columnIndex the index of the column.
+ * @return the N Clob.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getNClob(int)
*/
@@ -569,8 +568,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnLabel
- * @return
+ * @param columnLabel the column's label.
+ * @return the N Clob.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getNClob(java.lang.String)
*/
@@ -579,8 +578,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnIndex
- * @return
+ * @param columnIndex the index of the column.
+ * @return the N String.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getNString(int)
*/
@@ -589,8 +588,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnLabel
- * @return
+ * @param columnLabel the column's label.
+ * @return the N String.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getNString(java.lang.String)
*/
@@ -599,7 +598,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnIndex
+ * @param columnIndex the index of the column.
* @param map
* @return
* @throws SQLException thrown if there is an SQL error.
@@ -610,7 +609,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnIndex
+ * @param columnIndex the index of the column.
* @return
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getObject(int)
@@ -620,7 +619,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnLabel
+ * @param columnLabel the column's label.
* @param map
* @return
* @throws SQLException thrown if there is an SQL error.
@@ -631,7 +630,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnLabel
+ * @param columnLabel the column's label.
* @return
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getObject(java.lang.String)
@@ -641,7 +640,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnIndex
+ * @param columnIndex the index of the column.
* @return
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getRef(int)
@@ -651,7 +650,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnLabel
+ * @param columnLabel the column's label.
* @return
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getRef(java.lang.String)
@@ -670,7 +669,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnIndex
+ * @param columnIndex the index of the column.
* @return
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getRowId(int)
@@ -680,7 +679,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnLabel
+ * @param columnLabel the column's label.
* @return
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getRowId(java.lang.String)
@@ -690,7 +689,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnIndex
+ * @param columnIndex the index of the column.
* @return
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getSQLXML(int)
@@ -700,7 +699,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnLabel
+ * @param columnLabel the column's label.
* @return
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getSQLXML(java.lang.String)
@@ -710,7 +709,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnIndex
+ * @param columnIndex the index of the column.
* @return
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getShort(int)
@@ -720,7 +719,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnLabel
+ * @param columnLabel the column's label.
* @return
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getShort(java.lang.String)
@@ -739,7 +738,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnIndex
+ * @param columnIndex the index of the column.
* @return
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getString(int)
@@ -749,7 +748,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnLabel
+ * @param columnLabel the column's label.
* @return
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getString(java.lang.String)
@@ -759,8 +758,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnIndex
- * @param cal
+ * @param columnIndex the index of the column.
+ * @param cal the Calendar.
* @return
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getTime(int, java.util.Calendar)
@@ -770,7 +769,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnIndex
+ * @param columnIndex the index of the column.
* @return
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getTime(int)
@@ -780,8 +779,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnLabel
- * @param cal
+ * @param columnLabel the column's label.
+ * @param cal the Calendar.
* @return
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getTime(java.lang.String, java.util.Calendar)
@@ -791,7 +790,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnLabel
+ * @param columnLabel the column's label.
* @return
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getTime(java.lang.String)
@@ -801,8 +800,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnIndex
- * @param cal
+ * @param columnIndex the index of the column.
+ * @param cal the Calendar.
* @return
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getTimestamp(int, java.util.Calendar)
@@ -812,7 +811,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnIndex
+ * @param columnIndex the index of the column.
* @return
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getTimestamp(int)
@@ -822,8 +821,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnLabel
- * @param cal
+ * @param columnLabel the column's label.
+ * @param cal the Calendar.
* @return
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getTimestamp(java.lang.String, java.util.Calendar)
@@ -833,7 +832,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnLabel
+ * @param columnLabel the column's label.
* @return
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getTimestamp(java.lang.String)
@@ -852,7 +851,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnIndex
+ * @param columnIndex the index of the column.
* @return
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getURL(int)
@@ -862,7 +861,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnLabel
+ * @param columnLabel the column's label.
* @return
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#getURL(java.lang.String)
@@ -1060,8 +1059,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnIndex
- * @param x
+ * @param columnIndex the index of the column.
+ * @param x the InputStream.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateArray(int, java.sql.Array)
*/
@@ -1070,8 +1069,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnLabel
- * @param x
+ * @param columnLabel the column's label.
+ * @param x the InputStream.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateArray(java.lang.String, java.sql.Array)
*/
@@ -1080,9 +1079,9 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnIndex
- * @param x
- * @param length
+ * @param columnIndex the index of the column.
+ * @param x the InputStream.
+ * @param length the length of the data.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateAsciiStream(int, java.io.InputStream, int)
*/
@@ -1091,9 +1090,9 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnIndex
- * @param x
- * @param length
+ * @param columnIndex the index of the column.
+ * @param x the InputStream.
+ * @param length the length of the data.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateAsciiStream(int, java.io.InputStream, long)
*/
@@ -1102,8 +1101,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnIndex
- * @param x
+ * @param columnIndex the index of the column.
+ * @param x the InputStream.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateAsciiStream(int, java.io.InputStream)
*/
@@ -1112,9 +1111,9 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnLabel
- * @param x
- * @param length
+ * @param columnLabel the column's label.
+ * @param x the InputStream.
+ * @param length the length of the data.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateAsciiStream(java.lang.String, java.io.InputStream, int)
*/
@@ -1123,9 +1122,9 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnLabel
- * @param x
- * @param length
+ * @param columnLabel the column's label.
+ * @param x the InputStream.
+ * @param length the length of the data.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateAsciiStream(java.lang.String, java.io.InputStream, long)
*/
@@ -1134,8 +1133,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnLabel
- * @param x
+ * @param columnLabel the column's label.
+ * @param x the InputStream.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateAsciiStream(java.lang.String, java.io.InputStream)
*/
@@ -1144,8 +1143,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnIndex
- * @param x
+ * @param columnIndex the index of the column.
+ * @param x the InputStream.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateBigDecimal(int, java.math.BigDecimal)
*/
@@ -1154,8 +1153,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnLabel
- * @param x
+ * @param columnLabel the column's label.
+ * @param x the InputStream.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateBigDecimal(java.lang.String, java.math.BigDecimal)
*/
@@ -1164,9 +1163,9 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnIndex
- * @param x
- * @param length
+ * @param columnIndex the index of the column.
+ * @param x the InputStream.
+ * @param length the length of the data.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateBinaryStream(int, java.io.InputStream, int)
*/
@@ -1175,9 +1174,9 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnIndex
- * @param x
- * @param length
+ * @param columnIndex the index of the column.
+ * @param x the InputStream.
+ * @param length the length of the data.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateBinaryStream(int, java.io.InputStream, long)
*/
@@ -1186,8 +1185,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnIndex
- * @param x
+ * @param columnIndex the index of the column.
+ * @param x the InputStream.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateBinaryStream(int, java.io.InputStream)
*/
@@ -1196,9 +1195,9 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnLabel
- * @param x
- * @param length
+ * @param columnLabel the column's label.
+ * @param x the InputStream.
+ * @param length the length of the data.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateBinaryStream(java.lang.String, java.io.InputStream, int)
*/
@@ -1207,9 +1206,9 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnLabel
- * @param x
- * @param length
+ * @param columnLabel the column's label.
+ * @param x the InputStream.
+ * @param length the length of the data.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateBinaryStream(java.lang.String, java.io.InputStream, long)
*/
@@ -1218,8 +1217,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnLabel
- * @param x
+ * @param columnLabel the column's label.
+ * @param x the InputStream.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateBinaryStream(java.lang.String, java.io.InputStream)
*/
@@ -1228,8 +1227,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnIndex
- * @param x
+ * @param columnIndex the index of the column.
+ * @param x the InputStream.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateBlob(int, java.sql.Blob)
*/
@@ -1238,9 +1237,9 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnIndex
+ * @param columnIndex the index of the column.
* @param inputStream
- * @param length
+ * @param length the length of the data.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateBlob(int, java.io.InputStream, long)
*/
@@ -1249,7 +1248,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnIndex
+ * @param columnIndex the index of the column.
* @param inputStream
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateBlob(int, java.io.InputStream)
@@ -1259,8 +1258,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnLabel
- * @param x
+ * @param columnLabel the column's label.
+ * @param x the InputStream.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateBlob(java.lang.String, java.sql.Blob)
*/
@@ -1269,9 +1268,9 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnLabel
+ * @param columnLabel the column's label.
* @param inputStream
- * @param length
+ * @param length the length of the data.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateBlob(java.lang.String, java.io.InputStream, long)
*/
@@ -1280,7 +1279,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnLabel
+ * @param columnLabel the column's label.
* @param inputStream
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateBlob(java.lang.String, java.io.InputStream)
@@ -1290,8 +1289,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnIndex
- * @param x
+ * @param columnIndex the index of the column.
+ * @param x the InputStream.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateBoolean(int, boolean)
*/
@@ -1300,8 +1299,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnLabel
- * @param x
+ * @param columnLabel the column's label.
+ * @param x the InputStream.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateBoolean(java.lang.String, boolean)
*/
@@ -1310,8 +1309,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnIndex
- * @param x
+ * @param columnIndex the index of the column.
+ * @param x the InputStream.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateByte(int, byte)
*/
@@ -1320,8 +1319,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnLabel
- * @param x
+ * @param columnLabel the column's label.
+ * @param x the InputStream.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateByte(java.lang.String, byte)
*/
@@ -1330,8 +1329,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnIndex
- * @param x
+ * @param columnIndex the index of the column.
+ * @param x the InputStream.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateBytes(int, byte[])
*/
@@ -1340,8 +1339,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnLabel
- * @param x
+ * @param columnLabel the column's label.
+ * @param x the InputStream.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateBytes(java.lang.String, byte[])
*/
@@ -1350,9 +1349,9 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnIndex
- * @param x
- * @param length
+ * @param columnIndex the index of the column.
+ * @param x the InputStream.
+ * @param length the length of the data.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateCharacterStream(int, java.io.Reader, int)
*/
@@ -1361,9 +1360,9 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnIndex
- * @param x
- * @param length
+ * @param columnIndex the index of the column.
+ * @param x the InputStream.
+ * @param length the length of the data.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateCharacterStream(int, java.io.Reader, long)
*/
@@ -1372,8 +1371,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnIndex
- * @param x
+ * @param columnIndex the index of the column.
+ * @param x the InputStream.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateCharacterStream(int, java.io.Reader)
*/
@@ -1382,9 +1381,9 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnLabel
- * @param reader
- * @param length
+ * @param columnLabel the column's label.
+ * @param reader the Reader.
+ * @param length the length of the data.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateCharacterStream(java.lang.String, java.io.Reader, int)
*/
@@ -1393,9 +1392,9 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnLabel
- * @param reader
- * @param length
+ * @param columnLabel the column's label.
+ * @param reader the Reader.
+ * @param length the length of the data.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateCharacterStream(java.lang.String, java.io.Reader, long)
*/
@@ -1404,8 +1403,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnLabel
- * @param reader
+ * @param columnLabel the column's label.
+ * @param reader the Reader.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateCharacterStream(java.lang.String, java.io.Reader)
*/
@@ -1414,8 +1413,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnIndex
- * @param x
+ * @param columnIndex the index of the column.
+ * @param x the InputStream.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateClob(int, java.sql.Clob)
*/
@@ -1424,9 +1423,9 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnIndex
- * @param reader
- * @param length
+ * @param columnIndex the index of the column.
+ * @param reader the Reader.
+ * @param length the length of the data.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateClob(int, java.io.Reader, long)
*/
@@ -1435,8 +1434,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnIndex
- * @param reader
+ * @param columnIndex the index of the column.
+ * @param reader the Reader.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateClob(int, java.io.Reader)
*/
@@ -1445,8 +1444,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnLabel
- * @param x
+ * @param columnLabel the column's label.
+ * @param x the InputStream.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateClob(java.lang.String, java.sql.Clob)
*/
@@ -1455,9 +1454,9 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnLabel
- * @param reader
- * @param length
+ * @param columnLabel the column's label.
+ * @param reader the Reader.
+ * @param length the length of the data.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateClob(java.lang.String, java.io.Reader, long)
*/
@@ -1466,8 +1465,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnLabel
- * @param reader
+ * @param columnLabel the column's label.
+ * @param reader the Reader.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateClob(java.lang.String, java.io.Reader)
*/
@@ -1476,8 +1475,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnIndex
- * @param x
+ * @param columnIndex the index of the column.
+ * @param x the InputStream.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateDate(int, java.sql.Date)
*/
@@ -1486,8 +1485,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnLabel
- * @param x
+ * @param columnLabel the column's label.
+ * @param x the InputStream.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateDate(java.lang.String, java.sql.Date)
*/
@@ -1496,8 +1495,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnIndex
- * @param x
+ * @param columnIndex the index of the column.
+ * @param x the InputStream.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateDouble(int, double)
*/
@@ -1506,8 +1505,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnLabel
- * @param x
+ * @param columnLabel the column's label.
+ * @param x the InputStream.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateDouble(java.lang.String, double)
*/
@@ -1516,8 +1515,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnIndex
- * @param x
+ * @param columnIndex the index of the column.
+ * @param x the InputStream.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateFloat(int, float)
*/
@@ -1526,8 +1525,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnLabel
- * @param x
+ * @param columnLabel the column's label.
+ * @param x the InputStream.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateFloat(java.lang.String, float)
*/
@@ -1536,8 +1535,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnIndex
- * @param x
+ * @param columnIndex the index of the column.
+ * @param x the InputStream.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateInt(int, int)
*/
@@ -1546,8 +1545,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnLabel
- * @param x
+ * @param columnLabel the column's label.
+ * @param x the InputStream.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateInt(java.lang.String, int)
*/
@@ -1556,8 +1555,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnIndex
- * @param x
+ * @param columnIndex the index of the column.
+ * @param x the InputStream.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateLong(int, long)
*/
@@ -1566,8 +1565,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnLabel
- * @param x
+ * @param columnLabel the column's label.
+ * @param x the InputStream.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateLong(java.lang.String, long)
*/
@@ -1576,9 +1575,9 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnIndex
- * @param x
- * @param length
+ * @param columnIndex the index of the column.
+ * @param x the InputStream.
+ * @param length the length of the data.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateNCharacterStream(int, java.io.Reader, long)
*/
@@ -1587,8 +1586,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnIndex
- * @param x
+ * @param columnIndex the index of the column.
+ * @param x the InputStream.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateNCharacterStream(int, java.io.Reader)
*/
@@ -1597,9 +1596,9 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnLabel
- * @param reader
- * @param length
+ * @param columnLabel the column's label.
+ * @param reader the Reader.
+ * @param length the length of the data.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateNCharacterStream(java.lang.String, java.io.Reader, long)
*/
@@ -1608,8 +1607,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnLabel
- * @param reader
+ * @param columnLabel the column's label.
+ * @param reader the Reader.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateNCharacterStream(java.lang.String, java.io.Reader)
*/
@@ -1618,7 +1617,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnIndex
+ * @param columnIndex the index of the column.
* @param nClob
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateNClob(int, java.sql.NClob)
@@ -1628,9 +1627,9 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnIndex
- * @param reader
- * @param length
+ * @param columnIndex the index of the column.
+ * @param reader the Reader.
+ * @param length the length of the data.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateNClob(int, java.io.Reader, long)
*/
@@ -1639,8 +1638,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnIndex
- * @param reader
+ * @param columnIndex the index of the column.
+ * @param reader the Reader.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateNClob(int, java.io.Reader)
*/
@@ -1649,7 +1648,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnLabel
+ * @param columnLabel the column's label.
* @param nClob
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateNClob(java.lang.String, java.sql.NClob)
@@ -1659,9 +1658,9 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnLabel
- * @param reader
- * @param length
+ * @param columnLabel the column's label.
+ * @param reader the Reader.
+ * @param length the length of the data.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateNClob(java.lang.String, java.io.Reader, long)
*/
@@ -1670,8 +1669,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnLabel
- * @param reader
+ * @param columnLabel the column's label.
+ * @param reader the Reader.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateNClob(java.lang.String, java.io.Reader)
*/
@@ -1680,7 +1679,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnIndex
+ * @param columnIndex the index of the column.
* @param nString
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateNString(int, java.lang.String)
@@ -1690,7 +1689,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnLabel
+ * @param columnLabel the column's label.
* @param nString
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateNString(java.lang.String, java.lang.String)
@@ -1700,7 +1699,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnIndex
+ * @param columnIndex the index of the column.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateNull(int)
*/
@@ -1709,7 +1708,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnLabel
+ * @param columnLabel the column's label.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateNull(java.lang.String)
*/
@@ -1718,8 +1717,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnIndex
- * @param x
+ * @param columnIndex the index of the column.
+ * @param x the InputStream.
* @param scaleOrLength
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateObject(int, java.lang.Object, int)
@@ -1729,8 +1728,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnIndex
- * @param x
+ * @param columnIndex the index of the column.
+ * @param x the InputStream.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateObject(int, java.lang.Object)
*/
@@ -1739,8 +1738,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnLabel
- * @param x
+ * @param columnLabel the column's label.
+ * @param x the InputStream.
* @param scaleOrLength
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateObject(java.lang.String, java.lang.Object, int)
@@ -1750,8 +1749,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnLabel
- * @param x
+ * @param columnLabel the column's label.
+ * @param x the InputStream.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateObject(java.lang.String, java.lang.Object)
*/
@@ -1760,8 +1759,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnIndex
- * @param x
+ * @param columnIndex the index of the column.
+ * @param x the InputStream.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateRef(int, java.sql.Ref)
*/
@@ -1770,8 +1769,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnLabel
- * @param x
+ * @param columnLabel the column's label.
+ * @param x the InputStream.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateRef(java.lang.String, java.sql.Ref)
*/
@@ -1788,8 +1787,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnIndex
- * @param x
+ * @param columnIndex the index of the column.
+ * @param x the InputStream.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateRowId(int, java.sql.RowId)
*/
@@ -1798,8 +1797,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnLabel
- * @param x
+ * @param columnLabel the column's label.
+ * @param x the InputStream.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateRowId(java.lang.String, java.sql.RowId)
*/
@@ -1808,7 +1807,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnIndex
+ * @param columnIndex the index of the column.
* @param xmlObject
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateSQLXML(int, java.sql.SQLXML)
@@ -1818,7 +1817,7 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnLabel
+ * @param columnLabel the column's label.
* @param xmlObject
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateSQLXML(java.lang.String, java.sql.SQLXML)
@@ -1828,8 +1827,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnIndex
- * @param x
+ * @param columnIndex the index of the column.
+ * @param x the InputStream.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateShort(int, short)
*/
@@ -1838,8 +1837,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnLabel
- * @param x
+ * @param columnLabel the column's label.
+ * @param x the InputStream.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateShort(java.lang.String, short)
*/
@@ -1848,8 +1847,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnIndex
- * @param x
+ * @param columnIndex the index of the column.
+ * @param x the InputStream.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateString(int, java.lang.String)
*/
@@ -1858,8 +1857,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnLabel
- * @param x
+ * @param columnLabel the column's label.
+ * @param x the InputStream.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateString(java.lang.String, java.lang.String)
*/
@@ -1868,8 +1867,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnIndex
- * @param x
+ * @param columnIndex the index of the column.
+ * @param x the InputStream.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateTime(int, java.sql.Time)
*/
@@ -1878,8 +1877,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnLabel
- * @param x
+ * @param columnLabel the column's label.
+ * @param x the InputStream.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateTime(java.lang.String, java.sql.Time)
*/
@@ -1888,8 +1887,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnIndex
- * @param x
+ * @param columnIndex the index of the column.
+ * @param x the InputStream.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateTimestamp(int, java.sql.Timestamp)
*/
@@ -1898,8 +1897,8 @@ public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
}
/**
- * @param columnLabel
- * @param x
+ * @param columnLabel the column's label.
+ * @param x the InputStream.
* @throws SQLException thrown if there is an SQL error.
* @see java.sql.ResultSet#updateTimestamp(java.lang.String, java.sql.Timestamp)
*/
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/9319b07b/src/main/java/org/apache/commons/dbutils2/wrappers/SqlNullCheckedResultSet.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/wrappers/SqlNullCheckedResultSet.java b/src/main/java/org/apache/commons/dbutils2/wrappers/SqlNullCheckedResultSet.java
index 53e5a95..71e6661 100644
--- a/src/main/java/org/apache/commons/dbutils2/wrappers/SqlNullCheckedResultSet.java
+++ b/src/main/java/org/apache/commons/dbutils2/wrappers/SqlNullCheckedResultSet.java
@@ -253,7 +253,7 @@ public class SqlNullCheckedResultSet implements InvocationHandler {
* @return the value
*/
public Date getNullDate() {
- return new Date(this.nullDate.getTime());
+ return this.nullDate == null ? null : new Date(this.nullDate.getTime());
}
/**
@@ -353,7 +353,7 @@ public class SqlNullCheckedResultSet implements InvocationHandler {
* @return the value
*/
public Timestamp getNullTimestamp() {
- return new Timestamp(this.nullTimestamp.getTime());
+ return this.nullTimestamp == null ? null : new Timestamp(this.nullTimestamp.getTime());
}
/**
[41/58] [abbrv] commons-dbutils git commit: Applied DBUTILS-108 to
2.0 branch
Posted by th...@apache.org.
Applied DBUTILS-108 to 2.0 branch
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/dbutils/branches/2_0@1482088 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/commons-dbutils/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-dbutils/commit/e8727b69
Tree: http://git-wip-us.apache.org/repos/asf/commons-dbutils/tree/e8727b69
Diff: http://git-wip-us.apache.org/repos/asf/commons-dbutils/diff/e8727b69
Branch: refs/heads/2_0
Commit: e8727b69983ddfb247201dd69cd35940806051a5
Parents: 67728b0
Author: Bill Speirs <ws...@apache.org>
Authored: Mon May 13 20:27:57 2013 +0000
Committer: Bill Speirs <ws...@apache.org>
Committed: Mon May 13 20:27:57 2013 +0000
----------------------------------------------------------------------
.../apache/commons/dbutils2/BatchExecutor.java | 12 ++++
.../commons/dbutils2/BatchInsertExecutor.java | 67 ++++++++++++++++++
.../dbutils2/BatchInsertExecutorTest.java | 72 ++++++++++++++++++++
3 files changed, 151 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/e8727b69/src/main/java/org/apache/commons/dbutils2/BatchExecutor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/BatchExecutor.java b/src/main/java/org/apache/commons/dbutils2/BatchExecutor.java
index e8b13a9..4ee5d16 100644
--- a/src/main/java/org/apache/commons/dbutils2/BatchExecutor.java
+++ b/src/main/java/org/apache/commons/dbutils2/BatchExecutor.java
@@ -17,6 +17,7 @@
package org.apache.commons.dbutils2;
import java.sql.Connection;
+import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Types;
@@ -43,6 +44,14 @@ public class BatchExecutor extends AbstractExecutor<BatchExecutor> {
super(conn, sql);
this.closeConn = closeConnection;
}
+
+ /**
+ * Returns the close connection flag.
+ * @return close connection flag.
+ */
+ boolean getCloseConn() {
+ return closeConn;
+ }
/**
* Binds a parameter name to a value for a given statement.
@@ -111,6 +120,9 @@ public class BatchExecutor extends AbstractExecutor<BatchExecutor> {
* @see org.apache.commons.dbutils2.UpdateExecutor#execute()
*/
public int[] execute() throws SQLException {
+ // throw an exception if there are unmapped parameters
+ this.throwIfUnmappedParams();
+
try {
return getStatement().executeBatch();
} catch (SQLException e) {
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/e8727b69/src/main/java/org/apache/commons/dbutils2/BatchInsertExecutor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/BatchInsertExecutor.java b/src/main/java/org/apache/commons/dbutils2/BatchInsertExecutor.java
new file mode 100644
index 0000000..01f75d7
--- /dev/null
+++ b/src/main/java/org/apache/commons/dbutils2/BatchInsertExecutor.java
@@ -0,0 +1,67 @@
+package org.apache.commons.dbutils2;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+
+public class BatchInsertExecutor extends BatchExecutor {
+
+ /**
+ * Constructs a BatchInsertExecutor given a connection and SQL statement.
+ *
+ * @param conn The connection to use during execution.
+ * @param sql The SQL statement.
+ * @param closeConnection If the connection should be closed or not.
+ * @throws SQLException thrown if there is an error during execution.
+ */
+ BatchInsertExecutor(final Connection conn, final String sql, final boolean closeConnection) throws SQLException {
+ super(conn, sql, closeConnection);
+ }
+
+ /**
+ * Calls batch after checking the parameters to ensure nothing is null.
+ *
+ * @return the result generated by the handler.
+ * @throws SQLException If there are database or parameter errors.
+ * @see org.apache.commons.dbutils2.UpdateExecutor#execute()
+ */
+ public <T> T execute(final ResultSetHandler<T> handler) throws SQLException {
+ // throw an exception if there are unmapped parameters
+ this.throwIfUnmappedParams();
+
+ // make sure our handler is not null
+ if (handler == null) {
+ if (getCloseConn()) {
+ close(getConnection());
+ }
+ throw new SQLException("Null ResultSetHandler");
+ }
+
+ ResultSet resultSet = null;
+
+ try {
+ // execute the query and get the keys, wrapping them
+ getStatement().executeBatch();
+ resultSet = this.wrap(getStatement().getGeneratedKeys());
+
+ // execute the handler
+ return handler.handle(resultSet);
+ } catch (SQLException e) {
+ rethrow(e);
+ } finally {
+ try {
+ close(resultSet);
+ } finally {
+ close(getStatement());
+ if (getCloseConn()) {
+ close(getConnection());
+ }
+ }
+ }
+
+ // we get here only if something is thrown
+ return null;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/e8727b69/src/test/java/org/apache/commons/dbutils2/BatchInsertExecutorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils2/BatchInsertExecutorTest.java b/src/test/java/org/apache/commons/dbutils2/BatchInsertExecutorTest.java
new file mode 100644
index 0000000..7bb3a85
--- /dev/null
+++ b/src/test/java/org/apache/commons/dbutils2/BatchInsertExecutorTest.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.dbutils2;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.List;
+import org.apache.commons.dbutils2.handlers.ArrayListHandler;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+
+public class BatchInsertExecutorTest {
+
+ private BatchInsertExecutor executor;
+
+ @Mock private ResultSetHandler<Object> handler;
+ @Mock private Connection conn;
+ @Mock private PreparedStatement stmt;
+ @Mock private ResultSet resultSet;
+
+ @Before
+ public void setup() throws SQLException {
+ MockitoAnnotations.initMocks(this);
+
+ when(conn.prepareStatement(any(String.class))).thenReturn(stmt);
+ when(stmt.getGeneratedKeys()).thenReturn(resultSet);
+ when(handler.handle(any(ResultSet.class))).thenReturn(new Object());
+ }
+
+ protected void createExecutor(String sql) throws Exception {
+ executor = new BatchInsertExecutor(conn, sql, true);
+ }
+
+ @Test
+ public void testGoodSQL() throws Exception {
+ createExecutor("insert into blah");
+
+ executor.addBatch();
+ Object ret = executor.execute(handler);
+
+ assertNotNull(ret);
+ verify(handler, times(1)).handle(resultSet);
+ verify(conn, times(1)).close();
+ verify(stmt, times(1)).close();
+ }
+
+}
[30/58] [abbrv] commons-dbutils git commit: Standardise @since syntax
Posted by th...@apache.org.
Standardise @since syntax
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/dbutils/branches/2_0@1481323 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/commons-dbutils/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-dbutils/commit/44eadb77
Tree: http://git-wip-us.apache.org/repos/asf/commons-dbutils/tree/44eadb77
Diff: http://git-wip-us.apache.org/repos/asf/commons-dbutils/diff/44eadb77
Branch: refs/heads/2_0
Commit: 44eadb77b40c14d934f1314edf69b5f6d3561f32
Parents: c035938
Author: Sebastian Bazley <se...@apache.org>
Authored: Sat May 11 13:33:37 2013 +0000
Committer: Sebastian Bazley <se...@apache.org>
Committed: Sat May 11 13:33:37 2013 +0000
----------------------------------------------------------------------
src/main/java/org/apache/commons/dbutils2/BasicRowProcessor.java | 2 +-
src/main/java/org/apache/commons/dbutils2/BeanProcessor.java | 2 +-
src/main/java/org/apache/commons/dbutils2/DbUtils.java | 4 ++--
src/main/java/org/apache/commons/dbutils2/QueryLoader.java | 2 +-
src/main/java/org/apache/commons/dbutils2/ResultSetIterator.java | 2 +-
.../apache/commons/dbutils2/handlers/AbstractKeyedHandler.java | 2 +-
.../org/apache/commons/dbutils2/handlers/BeanMapHandler.java | 2 +-
.../org/apache/commons/dbutils2/handlers/ColumnListHandler.java | 2 +-
.../java/org/apache/commons/dbutils2/handlers/KeyedHandler.java | 2 +-
9 files changed, 10 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/44eadb77/src/main/java/org/apache/commons/dbutils2/BasicRowProcessor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/BasicRowProcessor.java b/src/main/java/org/apache/commons/dbutils2/BasicRowProcessor.java
index 51129f9..c8cc899 100644
--- a/src/main/java/org/apache/commons/dbutils2/BasicRowProcessor.java
+++ b/src/main/java/org/apache/commons/dbutils2/BasicRowProcessor.java
@@ -58,7 +58,7 @@ public class BasicRowProcessor implements RowProcessor {
* BasicRowProcessor constructor.
* @param convert The BeanProcessor to use when converting columns to
* bean properties.
- * @since DbUtils 1.1
+ * @since 1.1
*/
public BasicRowProcessor(BeanProcessor convert) {
super();
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/44eadb77/src/main/java/org/apache/commons/dbutils2/BeanProcessor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/BeanProcessor.java b/src/main/java/org/apache/commons/dbutils2/BeanProcessor.java
index 46c089b..1ee0ff6 100644
--- a/src/main/java/org/apache/commons/dbutils2/BeanProcessor.java
+++ b/src/main/java/org/apache/commons/dbutils2/BeanProcessor.java
@@ -47,7 +47,7 @@ import java.util.Map;
*
* @see BasicRowProcessor
*
- * @since DbUtils 1.1
+ * @since 1.1
*/
public class BeanProcessor {
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/44eadb77/src/main/java/org/apache/commons/dbutils2/DbUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/DbUtils.java b/src/main/java/org/apache/commons/dbutils2/DbUtils.java
index 515392f..37ff688 100644
--- a/src/main/java/org/apache/commons/dbutils2/DbUtils.java
+++ b/src/main/java/org/apache/commons/dbutils2/DbUtils.java
@@ -312,7 +312,7 @@ public final class DbUtils {
*
* @param conn Connection to rollback. A null value is legal.
* @throws SQLException if a database access error occurs
- * @since DbUtils 1.1
+ * @since 1.1
*/
public static void rollbackAndClose(Connection conn) throws SQLException {
if (conn != null) {
@@ -329,7 +329,7 @@ public final class DbUtils {
* avoid closing if null and hide any SQLExceptions that occur.
*
* @param conn Connection to rollback. A null value is legal.
- * @since DbUtils 1.1
+ * @since 1.1
*/
public static void rollbackAndCloseQuietly(Connection conn) {
try {
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/44eadb77/src/main/java/org/apache/commons/dbutils2/QueryLoader.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/QueryLoader.java b/src/main/java/org/apache/commons/dbutils2/QueryLoader.java
index df6db6f..e7b1f54 100644
--- a/src/main/java/org/apache/commons/dbutils2/QueryLoader.java
+++ b/src/main/java/org/apache/commons/dbutils2/QueryLoader.java
@@ -88,7 +88,7 @@ public class QueryLoader {
* @throws IOException if a file access error occurs
* @throws IllegalArgumentException if the ClassLoader can't find a file at
* the given path.
- * @since DbUtils 1.1
+ * @since 1.1
* @return Map of query names to SQL values
*/
protected Map<String, String> loadQueries(String path) throws IOException {
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/44eadb77/src/main/java/org/apache/commons/dbutils2/ResultSetIterator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/ResultSetIterator.java b/src/main/java/org/apache/commons/dbutils2/ResultSetIterator.java
index ef05213..cd9ca53 100644
--- a/src/main/java/org/apache/commons/dbutils2/ResultSetIterator.java
+++ b/src/main/java/org/apache/commons/dbutils2/ResultSetIterator.java
@@ -115,7 +115,7 @@ public class ResultSetIterator implements Iterator<Object[]> {
* Rethrow the SQLException as a RuntimeException. This implementation
* creates a new RuntimeException with the SQLException's error message.
* @param e SQLException to rethrow
- * @since DbUtils 1.1
+ * @since 1.1
*/
protected void rethrow(SQLException e) {
throw new RuntimeException(e.getMessage());
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/44eadb77/src/main/java/org/apache/commons/dbutils2/handlers/AbstractKeyedHandler.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/handlers/AbstractKeyedHandler.java b/src/main/java/org/apache/commons/dbutils2/handlers/AbstractKeyedHandler.java
index 14e0b63..a6372e1 100644
--- a/src/main/java/org/apache/commons/dbutils2/handlers/AbstractKeyedHandler.java
+++ b/src/main/java/org/apache/commons/dbutils2/handlers/AbstractKeyedHandler.java
@@ -33,7 +33,7 @@ import org.apache.commons.dbutils2.ResultSetHandler;
* @param <K> the type of keys maintained by the returned map
* @param <V> the type of mapped values
* @see org.apache.commons.dbutils2.ResultSetHandler
- * @since DbUtils 1.3
+ * @since 1.3
*/
public abstract class AbstractKeyedHandler<K, V> implements ResultSetHandler<Map<K, V>> {
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/44eadb77/src/main/java/org/apache/commons/dbutils2/handlers/BeanMapHandler.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/handlers/BeanMapHandler.java b/src/main/java/org/apache/commons/dbutils2/handlers/BeanMapHandler.java
index 6f37fca..a8edff0 100644
--- a/src/main/java/org/apache/commons/dbutils2/handlers/BeanMapHandler.java
+++ b/src/main/java/org/apache/commons/dbutils2/handlers/BeanMapHandler.java
@@ -53,7 +53,7 @@ import org.apache.commons.dbutils2.RowProcessor;
* @param <V>
* the type of the bean
* @see org.apache.commons.dbutils2.ResultSetHandler
- * @since DbUtils 1.5
+ * @since 1.5
*/
public class BeanMapHandler<K, V> extends AbstractKeyedHandler<K, V> {
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/44eadb77/src/main/java/org/apache/commons/dbutils2/handlers/ColumnListHandler.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/handlers/ColumnListHandler.java b/src/main/java/org/apache/commons/dbutils2/handlers/ColumnListHandler.java
index a432682..39cf128 100644
--- a/src/main/java/org/apache/commons/dbutils2/handlers/ColumnListHandler.java
+++ b/src/main/java/org/apache/commons/dbutils2/handlers/ColumnListHandler.java
@@ -26,7 +26,7 @@ import java.sql.SQLException;
*
* @param <T> The type of the column.
* @see org.apache.commons.dbutils2.ResultSetHandler
- * @since DbUtils 1.1
+ * @since 1.1
*/
public class ColumnListHandler<T> extends AbstractListHandler<T> {
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/44eadb77/src/main/java/org/apache/commons/dbutils2/handlers/KeyedHandler.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/handlers/KeyedHandler.java b/src/main/java/org/apache/commons/dbutils2/handlers/KeyedHandler.java
index 245d2e7..4089650 100644
--- a/src/main/java/org/apache/commons/dbutils2/handlers/KeyedHandler.java
+++ b/src/main/java/org/apache/commons/dbutils2/handlers/KeyedHandler.java
@@ -47,7 +47,7 @@ import org.apache.commons.dbutils2.RowProcessor;
*
* @param <K> The type of the key
* @see org.apache.commons.dbutils2.ResultSetHandler
- * @since DbUtils 1.1
+ * @since 1.1
*/
public class KeyedHandler<K> extends AbstractKeyedHandler<K, Map<String, Object>> {
[15/58] [abbrv] commons-dbutils git commit: - Setting to RC1
Posted by th...@apache.org.
- Setting to RC1
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/dbutils/tags/DBUTILS_2_0_RC1@1457541 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/commons-dbutils/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-dbutils/commit/b5e15de5
Tree: http://git-wip-us.apache.org/repos/asf/commons-dbutils/tree/b5e15de5
Diff: http://git-wip-us.apache.org/repos/asf/commons-dbutils/diff/b5e15de5
Branch: refs/heads/2_0
Commit: b5e15de5a15e28c30cfcd43e94c7afd7496e06d2
Parents: 7ea4269
Author: Bill Speirs <ws...@apache.org>
Authored: Sun Mar 17 19:43:06 2013 +0000
Committer: Bill Speirs <ws...@apache.org>
Committed: Sun Mar 17 19:43:06 2013 +0000
----------------------------------------------------------------------
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/b5e15de5/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 096f6a0..ec64cb2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -24,7 +24,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.commons</groupId>
<artifactId>commons-dbutils</artifactId>
- <version>2.0-SNAPSHOT</version>
+ <version>2.0-RC1</version>
<name>Commons DbUtils</name>
<inceptionYear>2002</inceptionYear>
[14/58] [abbrv] commons-dbutils git commit: Tagging dbutils-2.0 RC1
Posted by th...@apache.org.
Tagging dbutils-2.0 RC1
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/dbutils/tags/DBUTILS_2_0_RC1@1457535 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/commons-dbutils/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-dbutils/commit/7ea4269f
Tree: http://git-wip-us.apache.org/repos/asf/commons-dbutils/tree/7ea4269f
Diff: http://git-wip-us.apache.org/repos/asf/commons-dbutils/diff/7ea4269f
Branch: refs/heads/2_0
Commit: 7ea4269f0ae2fad4c286abefe701b2677d0d5b3a
Parents: 9319b07
Author: Bill Speirs <ws...@apache.org>
Authored: Sun Mar 17 19:37:03 2013 +0000
Committer: Bill Speirs <ws...@apache.org>
Committed: Sun Mar 17 19:37:03 2013 +0000
----------------------------------------------------------------------
----------------------------------------------------------------------
[23/58] [abbrv] commons-dbutils git commit: Add missing svn:eol-style
properties
Posted by th...@apache.org.
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/d2ce0836/src/test/java/org/apache/commons/dbutils2/InsertExecutorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils2/InsertExecutorTest.java b/src/test/java/org/apache/commons/dbutils2/InsertExecutorTest.java
index ee7bf11..3ebc56c 100644
--- a/src/test/java/org/apache/commons/dbutils2/InsertExecutorTest.java
+++ b/src/test/java/org/apache/commons/dbutils2/InsertExecutorTest.java
@@ -1,94 +1,94 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.dbutils2;
-
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-import org.apache.commons.dbutils2.InsertExecutor;
-import org.apache.commons.dbutils2.ResultSetHandler;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-
-
-public class InsertExecutorTest {
-
- private InsertExecutor executor;
-
- @Mock private ResultSetHandler<Object> handler;
- @Mock private Connection conn;
- @Mock private PreparedStatement stmt;
- @Mock private ResultSet resultSet;
-
- @Before
- public void setup() throws SQLException {
- MockitoAnnotations.initMocks(this);
-
- when(conn.prepareStatement(any(String.class))).thenReturn(stmt);
- when(stmt.getGeneratedKeys()).thenReturn(resultSet);
- when(handler.handle(any(ResultSet.class))).thenReturn(new Object());
- }
-
- protected void createExecutor(String sql) throws Exception {
- executor = new InsertExecutor(conn, sql, true);
- }
-
- @Test
- public void testGoodSQL() throws Exception {
- createExecutor("insert into blah");
-
- Object ret = executor.execute(handler);
-
- assertNotNull(ret);
- verify(handler, times(1)).handle(resultSet);
- verify(conn, times(1)).close();
- verify(stmt, times(1)).close();
- }
-
- @Test(expected=SQLException.class)
- public void testUnmappedParams() throws Exception {
- createExecutor("insert into blah (:something)");
-
- Object ret = executor.execute(handler);
-
- assertNotNull(ret);
- verify(handler, times(1)).handle(resultSet);
- verify(conn, times(1)).close();
- verify(stmt, times(1)).close();
- }
-
- @Test(expected=SQLException.class)
- public void testNullHandler() throws Exception {
- createExecutor("insert into blah");
-
- Object ret = executor.execute(null);
-
- assertNotNull(ret);
- verify(handler, times(1)).handle(resultSet);
- verify(conn, times(1)).close();
- verify(stmt, times(1)).close();
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.dbutils2;
+
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+import org.apache.commons.dbutils2.InsertExecutor;
+import org.apache.commons.dbutils2.ResultSetHandler;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+
+public class InsertExecutorTest {
+
+ private InsertExecutor executor;
+
+ @Mock private ResultSetHandler<Object> handler;
+ @Mock private Connection conn;
+ @Mock private PreparedStatement stmt;
+ @Mock private ResultSet resultSet;
+
+ @Before
+ public void setup() throws SQLException {
+ MockitoAnnotations.initMocks(this);
+
+ when(conn.prepareStatement(any(String.class))).thenReturn(stmt);
+ when(stmt.getGeneratedKeys()).thenReturn(resultSet);
+ when(handler.handle(any(ResultSet.class))).thenReturn(new Object());
+ }
+
+ protected void createExecutor(String sql) throws Exception {
+ executor = new InsertExecutor(conn, sql, true);
+ }
+
+ @Test
+ public void testGoodSQL() throws Exception {
+ createExecutor("insert into blah");
+
+ Object ret = executor.execute(handler);
+
+ assertNotNull(ret);
+ verify(handler, times(1)).handle(resultSet);
+ verify(conn, times(1)).close();
+ verify(stmt, times(1)).close();
+ }
+
+ @Test(expected=SQLException.class)
+ public void testUnmappedParams() throws Exception {
+ createExecutor("insert into blah (:something)");
+
+ Object ret = executor.execute(handler);
+
+ assertNotNull(ret);
+ verify(handler, times(1)).handle(resultSet);
+ verify(conn, times(1)).close();
+ verify(stmt, times(1)).close();
+ }
+
+ @Test(expected=SQLException.class)
+ public void testNullHandler() throws Exception {
+ createExecutor("insert into blah");
+
+ Object ret = executor.execute(null);
+
+ assertNotNull(ret);
+ verify(handler, times(1)).handle(resultSet);
+ verify(conn, times(1)).close();
+ verify(stmt, times(1)).close();
+ }
+}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/d2ce0836/src/test/java/org/apache/commons/dbutils2/QueryExecutorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils2/QueryExecutorTest.java b/src/test/java/org/apache/commons/dbutils2/QueryExecutorTest.java
index 9b7b1e8..bf6b760 100644
--- a/src/test/java/org/apache/commons/dbutils2/QueryExecutorTest.java
+++ b/src/test/java/org/apache/commons/dbutils2/QueryExecutorTest.java
@@ -1,94 +1,94 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.dbutils2;
-
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-import org.apache.commons.dbutils2.QueryExecutor;
-import org.apache.commons.dbutils2.ResultSetHandler;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-
-
-public class QueryExecutorTest {
-
- private QueryExecutor executor;
-
- @Mock private ResultSetHandler<Object> handler;
- @Mock private Connection conn;
- @Mock private PreparedStatement stmt;
- @Mock private ResultSet resultSet;
-
- @Before
- public void setup() throws SQLException {
- MockitoAnnotations.initMocks(this);
-
- when(conn.prepareStatement(any(String.class))).thenReturn(stmt);
- when(stmt.executeQuery()).thenReturn(resultSet);
- when(handler.handle(any(ResultSet.class))).thenReturn(new Object());
- }
-
- protected void createExecutor(String sql) throws Exception {
- executor = new QueryExecutor(conn, sql, true);
- }
-
- @Test
- public void testGoodSQL() throws Exception {
- createExecutor("insert into blah");
-
- Object ret = executor.execute(handler);
-
- assertNotNull(ret);
- verify(handler, times(1)).handle(resultSet);
- verify(conn, times(1)).close();
- verify(stmt, times(1)).close();
- }
-
- @Test(expected=SQLException.class)
- public void testUnmappedParams() throws Exception {
- createExecutor("insert into blah (:something)");
-
- Object ret = executor.execute(handler);
-
- assertNotNull(ret);
- verify(handler, times(1)).handle(resultSet);
- verify(conn, times(1)).close();
- verify(stmt, times(1)).close();
- }
-
- @Test(expected=SQLException.class)
- public void testNullHandler() throws Exception {
- createExecutor("insert into blah");
-
- Object ret = executor.execute(null);
-
- assertNotNull(ret);
- verify(handler, times(1)).handle(resultSet);
- verify(conn, times(1)).close();
- verify(stmt, times(1)).close();
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.dbutils2;
+
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+import org.apache.commons.dbutils2.QueryExecutor;
+import org.apache.commons.dbutils2.ResultSetHandler;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+
+public class QueryExecutorTest {
+
+ private QueryExecutor executor;
+
+ @Mock private ResultSetHandler<Object> handler;
+ @Mock private Connection conn;
+ @Mock private PreparedStatement stmt;
+ @Mock private ResultSet resultSet;
+
+ @Before
+ public void setup() throws SQLException {
+ MockitoAnnotations.initMocks(this);
+
+ when(conn.prepareStatement(any(String.class))).thenReturn(stmt);
+ when(stmt.executeQuery()).thenReturn(resultSet);
+ when(handler.handle(any(ResultSet.class))).thenReturn(new Object());
+ }
+
+ protected void createExecutor(String sql) throws Exception {
+ executor = new QueryExecutor(conn, sql, true);
+ }
+
+ @Test
+ public void testGoodSQL() throws Exception {
+ createExecutor("insert into blah");
+
+ Object ret = executor.execute(handler);
+
+ assertNotNull(ret);
+ verify(handler, times(1)).handle(resultSet);
+ verify(conn, times(1)).close();
+ verify(stmt, times(1)).close();
+ }
+
+ @Test(expected=SQLException.class)
+ public void testUnmappedParams() throws Exception {
+ createExecutor("insert into blah (:something)");
+
+ Object ret = executor.execute(handler);
+
+ assertNotNull(ret);
+ verify(handler, times(1)).handle(resultSet);
+ verify(conn, times(1)).close();
+ verify(stmt, times(1)).close();
+ }
+
+ @Test(expected=SQLException.class)
+ public void testNullHandler() throws Exception {
+ createExecutor("insert into blah");
+
+ Object ret = executor.execute(null);
+
+ assertNotNull(ret);
+ verify(handler, times(1)).handle(resultSet);
+ verify(conn, times(1)).close();
+ verify(stmt, times(1)).close();
+ }
+}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/d2ce0836/src/test/java/org/apache/commons/dbutils2/UpdateExecutorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils2/UpdateExecutorTest.java b/src/test/java/org/apache/commons/dbutils2/UpdateExecutorTest.java
index d245dba..4b9a400 100644
--- a/src/test/java/org/apache/commons/dbutils2/UpdateExecutorTest.java
+++ b/src/test/java/org/apache/commons/dbutils2/UpdateExecutorTest.java
@@ -1,77 +1,77 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.dbutils2;
-
-import static org.junit.Assert.*;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.SQLException;
-
-import org.apache.commons.dbutils2.UpdateExecutor;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-
-
-public class UpdateExecutorTest {
-
- private UpdateExecutor executor;
-
- @Mock private Connection conn;
- @Mock private PreparedStatement stmt;
-
- @SuppressWarnings("boxing") // test code
- @Before
- public void setup() throws SQLException {
- MockitoAnnotations.initMocks(this);
-
- when(conn.prepareStatement(any(String.class))).thenReturn(stmt);
- when(stmt.executeUpdate()).thenReturn(20);
- }
-
- protected void createExecutor(String sql) throws Exception {
- executor = new UpdateExecutor(conn, sql, true);
- }
-
- @Test
- public void testGoodSQL() throws Exception {
- createExecutor("insert into blah");
-
- int ret = executor.execute();
-
- assertEquals(20, ret);
- verify(conn, times(1)).close();
- verify(stmt, times(1)).close();
- }
-
- @Test(expected=SQLException.class)
- public void testUnmappedParams() throws Exception {
- createExecutor("insert into blah (:something)");
-
- int ret = executor.execute();
-
- assertEquals(20, ret);
- verify(conn, times(1)).close();
- verify(stmt, times(1)).close();
- }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.dbutils2;
+
+import static org.junit.Assert.*;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+
+import org.apache.commons.dbutils2.UpdateExecutor;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+
+public class UpdateExecutorTest {
+
+ private UpdateExecutor executor;
+
+ @Mock private Connection conn;
+ @Mock private PreparedStatement stmt;
+
+ @SuppressWarnings("boxing") // test code
+ @Before
+ public void setup() throws SQLException {
+ MockitoAnnotations.initMocks(this);
+
+ when(conn.prepareStatement(any(String.class))).thenReturn(stmt);
+ when(stmt.executeUpdate()).thenReturn(20);
+ }
+
+ protected void createExecutor(String sql) throws Exception {
+ executor = new UpdateExecutor(conn, sql, true);
+ }
+
+ @Test
+ public void testGoodSQL() throws Exception {
+ createExecutor("insert into blah");
+
+ int ret = executor.execute();
+
+ assertEquals(20, ret);
+ verify(conn, times(1)).close();
+ verify(stmt, times(1)).close();
+ }
+
+ @Test(expected=SQLException.class)
+ public void testUnmappedParams() throws Exception {
+ createExecutor("insert into blah (:something)");
+
+ int ret = executor.execute();
+
+ assertEquals(20, ret);
+ verify(conn, times(1)).close();
+ verify(stmt, times(1)).close();
+ }
+
+}
[25/58] [abbrv] commons-dbutils git commit: Merged changes from RC1
Posted by th...@apache.org.
Merged changes from RC1
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/dbutils/branches/2_0@1481159 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/commons-dbutils/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-dbutils/commit/f3951b9d
Tree: http://git-wip-us.apache.org/repos/asf/commons-dbutils/tree/f3951b9d
Diff: http://git-wip-us.apache.org/repos/asf/commons-dbutils/diff/f3951b9d
Branch: refs/heads/2_0
Commit: f3951b9dbbdd28de87b559289bfa824ff92ef7d4
Parents: d2ce083 83d65e3
Author: Bill Speirs <ws...@apache.org>
Authored: Fri May 10 19:43:34 2013 +0000
Committer: Bill Speirs <ws...@apache.org>
Committed: Fri May 10 19:43:34 2013 +0000
----------------------------------------------------------------------
RELEASE-NOTES.txt | 17 +++++------------
1 file changed, 5 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
[45/58] [abbrv] commons-dbutils git commit: Trailing spaces
Posted by th...@apache.org.
Trailing spaces
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/dbutils/branches/2_0@1482099 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/commons-dbutils/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-dbutils/commit/9c8f3b01
Tree: http://git-wip-us.apache.org/repos/asf/commons-dbutils/tree/9c8f3b01
Diff: http://git-wip-us.apache.org/repos/asf/commons-dbutils/diff/9c8f3b01
Branch: refs/heads/2_0
Commit: 9c8f3b01fd6ea48f6e00ae2ec1885d259d4ce48e
Parents: b389bb3
Author: Sebastian Bazley <se...@apache.org>
Authored: Mon May 13 20:53:33 2013 +0000
Committer: Sebastian Bazley <se...@apache.org>
Committed: Mon May 13 20:53:33 2013 +0000
----------------------------------------------------------------------
src/changes/release-notes.vm | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/9c8f3b01/src/changes/release-notes.vm
----------------------------------------------------------------------
diff --git a/src/changes/release-notes.vm b/src/changes/release-notes.vm
index fa03831..87783d6 100644
--- a/src/changes/release-notes.vm
+++ b/src/changes/release-notes.vm
@@ -15,8 +15,8 @@
## specific language governing permissions and limitations
## under the License.
- Apache ${project.name}
- Version ${version}
+ Apache ${project.name}
+ Version ${version}
RELEASE NOTES
The ${developmentTeam} is pleased to announce the release of ${project.name} ${version}
@@ -61,7 +61,7 @@ o#if($!issue != "") $issue: #else$indent#end ${action} #if($!dueto != "")Thanks
#set($issue="")
#set($dueto="")
-#end
+#end
#end
#if ($release.getActions('fix').size() !=0)
[09/58] [abbrv] commons-dbutils git commit: Changed the package names
so dbutils and dbutils2 won't conflict if both loaded
Posted by th...@apache.org.
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/main/java/org/apache/commons/dbutils/BasicRowProcessor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils/BasicRowProcessor.java b/src/main/java/org/apache/commons/dbutils/BasicRowProcessor.java
deleted file mode 100644
index cd0c575..0000000
--- a/src/main/java/org/apache/commons/dbutils/BasicRowProcessor.java
+++ /dev/null
@@ -1,239 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.dbutils;
-
-import java.sql.ResultSet;
-import java.sql.ResultSetMetaData;
-import java.sql.SQLException;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-
-/**
- * Basic implementation of the <code>RowProcessor</code> interface.
- *
- * <p>
- * This class is thread-safe.
- * </p>
- *
- * @see RowProcessor
- */
-public class BasicRowProcessor implements RowProcessor {
-
- /**
- * The default BeanProcessor instance to use if not supplied in the
- * constructor.
- */
- private static final BeanProcessor defaultConvert = new BeanProcessor();
-
- /**
- * Use this to process beans.
- */
- private final BeanProcessor convert;
-
- /**
- * BasicRowProcessor constructor. Bean processing defaults to a
- * BeanProcessor instance.
- */
- public BasicRowProcessor() {
- this(defaultConvert);
- }
-
- /**
- * BasicRowProcessor constructor.
- * @param convert The BeanProcessor to use when converting columns to
- * bean properties.
- * @since DbUtils 1.1
- */
- public BasicRowProcessor(BeanProcessor convert) {
- super();
- this.convert = convert;
- }
-
- /**
- * Convert a <code>ResultSet</code> row into an <code>Object[]</code>.
- * This implementation copies column values into the array in the same
- * order they're returned from the <code>ResultSet</code>. Array elements
- * will be set to <code>null</code> if the column was SQL NULL.
- *
- * @see org.apache.commons.dbutils.RowProcessor#toArray(java.sql.ResultSet)
- * @param rs ResultSet that supplies the array data
- * @throws SQLException if a database access error occurs
- * @return the newly created array
- */
- @Override
- public Object[] toArray(ResultSet rs) throws SQLException {
- ResultSetMetaData meta = rs.getMetaData();
- int cols = meta.getColumnCount();
- Object[] result = new Object[cols];
-
- for (int i = 0; i < cols; i++) {
- result[i] = rs.getObject(i + 1);
- }
-
- return result;
- }
-
- /**
- * Convert a <code>ResultSet</code> row into a JavaBean. This
- * implementation delegates to a BeanProcessor instance.
- * @see org.apache.commons.dbutils.RowProcessor#toBean(java.sql.ResultSet, java.lang.Class)
- * @see org.apache.commons.dbutils.BeanProcessor#toBean(java.sql.ResultSet, java.lang.Class)
- * @param <T> The type of bean to create
- * @param rs ResultSet that supplies the bean data
- * @param type Class from which to create the bean instance
- * @throws SQLException if a database access error occurs
- * @return the newly created bean
- */
- @Override
- public <T> T toBean(ResultSet rs, Class<T> type) throws SQLException {
- return this.convert.toBean(rs, type);
- }
-
- /**
- * Convert a <code>ResultSet</code> into a <code>List</code> of JavaBeans.
- * This implementation delegates to a BeanProcessor instance.
- * @see org.apache.commons.dbutils.RowProcessor#toBeanList(java.sql.ResultSet, java.lang.Class)
- * @see org.apache.commons.dbutils.BeanProcessor#toBeanList(java.sql.ResultSet, java.lang.Class)
- * @param <T> The type of bean to create
- * @param rs ResultSet that supplies the bean data
- * @param type Class from which to create the bean instance
- * @throws SQLException if a database access error occurs
- * @return A <code>List</code> of beans with the given type in the order
- * they were returned by the <code>ResultSet</code>.
- */
- @Override
- public <T> List<T> toBeanList(ResultSet rs, Class<T> type) throws SQLException {
- return this.convert.toBeanList(rs, type);
- }
-
- /**
- * Convert a <code>ResultSet</code> row into a <code>Map</code>. This
- * implementation returns a <code>Map</code> with case insensitive column
- * names as keys. Calls to <code>map.get("COL")</code> and
- * <code>map.get("col")</code> return the same value.
- * @see org.apache.commons.dbutils.RowProcessor#toMap(java.sql.ResultSet)
- * @param rs ResultSet that supplies the map data
- * @throws SQLException if a database access error occurs
- * @return the newly created Map
- */
- @Override
- public Map<String, Object> toMap(ResultSet rs) throws SQLException {
- Map<String, Object> result = new CaseInsensitiveHashMap();
- ResultSetMetaData rsmd = rs.getMetaData();
- int cols = rsmd.getColumnCount();
-
- for (int i = 1; i <= cols; i++) {
- result.put(rsmd.getColumnName(i), rs.getObject(i));
- }
-
- return result;
- }
-
- /**
- * A Map that converts all keys to lowercase Strings for case insensitive
- * lookups. This is needed for the toMap() implementation because
- * databases don't consistently handle the casing of column names.
- *
- * <p>The keys are stored as they are given [BUG #DBUTILS-34], so we maintain
- * an internal mapping from lowercase keys to the real keys in order to
- * achieve the case insensitive lookup.
- *
- * <p>Note: This implementation does not allow <tt>null</tt>
- * for key, whereas {@link HashMap} does, because of the code:
- * <pre>
- * key.toString().toLowerCase()
- * </pre>
- */
- private static class CaseInsensitiveHashMap extends HashMap<String, Object> {
- /**
- * The internal mapping from lowercase keys to the real keys.
- *
- * <p>
- * Any query operation using the key
- * ({@link #get(Object)}, {@link #containsKey(Object)})
- * is done in three steps:
- * <ul>
- * <li>convert the parameter key to lower case</li>
- * <li>get the actual key that corresponds to the lower case key</li>
- * <li>query the map with the actual key</li>
- * </ul>
- * </p>
- */
- private final Map<String, String> lowerCaseMap = new HashMap<String, String>();
-
- /**
- * Required for serialization support.
- *
- * @see java.io.Serializable
- */
- private static final long serialVersionUID = -2848100435296897392L;
-
- /** {@inheritDoc} */
- @Override
- public boolean containsKey(Object key) {
- Object realKey = lowerCaseMap.get(key.toString().toLowerCase(Locale.ENGLISH));
- return super.containsKey(realKey);
- // Possible optimisation here:
- // Since the lowerCaseMap contains a mapping for all the keys,
- // we could just do this:
- // return lowerCaseMap.containsKey(key.toString().toLowerCase());
- }
-
- /** {@inheritDoc} */
- @Override
- public Object get(Object key) {
- Object realKey = lowerCaseMap.get(key.toString().toLowerCase(Locale.ENGLISH));
- return super.get(realKey);
- }
-
- /** {@inheritDoc} */
- @Override
- public Object put(String key, Object value) {
- /*
- * In order to keep the map and lowerCaseMap synchronized,
- * we have to remove the old mapping before putting the
- * new one. Indeed, oldKey and key are not necessaliry equals.
- * (That's why we call super.remove(oldKey) and not just
- * super.put(key, value))
- */
- Object oldKey = lowerCaseMap.put(key.toLowerCase(Locale.ENGLISH), key);
- Object oldValue = super.remove(oldKey);
- super.put(key, value);
- return oldValue;
- }
-
- /** {@inheritDoc} */
- @Override
- public void putAll(Map<? extends String, ?> m) {
- for (Map.Entry<? extends String, ?> entry : m.entrySet()) {
- String key = entry.getKey();
- Object value = entry.getValue();
- this.put(key, value);
- }
- }
-
- /** {@inheritDoc} */
- @Override
- public Object remove(Object key) {
- Object realKey = lowerCaseMap.remove(key.toString().toLowerCase(Locale.ENGLISH));
- return super.remove(realKey);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/main/java/org/apache/commons/dbutils/BatchExecutor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils/BatchExecutor.java b/src/main/java/org/apache/commons/dbutils/BatchExecutor.java
deleted file mode 100644
index a407455..0000000
--- a/src/main/java/org/apache/commons/dbutils/BatchExecutor.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.dbutils;
-
-import java.sql.Connection;
-import java.sql.SQLException;
-import java.sql.Types;
-
-/**
- * This class provides the ability to execute a batch of statements.
- *
- * It is really just a facade to an array of UpdateExecutors.
- *
- * @author William Speirs <ws...@apache.org>
- */
-public class BatchExecutor extends AbstractExecutor<BatchExecutor> {
-
- private final boolean closeConn;
-
- public BatchExecutor(final Connection conn, final String sql, final boolean closeConnection) throws SQLException {
- super(conn, sql);
- this.closeConn = closeConnection;
- }
-
- /**
- * Binds a parameter name to a value for a given statement.
- * @param statement the statement number to operate on.
- * @param name the name of the parameter.
- * @param value the value to bind to the parameter.
- * @return this object.
- * @throws SQLException thrown if the statement number does not exist, or any other SQLException.
- * @see org.apache.commons.dbutils.UpdateExecutor.bind(String, Object)
- */
- @Override
- public BatchExecutor bind(final String name, final Object value) throws SQLException {
- return bind(name, value, false);
- }
-
- /**
- * Binds null to a parameter.
- * Types.VARCHAR is used as the type's parameter.
- * This usually works, but fails with some Oracle and MS SQL drivers.
- * @param name the name of the parameter.
- * @return this execution object to provide the fluent style.
- * @throws SQLException throw if the parameter is not found, already bound, or there is an issue binding null.
- */
- @Override
- public BatchExecutor bindNull(final String name) throws SQLException {
- return bindNull(name, Types.VARCHAR, false);
- }
-
- /**
- * Binds null to a parameter, specifying the parameter's type.
- * @param name the name of the parameter.
- * @param sqlType the type of the parameter.
- * @return this execution object to provide the fluent style.
- * @throws SQLException throw if the parameter is not found, already bound, or there is an issue binding null.
- */
- @Override
- public BatchExecutor bindNull(final String name, final int sqlType) throws SQLException {
- return bindNull(name, sqlType, false);
- }
-
- /**
- * Adds the statement to the batch after binding all of the parameters.
- * @return this object.
- * @throws SQLException if a SQLException is thrown during the addBatch() call.
- * @see java.sql.PreparedStatement.addBatch()
- */
- public BatchExecutor addBatch() throws SQLException {
- try {
- getStatement().addBatch();
- clearValueMap();
- } catch(SQLException e) {
- rethrow(e);
- }
-
- return this;
- }
-
- /**
- * Calls batch after checking the parameters to ensure nothing is null.
- * @return an array containing the number of rows updated for each statement.
- * @throws SQLException If there are database or parameter errors.
- * @see org.apache.commons.dbutils.UpdateExecutor.update()
- */
- public int[] execute() throws SQLException {
- try {
- return getStatement().executeBatch();
- } catch (SQLException e) {
- rethrow(e);
- } finally {
- close(getStatement());
- if (closeConn) {
- close(getConnection());
- }
- }
-
- // we get here only if something is thrown
- return null;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/main/java/org/apache/commons/dbutils/BeanProcessor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils/BeanProcessor.java b/src/main/java/org/apache/commons/dbutils/BeanProcessor.java
deleted file mode 100644
index 5f3a6d1..0000000
--- a/src/main/java/org/apache/commons/dbutils/BeanProcessor.java
+++ /dev/null
@@ -1,504 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.dbutils;
-
-import java.beans.BeanInfo;
-import java.beans.IntrospectionException;
-import java.beans.Introspector;
-import java.beans.PropertyDescriptor;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.sql.ResultSet;
-import java.sql.ResultSetMetaData;
-import java.sql.SQLException;
-import java.sql.SQLXML;
-import java.sql.Timestamp;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * <p>
- * <code>BeanProcessor</code> matches column names to bean property names
- * and converts <code>ResultSet</code> columns into objects for those bean
- * properties. Subclasses should override the methods in the processing chain
- * to customize behavior.
- * </p>
- *
- * <p>
- * This class is thread-safe.
- * </p>
- *
- * @see BasicRowProcessor
- *
- * @since DbUtils 1.1
- */
-public class BeanProcessor {
-
- /**
- * Special array value used by <code>mapColumnsToProperties</code> that
- * indicates there is no bean property that matches a column from a
- * <code>ResultSet</code>.
- */
- protected static final int PROPERTY_NOT_FOUND = -1;
-
- /**
- * Set a bean's primitive properties to these defaults when SQL NULL
- * is returned. These are the same as the defaults that ResultSet get*
- * methods return in the event of a NULL column.
- */
- private static final Map<Class<?>, Object> primitiveDefaults = new HashMap<Class<?>, Object>();
-
- /**
- * ResultSet column to bean property name overrides.
- */
- private final Map<String, String> columnToPropertyOverrides;
-
- static {
- primitiveDefaults.put(Integer.TYPE, Integer.valueOf(0));
- primitiveDefaults.put(Short.TYPE, Short.valueOf((short) 0));
- primitiveDefaults.put(Byte.TYPE, Byte.valueOf((byte) 0));
- primitiveDefaults.put(Float.TYPE, Float.valueOf(0f));
- primitiveDefaults.put(Double.TYPE, Double.valueOf(0d));
- primitiveDefaults.put(Long.TYPE, Long.valueOf(0L));
- primitiveDefaults.put(Boolean.TYPE, Boolean.FALSE);
- primitiveDefaults.put(Character.TYPE, Character.valueOf((char) 0));
- }
-
- /**
- * Constructor for BeanProcessor.
- */
- public BeanProcessor() {
- this(new HashMap<String, String>());
- }
-
- /**
- * Constructor for BeanProcessor configured with column to property name overrides.
- *
- * @param columnToPropertyOverrides ResultSet column to bean property name overrides
- * @since 1.5
- */
- public BeanProcessor(Map<String, String> columnToPropertyOverrides) {
- super();
- if (columnToPropertyOverrides == null) {
- throw new IllegalArgumentException("columnToPropertyOverrides map cannot be null");
- }
- this.columnToPropertyOverrides = columnToPropertyOverrides;
- }
-
- /**
- * Convert a <code>ResultSet</code> row into a JavaBean. This
- * implementation uses reflection and <code>BeanInfo</code> classes to
- * match column names to bean property names. Properties are matched to
- * columns based on several factors:
- * <br/>
- * <ol>
- * <li>
- * The class has a writable property with the same name as a column.
- * The name comparison is case insensitive.
- * </li>
- *
- * <li>
- * The column type can be converted to the property's set method
- * parameter type with a ResultSet.get* method. If the conversion fails
- * (ie. the property was an int and the column was a Timestamp) an
- * SQLException is thrown.
- * </li>
- * </ol>
- *
- * <p>
- * Primitive bean properties are set to their defaults when SQL NULL is
- * returned from the <code>ResultSet</code>. Numeric fields are set to 0
- * and booleans are set to false. Object bean properties are set to
- * <code>null</code> when SQL NULL is returned. This is the same behavior
- * as the <code>ResultSet</code> get* methods.
- * </p>
- * @param <T> The type of bean to create
- * @param rs ResultSet that supplies the bean data
- * @param type Class from which to create the bean instance
- * @throws SQLException if a database access error occurs
- * @return the newly created bean
- */
- public <T> T toBean(ResultSet rs, Class<T> type) throws SQLException {
-
- PropertyDescriptor[] props = this.propertyDescriptors(type);
-
- ResultSetMetaData rsmd = rs.getMetaData();
- int[] columnToProperty = this.mapColumnsToProperties(rsmd, props);
-
- return this.createBean(rs, type, props, columnToProperty);
- }
-
- /**
- * Convert a <code>ResultSet</code> into a <code>List</code> of JavaBeans.
- * This implementation uses reflection and <code>BeanInfo</code> classes to
- * match column names to bean property names. Properties are matched to
- * columns based on several factors:
- * <br/>
- * <ol>
- * <li>
- * The class has a writable property with the same name as a column.
- * The name comparison is case insensitive.
- * </li>
- *
- * <li>
- * The column type can be converted to the property's set method
- * parameter type with a ResultSet.get* method. If the conversion fails
- * (ie. the property was an int and the column was a Timestamp) an
- * SQLException is thrown.
- * </li>
- * </ol>
- *
- * <p>
- * Primitive bean properties are set to their defaults when SQL NULL is
- * returned from the <code>ResultSet</code>. Numeric fields are set to 0
- * and booleans are set to false. Object bean properties are set to
- * <code>null</code> when SQL NULL is returned. This is the same behavior
- * as the <code>ResultSet</code> get* methods.
- * </p>
- * @param <T> The type of bean to create
- * @param rs ResultSet that supplies the bean data
- * @param type Class from which to create the bean instance
- * @throws SQLException if a database access error occurs
- * @return the newly created List of beans
- */
- public <T> List<T> toBeanList(ResultSet rs, Class<T> type) throws SQLException {
- List<T> results = new ArrayList<T>();
-
- if (!rs.next()) {
- return results;
- }
-
- PropertyDescriptor[] props = this.propertyDescriptors(type);
- ResultSetMetaData rsmd = rs.getMetaData();
- int[] columnToProperty = this.mapColumnsToProperties(rsmd, props);
-
- do {
- results.add(this.createBean(rs, type, props, columnToProperty));
- } while (rs.next());
-
- return results;
- }
-
- /**
- * Creates a new object and initializes its fields from the ResultSet.
- * @param <T> The type of bean to create
- * @param rs The result set.
- * @param type The bean type (the return type of the object).
- * @param props The property descriptors.
- * @param columnToProperty The column indices in the result set.
- * @return An initialized object.
- * @throws SQLException if a database error occurs.
- */
- private <T> T createBean(ResultSet rs, Class<T> type,
- PropertyDescriptor[] props, int[] columnToProperty)
- throws SQLException {
-
- T bean = this.newInstance(type);
-
- for (int i = 1; i < columnToProperty.length; i++) {
-
- if (columnToProperty[i] == PROPERTY_NOT_FOUND) {
- continue;
- }
-
- PropertyDescriptor prop = props[columnToProperty[i]];
- Class<?> propType = prop.getPropertyType();
-
- Object value = this.processColumn(rs, i, propType);
-
- if (propType != null && value == null && propType.isPrimitive()) {
- value = primitiveDefaults.get(propType);
- }
-
- this.callSetter(bean, prop, value);
- }
-
- return bean;
- }
-
- /**
- * Calls the setter method on the target object for the given property.
- * If no setter method exists for the property, this method does nothing.
- * @param target The object to set the property on.
- * @param prop The property to set.
- * @param value The value to pass into the setter.
- * @throws SQLException if an error occurs setting the property.
- */
- private void callSetter(Object target, PropertyDescriptor prop, Object value)
- throws SQLException {
-
- Method setter = prop.getWriteMethod();
-
- if (setter == null) {
- return;
- }
-
- Class<?>[] params = setter.getParameterTypes();
- try {
- // convert types for some popular ones
- if (value instanceof java.util.Date) {
- final String targetType = params[0].getName();
- if ("java.sql.Date".equals(targetType)) {
- value = new java.sql.Date(((java.util.Date) value).getTime());
- } else
- if ("java.sql.Time".equals(targetType)) {
- value = new java.sql.Time(((java.util.Date) value).getTime());
- } else
- if ("java.sql.Timestamp".equals(targetType)) {
- value = new java.sql.Timestamp(((java.util.Date) value).getTime());
- }
- }
-
- // Don't call setter if the value object isn't the right type
- if (this.isCompatibleType(value, params[0])) {
- setter.invoke(target, new Object[]{value});
- } else {
- throw new SQLException(
- "Cannot set " + prop.getName() + ": incompatible types, cannot convert "
- + value.getClass().getName() + " to " + params[0].getName());
- // value cannot be null here because isCompatibleType allows null
- }
-
- } catch (IllegalArgumentException e) {
- throw new SQLException(
- "Cannot set " + prop.getName() + ": " + e.getMessage());
-
- } catch (IllegalAccessException e) {
- throw new SQLException(
- "Cannot set " + prop.getName() + ": " + e.getMessage());
-
- } catch (InvocationTargetException e) {
- throw new SQLException(
- "Cannot set " + prop.getName() + ": " + e.getMessage());
- }
- }
-
- /**
- * ResultSet.getObject() returns an Integer object for an INT column. The
- * setter method for the property might take an Integer or a primitive int.
- * This method returns true if the value can be successfully passed into
- * the setter method. Remember, Method.invoke() handles the unwrapping
- * of Integer into an int.
- *
- * @param value The value to be passed into the setter method.
- * @param type The setter's parameter type (non-null)
- * @return boolean True if the value is compatible (null => true)
- */
- private boolean isCompatibleType(Object value, Class<?> type) {
- // Do object check first, then primitives
- if (value == null || type.isInstance(value)) {
- return true;
-
- } else if (type.equals(Integer.TYPE) && Integer.class.isInstance(value)) {
- return true;
-
- } else if (type.equals(Long.TYPE) && Long.class.isInstance(value)) {
- return true;
-
- } else if (type.equals(Double.TYPE) && Double.class.isInstance(value)) {
- return true;
-
- } else if (type.equals(Float.TYPE) && Float.class.isInstance(value)) {
- return true;
-
- } else if (type.equals(Short.TYPE) && Short.class.isInstance(value)) {
- return true;
-
- } else if (type.equals(Byte.TYPE) && Byte.class.isInstance(value)) {
- return true;
-
- } else if (type.equals(Character.TYPE) && Character.class.isInstance(value)) {
- return true;
-
- } else if (type.equals(Boolean.TYPE) && Boolean.class.isInstance(value)) {
- return true;
-
- }
- return false;
-
- }
-
- /**
- * Factory method that returns a new instance of the given Class. This
- * is called at the start of the bean creation process and may be
- * overridden to provide custom behavior like returning a cached bean
- * instance.
- * @param <T> The type of object to create
- * @param c The Class to create an object from.
- * @return A newly created object of the Class.
- * @throws SQLException if creation failed.
- */
- protected <T> T newInstance(Class<T> c) throws SQLException {
- try {
- return c.newInstance();
-
- } catch (InstantiationException e) {
- throw new SQLException(
- "Cannot create " + c.getName() + ": " + e.getMessage());
-
- } catch (IllegalAccessException e) {
- throw new SQLException(
- "Cannot create " + c.getName() + ": " + e.getMessage());
- }
- }
-
- /**
- * Returns a PropertyDescriptor[] for the given Class.
- *
- * @param c The Class to retrieve PropertyDescriptors for.
- * @return A PropertyDescriptor[] describing the Class.
- * @throws SQLException if introspection failed.
- */
- private PropertyDescriptor[] propertyDescriptors(Class<?> c)
- throws SQLException {
- // Introspector caches BeanInfo classes for better performance
- BeanInfo beanInfo = null;
- try {
- beanInfo = Introspector.getBeanInfo(c);
-
- } catch (IntrospectionException e) {
- throw new SQLException(
- "Bean introspection failed: " + e.getMessage());
- }
-
- return beanInfo.getPropertyDescriptors();
- }
-
- /**
- * The positions in the returned array represent column numbers. The
- * values stored at each position represent the index in the
- * <code>PropertyDescriptor[]</code> for the bean property that matches
- * the column name. If no bean property was found for a column, the
- * position is set to <code>PROPERTY_NOT_FOUND</code>.
- *
- * @param rsmd The <code>ResultSetMetaData</code> containing column
- * information.
- *
- * @param props The bean property descriptors.
- *
- * @throws SQLException if a database access error occurs
- *
- * @return An int[] with column index to property index mappings. The 0th
- * element is meaningless because JDBC column indexing starts at 1.
- */
- protected int[] mapColumnsToProperties(ResultSetMetaData rsmd,
- PropertyDescriptor[] props) throws SQLException {
-
- int cols = rsmd.getColumnCount();
- int[] columnToProperty = new int[cols + 1];
- Arrays.fill(columnToProperty, PROPERTY_NOT_FOUND);
-
- for (int col = 1; col <= cols; col++) {
- String columnName = rsmd.getColumnLabel(col);
- if (null == columnName || 0 == columnName.length()) {
- columnName = rsmd.getColumnName(col);
- }
- String propertyName = columnToPropertyOverrides.get(columnName);
- if (propertyName == null) {
- propertyName = columnName;
- }
- for (int i = 0; i < props.length; i++) {
-
- if (propertyName.equalsIgnoreCase(props[i].getName())) {
- columnToProperty[col] = i;
- break;
- }
- }
- }
-
- return columnToProperty;
- }
-
- /**
- * Convert a <code>ResultSet</code> column into an object. Simple
- * implementations could just call <code>rs.getObject(index)</code> while
- * more complex implementations could perform type manipulation to match
- * the column's type to the bean property type.
- *
- * <p>
- * This implementation calls the appropriate <code>ResultSet</code> getter
- * method for the given property type to perform the type conversion. If
- * the property type doesn't match one of the supported
- * <code>ResultSet</code> types, <code>getObject</code> is called.
- * </p>
- *
- * @param rs The <code>ResultSet</code> currently being processed. It is
- * positioned on a valid row before being passed into this method.
- *
- * @param index The current column index being processed.
- *
- * @param propType The bean property type that this column needs to be
- * converted into.
- *
- * @throws SQLException if a database access error occurs
- *
- * @return The object from the <code>ResultSet</code> at the given column
- * index after optional type processing or <code>null</code> if the column
- * value was SQL NULL.
- */
- protected Object processColumn(ResultSet rs, int index, Class<?> propType)
- throws SQLException {
-
- if ( !propType.isPrimitive() && rs.getObject(index) == null ) {
- return null;
- }
-
- if (propType.equals(String.class)) {
- return rs.getString(index);
-
- } else if (
- propType.equals(Integer.TYPE) || propType.equals(Integer.class)) {
- return Integer.valueOf(rs.getInt(index));
-
- } else if (
- propType.equals(Boolean.TYPE) || propType.equals(Boolean.class)) {
- return Boolean.valueOf(rs.getBoolean(index));
-
- } else if (propType.equals(Long.TYPE) || propType.equals(Long.class)) {
- return Long.valueOf(rs.getLong(index));
-
- } else if (
- propType.equals(Double.TYPE) || propType.equals(Double.class)) {
- return Double.valueOf(rs.getDouble(index));
-
- } else if (
- propType.equals(Float.TYPE) || propType.equals(Float.class)) {
- return Float.valueOf(rs.getFloat(index));
-
- } else if (
- propType.equals(Short.TYPE) || propType.equals(Short.class)) {
- return Short.valueOf(rs.getShort(index));
-
- } else if (propType.equals(Byte.TYPE) || propType.equals(Byte.class)) {
- return Byte.valueOf(rs.getByte(index));
-
- } else if (propType.equals(Timestamp.class)) {
- return rs.getTimestamp(index);
-
- } else if (propType.equals(SQLXML.class)) {
- return rs.getSQLXML(index);
-
- } else {
- return rs.getObject(index);
- }
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/main/java/org/apache/commons/dbutils/DbUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils/DbUtils.java b/src/main/java/org/apache/commons/dbutils/DbUtils.java
deleted file mode 100644
index fbed34e..0000000
--- a/src/main/java/org/apache/commons/dbutils/DbUtils.java
+++ /dev/null
@@ -1,406 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.dbutils;
-
-import static java.sql.DriverManager.registerDriver;
-import java.io.PrintWriter;
-import java.lang.reflect.Constructor;
-import java.sql.Connection;
-import java.sql.Driver;
-import java.sql.DriverPropertyInfo;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.SQLFeatureNotSupportedException;
-import java.sql.Statement;
-import java.util.Properties;
-import java.util.logging.Logger;
-
-/**
- * A collection of JDBC helper methods. This class is thread safe.
- */
-public final class DbUtils {
-
- /**
- * Utility classes do not have a public default constructor.
- *
- * @since 1.4
- */
- private DbUtils() {
- // do nothing
- }
-
- /**
- * Close a <code>Connection</code>, avoid closing if null.
- *
- * @param conn Connection to close.
- * @throws SQLException if a database access error occurs
- */
- public static void close(Connection conn) throws SQLException {
- if (conn != null) {
- conn.close();
- }
- }
-
- /**
- * Close a <code>ResultSet</code>, avoid closing if null.
- *
- * @param rs ResultSet to close.
- * @throws SQLException if a database access error occurs
- */
- public static void close(ResultSet rs) throws SQLException {
- if (rs != null) {
- rs.close();
- }
- }
-
- /**
- * Close a <code>Statement</code>, avoid closing if null.
- *
- * @param stmt Statement to close.
- * @throws SQLException if a database access error occurs
- */
- public static void close(Statement stmt) throws SQLException {
- if (stmt != null) {
- stmt.close();
- }
- }
-
- /**
- * Close a <code>Connection</code>, avoid closing if null and hide
- * any SQLExceptions that occur.
- *
- * @param conn Connection to close.
- */
- public static void closeQuietly(Connection conn) {
- try {
- close(conn);
- } catch (SQLException e) { // NOPMD
- // quiet
- }
- }
-
- /**
- * Close a <code>Connection</code>, <code>Statement</code> and
- * <code>ResultSet</code>. Avoid closing if null and hide any
- * SQLExceptions that occur.
- *
- * @param conn Connection to close.
- * @param stmt Statement to close.
- * @param rs ResultSet to close.
- */
- public static void closeQuietly(Connection conn, Statement stmt,
- ResultSet rs) {
-
- try {
- closeQuietly(rs);
- } finally {
- try {
- closeQuietly(stmt);
- } finally {
- closeQuietly(conn);
- }
- }
-
- }
-
- /**
- * Close a <code>ResultSet</code>, avoid closing if null and hide any
- * SQLExceptions that occur.
- *
- * @param rs ResultSet to close.
- */
- public static void closeQuietly(ResultSet rs) {
- try {
- close(rs);
- } catch (SQLException e) { // NOPMD
- // quiet
- }
- }
-
- /**
- * Close a <code>Statement</code>, avoid closing if null and hide
- * any SQLExceptions that occur.
- *
- * @param stmt Statement to close.
- */
- public static void closeQuietly(Statement stmt) {
- try {
- close(stmt);
- } catch (SQLException e) { // NOPMD
- // quiet
- }
- }
-
- /**
- * Commits a <code>Connection</code> then closes it, avoid closing if null.
- *
- * @param conn Connection to close.
- * @throws SQLException if a database access error occurs
- */
- public static void commitAndClose(Connection conn) throws SQLException {
- if (conn != null) {
- try {
- conn.commit();
- } finally {
- conn.close();
- }
- }
- }
-
- /**
- * Commits a <code>Connection</code> then closes it, avoid closing if null
- * and hide any SQLExceptions that occur.
- *
- * @param conn Connection to close.
- */
- public static void commitAndCloseQuietly(Connection conn) {
- try {
- commitAndClose(conn);
- } catch (SQLException e) { // NOPMD
- // quiet
- }
- }
-
- /**
- * Loads and registers a database driver class.
- * If this succeeds, it returns true, else it returns false.
- *
- * @param driverClassName of driver to load
- * @return boolean <code>true</code> if the driver was found, otherwise <code>false</code>
- */
- public static boolean loadDriver(String driverClassName) {
- return loadDriver(DbUtils.class.getClassLoader(), driverClassName);
- }
-
- /**
- * Loads and registers a database driver class.
- * If this succeeds, it returns true, else it returns false.
- *
- * @param classLoader the class loader used to load the driver class
- * @param driverClassName of driver to load
- * @return boolean <code>true</code> if the driver was found, otherwise <code>false</code>
- * @since 1.4
- */
- public static boolean loadDriver(ClassLoader classLoader, String driverClassName) {
- try {
- Class<?> loadedClass = classLoader.loadClass(driverClassName);
-
- if (!Driver.class.isAssignableFrom(loadedClass)) {
- return false;
- }
-
- @SuppressWarnings("unchecked") // guarded by previous check
- Class<Driver> driverClass = (Class<Driver>) loadedClass;
- Constructor<Driver> driverConstructor = driverClass.getConstructor();
-
- // make Constructor accessible if it is private
- boolean isConstructorAccessible = driverConstructor.isAccessible();
- if (!isConstructorAccessible) {
- driverConstructor.setAccessible(true);
- }
-
- try {
- Driver driver = driverConstructor.newInstance();
- registerDriver(new DriverProxy(driver));
- } finally {
- driverConstructor.setAccessible(isConstructorAccessible);
- }
-
- return true;
- } catch (Exception e) {
- return false;
-
- }
- }
-
- /**
- * Print the stack trace for a SQLException to STDERR.
- *
- * @param e SQLException to print stack trace of
- */
- public static void printStackTrace(SQLException e) {
- printStackTrace(e, new PrintWriter(System.err));
- }
-
- /**
- * Print the stack trace for a SQLException to a
- * specified PrintWriter.
- *
- * @param e SQLException to print stack trace of
- * @param pw PrintWriter to print to
- */
- public static void printStackTrace(SQLException e, PrintWriter pw) {
-
- SQLException next = e;
- while (next != null) {
- next.printStackTrace(pw);
- next = next.getNextException();
- if (next != null) {
- pw.println("Next SQLException:");
- }
- }
- }
-
- /**
- * Print warnings on a Connection to STDERR.
- *
- * @param conn Connection to print warnings from
- */
- public static void printWarnings(Connection conn) {
- printWarnings(conn, new PrintWriter(System.err));
- }
-
- /**
- * Print warnings on a Connection to a specified PrintWriter.
- *
- * @param conn Connection to print warnings from
- * @param pw PrintWriter to print to
- */
- public static void printWarnings(Connection conn, PrintWriter pw) {
- if (conn != null) {
- try {
- printStackTrace(conn.getWarnings(), pw);
- } catch (SQLException e) {
- printStackTrace(e, pw);
- }
- }
- }
-
- /**
- * Rollback any changes made on the given connection.
- * @param conn Connection to rollback. A null value is legal.
- * @throws SQLException if a database access error occurs
- */
- public static void rollback(Connection conn) throws SQLException {
- if (conn != null) {
- conn.rollback();
- }
- }
-
- /**
- * Performs a rollback on the <code>Connection</code> then closes it,
- * avoid closing if null.
- *
- * @param conn Connection to rollback. A null value is legal.
- * @throws SQLException if a database access error occurs
- * @since DbUtils 1.1
- */
- public static void rollbackAndClose(Connection conn) throws SQLException {
- if (conn != null) {
- try {
- conn.rollback();
- } finally {
- conn.close();
- }
- }
- }
-
- /**
- * Performs a rollback on the <code>Connection</code> then closes it,
- * avoid closing if null and hide any SQLExceptions that occur.
- *
- * @param conn Connection to rollback. A null value is legal.
- * @since DbUtils 1.1
- */
- public static void rollbackAndCloseQuietly(Connection conn) {
- try {
- rollbackAndClose(conn);
- } catch (SQLException e) { // NOPMD
- // quiet
- }
- }
-
- /**
- * Simple {@link Driver} proxy class that proxies a JDBC Driver loaded dynamically.
- *
- * @since 1.6
- */
- private static final class DriverProxy implements Driver {
-
- /**
- * The adapted JDBC Driver loaded dynamically.
- */
- private final Driver adapted;
-
- /**
- * Creates a new JDBC Driver that adapts a JDBC Driver loaded dynamically.
- *
- * @param adapted the adapted JDBC Driver loaded dynamically.
- */
- public DriverProxy(Driver adapted) {
- this.adapted = adapted;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean acceptsURL(String url) throws SQLException {
- return adapted.acceptsURL(url);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Connection connect(String url, Properties info) throws SQLException {
- return adapted.connect(url, info);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int getMajorVersion() {
- return adapted.getMajorVersion();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int getMinorVersion() {
- return adapted.getMinorVersion();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException {
- return adapted.getPropertyInfo(url, info);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean jdbcCompliant() {
- return adapted.jdbcCompliant();
- }
-
- /**
- * Java 1.7 method.
- */
- @SuppressWarnings("unused")
- public Logger getParentLogger() throws SQLFeatureNotSupportedException {
- throw new SQLFeatureNotSupportedException();
- }
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/main/java/org/apache/commons/dbutils/GenerousBeanProcessor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils/GenerousBeanProcessor.java b/src/main/java/org/apache/commons/dbutils/GenerousBeanProcessor.java
deleted file mode 100644
index 8dccee7..0000000
--- a/src/main/java/org/apache/commons/dbutils/GenerousBeanProcessor.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.dbutils;
-
-
-import java.beans.PropertyDescriptor;
-import java.sql.ResultSetMetaData;
-import java.sql.SQLException;
-import java.util.Arrays;
-
-
-/**
- * Provides generous name matching (e.g. underscore-aware) from DB
- * columns to Java Bean properties.
- */
-public class GenerousBeanProcessor extends BeanProcessor {
-
- /**
- * Default constructor.
- */
- public GenerousBeanProcessor() {
- super();
- }
-
- @Override
- protected int[] mapColumnsToProperties(final ResultSetMetaData rsmd,
- final PropertyDescriptor[] props) throws SQLException {
-
- final int cols = rsmd.getColumnCount();
- final int[] columnToProperty = new int[cols + 1];
- Arrays.fill(columnToProperty, PROPERTY_NOT_FOUND);
-
- for (int col = 1; col <= cols; col++) {
- String columnName = rsmd.getColumnLabel(col);
-
- if (null == columnName || 0 == columnName.length()) {
- columnName = rsmd.getColumnName(col);
- }
-
- final String generousColumnName = columnName.replace("_","");
-
- for (int i = 0; i < props.length; i++) {
- final String propName = props[i].getName();
-
- // see if either the column name, or the generous one matches
- if (columnName.equalsIgnoreCase(propName) ||
- generousColumnName.equalsIgnoreCase(propName)) {
- columnToProperty[col] = i;
- break;
- }
- }
- }
-
- return columnToProperty;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/main/java/org/apache/commons/dbutils/InsertExecutor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils/InsertExecutor.java b/src/main/java/org/apache/commons/dbutils/InsertExecutor.java
deleted file mode 100644
index a3a9898..0000000
--- a/src/main/java/org/apache/commons/dbutils/InsertExecutor.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.dbutils;
-
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-
-public class InsertExecutor extends AbstractExecutor<InsertExecutor> {
-
- private final boolean closeConn;
-
- public InsertExecutor(final Connection conn, final String sql, final boolean closeConnection) throws SQLException {
- super(conn, sql);
- this.closeConn = closeConnection;
- }
-
- /**
- * Executes the given INSERT SQL statement.
- *
- * @param handler The handler used to create the result object from
- * the <code>ResultSet</code> of auto-generated keys.
- *
- * @return An object generated by the handler.
- * @throws SQLException If there are database or parameter errors.
- */
- public <T> T execute(ResultSetHandler<T> handler) throws SQLException {
- // throw an exception if there are unmapped parameters
- this.throwIfUnmappedParams();
-
- // make sure our handler is not null
- if (handler == null) {
- if (closeConn) {
- close(getConnection());
- }
- throw new SQLException("Null ResultSetHandler");
- }
-
- try {
- // execute the update
- getStatement().executeUpdate();
-
- // get the result set
- final ResultSet resultSet = getStatement().getGeneratedKeys();
-
- // run the handler over the results and return them
- return handler.handle(resultSet);
- } catch (SQLException e) {
- this.rethrow(e);
- } finally {
- close(getStatement());
- if (closeConn) {
- close(getConnection());
- }
- }
-
- // we get here only if something is thrown
- return null;
- }
-
- /**
- * Executes the given INSERT SQL statement.
- * @return the number of rows updated.
- * @throws SQLException If there are database or parameter errors.
- */
- public int execute() throws SQLException {
- // throw an exception if there are unmapped parameters
- this.throwIfUnmappedParams();
-
- try {
- // execute the insert
- return getStatement().executeUpdate();
- } catch (SQLException e) {
- this.rethrow(e);
- } finally {
- close(getStatement());
- if (closeConn) {
- close(getConnection());
- }
- }
-
- return 0; // only get here on an error
- }
-
-}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/main/java/org/apache/commons/dbutils/ProxyFactory.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils/ProxyFactory.java b/src/main/java/org/apache/commons/dbutils/ProxyFactory.java
deleted file mode 100644
index 3a212e1..0000000
--- a/src/main/java/org/apache/commons/dbutils/ProxyFactory.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.dbutils;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Proxy;
-import java.sql.CallableStatement;
-import java.sql.Connection;
-import java.sql.Driver;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.ResultSetMetaData;
-import java.sql.Statement;
-
-/**
- * Creates proxy implementations of JDBC interfaces. This avoids
- * incompatibilities between the JDBC 2 and JDBC 3 interfaces. This class is
- * thread safe.
- *
- * @see java.lang.reflect.Proxy
- * @see java.lang.reflect.InvocationHandler
- */
-public class ProxyFactory {
-
- /**
- * The Singleton instance of this class.
- */
- private static final ProxyFactory instance = new ProxyFactory();
-
- /**
- * Returns the Singleton instance of this class.
- *
- * @return singleton instance
- */
- public static ProxyFactory instance() {
- return instance;
- }
-
- /**
- * Protected constructor for ProxyFactory subclasses to use.
- */
- protected ProxyFactory() {
- super();
- }
-
- /**
- * Convenience method to generate a single-interface proxy using the handler's classloader
- *
- * @param <T> The type of object to proxy
- * @param type The type of object to proxy
- * @param handler The handler that intercepts/overrides method calls.
- * @return proxied object
- */
- public <T> T newProxyInstance(Class<T> type, InvocationHandler handler) {
- return type.cast(Proxy.newProxyInstance(handler.getClass().getClassLoader(), new Class<?>[] {type}, handler));
- }
-
- /**
- * Creates a new proxy <code>CallableStatement</code> object.
- * @param handler The handler that intercepts/overrides method calls.
- * @return proxied CallableStatement
- */
- public CallableStatement createCallableStatement(InvocationHandler handler) {
- return newProxyInstance(CallableStatement.class, handler);
- }
-
- /**
- * Creates a new proxy <code>Connection</code> object.
- * @param handler The handler that intercepts/overrides method calls.
- * @return proxied Connection
- */
- public Connection createConnection(InvocationHandler handler) {
- return newProxyInstance(Connection.class, handler);
- }
-
- /**
- * Creates a new proxy <code>Driver</code> object.
- * @param handler The handler that intercepts/overrides method calls.
- * @return proxied Driver
- */
- public Driver createDriver(InvocationHandler handler) {
- return newProxyInstance(Driver.class, handler);
- }
-
- /**
- * Creates a new proxy <code>PreparedStatement</code> object.
- * @param handler The handler that intercepts/overrides method calls.
- * @return proxied PreparedStatement
- */
- public PreparedStatement createPreparedStatement(InvocationHandler handler) {
- return newProxyInstance(PreparedStatement.class, handler);
- }
-
- /**
- * Creates a new proxy <code>ResultSet</code> object.
- * @param handler The handler that intercepts/overrides method calls.
- * @return proxied ResultSet
- */
- public ResultSet createResultSet(InvocationHandler handler) {
- return newProxyInstance(ResultSet.class, handler);
- }
-
- /**
- * Creates a new proxy <code>ResultSetMetaData</code> object.
- * @param handler The handler that intercepts/overrides method calls.
- * @return proxied ResultSetMetaData
- */
- public ResultSetMetaData createResultSetMetaData(InvocationHandler handler) {
- return newProxyInstance(ResultSetMetaData.class, handler);
- }
-
- /**
- * Creates a new proxy <code>Statement</code> object.
- * @param handler The handler that intercepts/overrides method calls.
- * @return proxied Statement
- */
- public Statement createStatement(InvocationHandler handler) {
- return newProxyInstance(Statement.class, handler);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/main/java/org/apache/commons/dbutils/QueryExecutor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils/QueryExecutor.java b/src/main/java/org/apache/commons/dbutils/QueryExecutor.java
deleted file mode 100644
index 9f13bb0..0000000
--- a/src/main/java/org/apache/commons/dbutils/QueryExecutor.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.dbutils;
-
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-/**
- * Fluent class for executing a query.
- *
- * @since 2.0
- * @author William Speirs <ws...@apache.org>
- */
-class QueryExecutor extends AbstractExecutor<QueryExecutor> {
-
- private final boolean closeConn;
-
- public QueryExecutor(final Connection conn, final String sql, final boolean closeConnection) throws SQLException {
- super(conn, sql);
- this.closeConn = closeConnection;
- }
-
- /**
- * Calls query after checking the parameters to ensure nothing is null.
- *
- * @param rsh The handler that converts the results into an object.
- *
- * @return The results of the query.
- * @throws SQLException If there are database or parameter errors.
- */
- public <T> T execute(ResultSetHandler<T> handler) throws SQLException {
- // throw an exception if there are unmapped parameters
- this.throwIfUnmappedParams();
-
- // make sure our handler is not null
- if (handler == null) {
- if (closeConn) {
- close(getConnection());
- }
- throw new SQLException("Null ResultSetHandler");
- }
-
- ResultSet resultSet = null;
-
- try {
- // execute the query, wrapping it
- resultSet = this.wrap(getStatement().executeQuery());
- // execute the handler
- return handler.handle(resultSet);
- } catch (SQLException e) {
- // rethrow our exception printing more information
- this.rethrow(e);
- } finally {
- try {
- close(resultSet);
- } finally {
- close(getStatement());
- if (closeConn) {
- close(getConnection());
- }
- }
- }
-
- // we get here only if something is thrown
- return null;
- }
-}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/main/java/org/apache/commons/dbutils/QueryLoader.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils/QueryLoader.java b/src/main/java/org/apache/commons/dbutils/QueryLoader.java
deleted file mode 100644
index e19d08b..0000000
--- a/src/main/java/org/apache/commons/dbutils/QueryLoader.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.dbutils;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-
-/**
- * <code>QueryLoader</code> is a registry for sets of queries so
- * that multiple copies of the same queries aren't loaded into memory.
- * This implementation loads properties files filled with query name to
- * SQL mappings. This class is thread safe.
- */
-public class QueryLoader {
-
- /**
- * The Singleton instance of this class.
- */
- private static final QueryLoader instance = new QueryLoader();
-
- /**
- * Return an instance of this class.
- * @return The Singleton instance.
- */
- public static QueryLoader instance() {
- return instance;
- }
-
- /**
- * Maps query set names to Maps of their queries.
- */
- private final Map<String, Map<String, String>> queries = new HashMap<String, Map<String, String>>();
-
- /**
- * QueryLoader constructor.
- */
- protected QueryLoader() {
- super();
- }
-
- /**
- * Loads a Map of query names to SQL values. The Maps are cached so a
- * subsequent request to load queries from the same path will return
- * the cached Map.
- *
- * @param path The path that the ClassLoader will use to find the file.
- * This is <strong>not</strong> a file system path. If you had a jarred
- * Queries.properties file in the com.yourcorp.app.jdbc package you would
- * pass "/com/yourcorp/app/jdbc/Queries.properties" to this method.
- * @throws IOException if a file access error occurs
- * @throws IllegalArgumentException if the ClassLoader can't find a file at
- * the given path.
- * @return Map of query names to SQL values
- */
- public synchronized Map<String, String> load(String path) throws IOException {
-
- Map<String, String> queryMap = this.queries.get(path);
-
- if (queryMap == null) {
- queryMap = this.loadQueries(path);
- this.queries.put(path, queryMap);
- }
-
- return queryMap;
- }
-
- /**
- * Loads a set of named queries into a Map object. This implementation
- * reads a properties file at the given path.
- * @param path The path that the ClassLoader will use to find the file.
- * @throws IOException if a file access error occurs
- * @throws IllegalArgumentException if the ClassLoader can't find a file at
- * the given path.
- * @since DbUtils 1.1
- * @return Map of query names to SQL values
- */
- protected Map<String, String> loadQueries(String path) throws IOException {
- // Findbugs flags getClass().getResource as a bad practice; maybe we should change the API?
- InputStream in = getClass().getResourceAsStream(path);
-
- if (in == null) {
- throw new IllegalArgumentException(path + " not found.");
- }
-
- Properties props = new Properties();
- try {
- props.load(in);
- } finally {
- in.close();
- }
-
- // Copy to HashMap for better performance
-
- @SuppressWarnings({ "rawtypes", "unchecked" }) // load() always creates <String,String> entries
- HashMap<String, String> hashMap = new HashMap(props);
- return hashMap;
- }
-
- /**
- * Removes the queries for the given path from the cache.
- * @param path The path that the queries were loaded from.
- */
- public synchronized void unload(String path) {
- this.queries.remove(path);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/main/java/org/apache/commons/dbutils/QueryRunner.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils/QueryRunner.java b/src/main/java/org/apache/commons/dbutils/QueryRunner.java
deleted file mode 100644
index 47a21cd..0000000
--- a/src/main/java/org/apache/commons/dbutils/QueryRunner.java
+++ /dev/null
@@ -1,315 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.dbutils;
-
-import java.sql.Connection;
-import java.sql.SQLException;
-import javax.sql.DataSource;
-
-/**
- * Executes SQL queries with pluggable strategies for handling
- * <code>ResultSet</code>s. This class is thread safe.
- *
- * @see ResultSetHandler
- */
-public class QueryRunner {
- /**
- * The DataSource to retrieve connections from.
- */
- private final DataSource ds;
-
- /**
- * Constructor for QueryRunner.
- */
- public QueryRunner() {
- ds = null;
- }
-
- /**
- * Constructor for QueryRunner that takes a <code>DataSource</code> to use.
- *
- * Methods that do not take a <code>Connection</code> parameter will retrieve connections from this
- * <code>DataSource</code>.
- *
- * @param ds The <code>DataSource</code> to retrieve connections from.
- */
- public QueryRunner(final DataSource ds) {
- this.ds = ds;
- }
-
- /**
- * Returns the <code>DataSource</code> this runner is using.
- * <code>QueryRunner</code> methods always call this method to get the
- * <code>DataSource</code> so subclasses can provide specialized behavior.
- *
- * @return DataSource the runner is using
- */
- public DataSource getDataSource() {
- return this.ds;
- }
-
- /**
- * Factory method that creates and initializes a <code>Connection</code>
- * object. <code>QueryRunner</code> methods always call this method to
- * retrieve connections from its DataSource. Subclasses can override this
- * method to provide special <code>Connection</code> configuration if
- * needed. This implementation simply calls <code>ds.getConnection()</code>.
- *
- * @return An initialized <code>Connection</code>.
- * @throws SQLException if a database access error occurs
- */
- protected Connection prepareConnection() throws SQLException {
- if (this.getDataSource() == null) {
- throw new SQLException(
- "QueryRunner requires a DataSource to be "
- + "invoked in this way, or a Connection should be passed in");
- }
- return this.getDataSource().getConnection();
- }
-
- /**
- * Close a <code>Connection</code>. This implementation avoids closing if
- * null and does <strong>not</strong> suppress any exceptions. Subclasses
- * can override to provide special handling like logging.
- *
- * @param conn Connection to close
- * @throws SQLException if a database access error occurs
- */
- private void close(Connection conn) throws SQLException {
- DbUtils.close(conn);
- }
-
- /**
- * Creates an {@link org.apache.commons.dbutils.BatchExecutor} for the given SQL.
- * <code>Connection</code> is retrieved from the <code>DataSource</code>
- * set in the constructor. This <code>Connection</code> must be in
- * auto-commit mode or the insert will not be saved. The <code>Connection</code> is
- * closed after the call.
- *
- * @param sql The SQL statement to execute.
- *
- * @return An {@link org.apache.commons.dbutils.BatchExecutor} for this SQL statement.
- * @throws SQLException If there are database or parameter errors.
- */
- public BatchExecutor batch(String sql) throws SQLException {
- return this.batch(this.prepareConnection(), true, sql);
- }
-
- /**
- * Creates an {@link org.apache.commons.dbutils.BatchExecutor} for the given SQL statement and connection.
- * The connection is <b>NOT</b> closed after execution.
- *
- * @param conn The connection to use for the batch call.
- * @param sql The SQL statement to execute.
- *
- * @return An {@link org.apache.commons.dbutils.BatchExecutor} for this SQL statement.
- * @throws SQLException If there are database or parameter errors.
- */
- public BatchExecutor batch(Connection conn, String sql) throws SQLException {
- return this.batch(conn, true, sql);
- }
-
- /**
- * Creates an {@link org.apache.commons.dbutils.BatchExecutor} for the given SQL statement and connection.
- *
- * @param conn The connection to use for the batch call.
- * @param closeConn True if the connection should be closed, false otherwise.
- * @param sql The SQL statement to execute.
- *
- * @return An {@link org.apache.commons.dbutils.BatchExecutor} for this SQL statement.
- * @throws SQLException If there are database or parameter errors.
- */
- public BatchExecutor batch(Connection conn, boolean closeConn, String sql) throws SQLException {
- if (conn == null) {
- throw new SQLException("Null connection");
- }
-
- if (sql == null) {
- if (closeConn) {
- close(conn);
- }
- throw new SQLException("Null SQL statement");
- }
-
- return new BatchExecutor(conn, sql, closeConn);
- }
-
- /**
- * Creates an {@link org.apache.commons.dbutils.QueryExecutor} for the given SQL.
- * <code>Connection</code> is retrieved from the <code>DataSource</code>
- * set in the constructor. This <code>Connection</code> must be in
- * auto-commit mode or the insert will not be saved. The <code>Connection</code> is
- * closed after the call.
- *
- * @param sql The SQL statement to execute.
- *
- * @return An {@link org.apache.commons.dbutils.QueryExecutor} for this SQL statement.
- * @throws SQLException If there are database or parameter errors.
- */
- public QueryExecutor query(String sql) throws SQLException {
- return this.query(this.prepareConnection(), true, sql);
- }
-
- /**
- * Creates an {@link org.apache.commons.dbutils.QueryExecutor} for the given SQL statement and connection.
- * The connection is <b>NOT</b> closed after execution.
- *
- * @param conn The connection to use for the update call.
- * @param sql The SQL statement to execute.
- *
- * @return An {@link org.apache.commons.dbutils.QueryExecutor} for this SQL statement.
- * @throws SQLException If there are database or parameter errors.
- */
- public QueryExecutor query(Connection conn, String sql) throws SQLException {
- return this.query(conn, false, sql);
- }
-
- /**
- * Creates an {@link org.apache.commons.dbutils.QueryExecutor} for the given SQL statement and connection.
- *
- * @param conn The connection to use for the query call.
- * @param closeConn True if the connection should be closed, false otherwise.
- * @param sql The SQL statement to execute.
- *
- * @return An {@link org.apache.commons.dbutils.QueryExecutor} for this SQL statement.
- * @throws SQLException If there are database or parameter errors.
- */
- public QueryExecutor query(Connection conn, boolean closeConn, String sql) throws SQLException {
- if (conn == null) {
- throw new SQLException("Null connection");
- }
-
- if (sql == null) {
- if (closeConn) {
- close(conn);
- }
- throw new SQLException("Null SQL statement");
- }
-
- return new QueryExecutor(conn, sql, closeConn);
- }
-
- /**
- * Creates an {@link org.apache.commons.dbutils.UpdateExecutor} for the given SQL.
- * <code>Connection</code> is retrieved from the <code>DataSource</code>
- * set in the constructor. This <code>Connection</code> must be in
- * auto-commit mode or the insert will not be saved. The <code>Connection</code> is
- * closed after the call.
- *
- * @param sql The SQL statement to execute.
- *
- * @return An {@link org.apache.commons.dbutils.UpdateExecutor} for this SQL statement.
- * @throws SQLException if a database access error occurs
- */
- public UpdateExecutor update(String sql) throws SQLException {
- return this.update(this.prepareConnection(), true, sql);
- }
-
- /**
- * Creates an {@link org.apache.commons.dbutils.UpdateExecutor} for the given SQL statement and connection.
- * The connection is <b>NOT</b> closed after execution.
- *
- * @param conn The connection to use for the update call.
- * @param sql The SQL statement to execute.
- *
- * @return An {@link org.apache.commons.dbutils.UpdateExecutor} for this SQL statement.
- * @throws SQLException If there are database or parameter errors.
- */
- public UpdateExecutor update(Connection conn, String sql) throws SQLException {
- return this.update(conn, false, sql);
- }
-
- /**
- * Creates an {@link org.apache.commons.dbutils.UpdateExecutor} for the given SQL statement and connection.
- *
- * @param conn The connection to use for the update call.
- * @param closeConn True if the connection should be closed, false otherwise.
- * @param sql The SQL statement to execute.
- *
- * @return An {@link org.apache.commons.dbutils.UpdateExecutor} for this SQL statement.
- * @throws SQLException If there are database or parameter errors.
- */
- public UpdateExecutor update(Connection conn, boolean closeConn, String sql) throws SQLException {
- if (conn == null) {
- throw new SQLException("Null connection");
- }
-
- if (sql == null) {
- if (closeConn) {
- close(conn);
- }
- throw new SQLException("Null SQL statement");
- }
-
- return new UpdateExecutor(conn, sql, closeConn);
- }
-
- /**
- * Creates an {@link org.apache.commons.dbutils.InsertExecutor} for the given SQL.
- * <code>Connection</code> is retrieved from the <code>DataSource</code>
- * set in the constructor. This <code>Connection</code> must be in
- * auto-commit mode or the insert will not be saved. The <code>Connection</code> is
- * closed after the call.
- *
- * @param sql The SQL statement to execute.
- *
- * @return An {@link org.apache.commons.dbutils.InsertExecutor} for this SQL statement.
- * @throws SQLException If there are database or parameter errors.
- */
- public InsertExecutor insert(String sql) throws SQLException {
- return insert(this.prepareConnection(), true, sql);
- }
-
- /**
- * Creates an {@link org.apache.commons.dbutils.InsertExecutor} for the given SQL and connection
- * The connection is <b>NOT</b> closed after execution.
- *
- * @param conn The connection to use for the query call.
- * @param sql The SQL statement to execute.
- *
- * @return An {@link org.apache.commons.dbutils.InsertExecutor} for this SQL statement.
- * @throws SQLException If there are database or parameter errors.
- */
- public InsertExecutor insert(Connection conn, String sql) throws SQLException {
- return insert(conn, false, sql);
- }
-
- /**
- * Creates an {@link org.apache.commons.dbutils.InsertExecutor} for the given SQL and connection.
- *
- * @param conn The connection to use for the insert call.
- * @param closeConn True if the connection should be closed, false otherwise.
- * @param sql The SQL statement to execute.
- *
- * @return An {@link org.apache.commons.dbutils.InsertExecutor} for this SQL statement.
- * @throws SQLException If there are database or parameter errors.
- */
- public InsertExecutor insert(Connection conn, boolean closeConn, String sql) throws SQLException {
- if (conn == null) {
- throw new SQLException("Null connection");
- }
-
- if (sql == null) {
- if (closeConn) {
- close(conn);
- }
- throw new SQLException("Null SQL statement");
- }
-
- return new InsertExecutor(conn, sql, closeConn);
- }
-}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/main/java/org/apache/commons/dbutils/ResultSetHandler.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils/ResultSetHandler.java b/src/main/java/org/apache/commons/dbutils/ResultSetHandler.java
deleted file mode 100644
index d1a7b4c..0000000
--- a/src/main/java/org/apache/commons/dbutils/ResultSetHandler.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.dbutils;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-/**
- * Implementations of this interface convert ResultSets into other objects.
- *
- * @param <T> the target type the input ResultSet will be converted to.
- */
-public interface ResultSetHandler<T> {
-
- /**
- * Turn the <code>ResultSet</code> into an Object.
- *
- * @param rs The <code>ResultSet</code> to handle. It has not been touched
- * before being passed to this method.
- *
- * @return An Object initialized with <code>ResultSet</code> data. It is
- * legal for implementations to return <code>null</code> if the
- * <code>ResultSet</code> contained 0 rows.
- *
- * @throws SQLException if a database access error occurs
- */
- T handle(ResultSet rs) throws SQLException;
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/main/java/org/apache/commons/dbutils/ResultSetIterator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils/ResultSetIterator.java b/src/main/java/org/apache/commons/dbutils/ResultSetIterator.java
deleted file mode 100644
index 0eeda4a..0000000
--- a/src/main/java/org/apache/commons/dbutils/ResultSetIterator.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.dbutils;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.Iterator;
-
-/**
- * <p>
- * Wraps a <code>ResultSet</code> in an <code>Iterator<Object[]></code>. This is useful
- * when you want to present a non-database application layer with domain
- * neutral data.
- * </p>
- *
- * <p>
- * This implementation requires the <code>ResultSet.isLast()</code> method
- * to be implemented.
- * </p>
- */
-public class ResultSetIterator implements Iterator<Object[]> {
-
- /**
- * The wrapped <code>ResultSet</code>.
- */
- private final ResultSet rs;
-
- /**
- * The processor to use when converting a row into an Object[].
- */
- private final RowProcessor convert;
-
- /**
- * Constructor for ResultSetIterator.
- * @param rs Wrap this <code>ResultSet</code> in an <code>Iterator</code>.
- */
- public ResultSetIterator(ResultSet rs) {
- this(rs, new BasicRowProcessor());
- }
-
- /**
- * Constructor for ResultSetIterator.
- * @param rs Wrap this <code>ResultSet</code> in an <code>Iterator</code>.
- * @param convert The processor to use when converting a row into an
- * <code>Object[]</code>. Defaults to a
- * <code>BasicRowProcessor</code>.
- */
- public ResultSetIterator(ResultSet rs, RowProcessor convert) {
- this.rs = rs;
- this.convert = convert;
- }
-
- /**
- * Returns true if there are more rows in the ResultSet.
- * @return boolean <code>true</code> if there are more rows
- * @throws RuntimeException if an SQLException occurs.
- */
- @Override
- public boolean hasNext() {
- try {
- return !rs.isLast();
- } catch (SQLException e) {
- rethrow(e);
- return false;
- }
- }
-
- /**
- * Returns the next row as an <code>Object[]</code>.
- * @return An <code>Object[]</code> with the same number of elements as
- * columns in the <code>ResultSet</code>.
- * @see java.util.Iterator#next()
- * @throws RuntimeException if an SQLException occurs.
- */
- @Override
- public Object[] next() {
- try {
- rs.next();
- return this.convert.toArray(rs);
- } catch (SQLException e) {
- rethrow(e);
- return null;
- }
- }
-
- /**
- * Deletes the current row from the <code>ResultSet</code>.
- * @see java.util.Iterator#remove()
- * @throws RuntimeException if an SQLException occurs.
- */
- @Override
- public void remove() {
- try {
- this.rs.deleteRow();
- } catch (SQLException e) {
- rethrow(e);
- }
- }
-
- /**
- * Rethrow the SQLException as a RuntimeException. This implementation
- * creates a new RuntimeException with the SQLException's error message.
- * @param e SQLException to rethrow
- * @since DbUtils 1.1
- */
- protected void rethrow(SQLException e) {
- throw new RuntimeException(e.getMessage());
- }
-
- /**
- * Generates an <code>Iterable</code>, suitable for use in for-each loops.
- *
- * @param rs Wrap this <code>ResultSet</code> in an <code>Iterator</code>.
- * @return an <code>Iterable</code>, suitable for use in for-each loops.
- */
- public static Iterable<Object[]> iterable(final ResultSet rs) {
- return new Iterable<Object[]>() {
-
- @Override
- public Iterator<Object[]> iterator() {
- return new ResultSetIterator(rs);
- }
-
- };
- }
-
-}
[07/58] [abbrv] commons-dbutils git commit: Changed the package names
so dbutils and dbutils2 won't conflict if both loaded
Posted by th...@apache.org.
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/main/java/org/apache/commons/dbutils2/AbstractExecutor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/AbstractExecutor.java b/src/main/java/org/apache/commons/dbutils2/AbstractExecutor.java
new file mode 100644
index 0000000..be0e2ac
--- /dev/null
+++ b/src/main/java/org/apache/commons/dbutils2/AbstractExecutor.java
@@ -0,0 +1,323 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.dbutils2;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.sql.Types;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * Abstract class for executing a query, insert, update, or batch.
+ *
+ * @since 2.0
+ * @author William Speirs <ws...@apache.org>
+ */
+abstract class AbstractExecutor<T extends AbstractExecutor<T>> {
+
+ private static final String COLON = ":"; // TODO: change this to any character
+
+ private final Connection conn;
+ private final String sql;
+ private final PreparedStatement stmt;
+
+ private final Map<String, List<Integer>> paramPosMap;
+ private final Map<String, Object> paramValueMap;
+ private Integer currentPosition = Integer.valueOf(0);
+
+ public AbstractExecutor(final Connection conn, final String sql) throws SQLException {
+ this.conn = conn;
+ this.sql = sql;
+ this.paramPosMap = new HashMap<String, List<Integer>>();
+ this.paramValueMap = new HashMap<String, Object>();
+
+ final Pattern paramPattern = Pattern.compile("(:\\w+)");
+ final Matcher matcher = paramPattern.matcher(sql);
+
+ // go through finding params
+ while(matcher.find()) {
+ insertParamPosition(matcher.group().replace(COLON, ""));
+ }
+
+ // replace all of the :names with ?, and create a prepared statement
+ stmt = conn.prepareStatement(sql.replaceAll(":\\w+", "\\?"));
+ }
+
+ /**
+ * Helper method to insert params and the current position into the map.
+ * @param param the SQL param.
+ */
+ private void insertParamPosition(final String param) {
+ List<Integer> posList = paramPosMap.get(param);
+
+ // create a new list if we need to
+ if(posList == null) {
+ posList = new ArrayList<Integer>();
+ paramPosMap.put(param, posList);
+ }
+
+ // increment first, so we match SQL numbering
+ posList.add(++currentPosition);
+ }
+
+ /**
+ * Gets the SQL statement that was passed into the constructor.
+ * @return the SQL statement passed into the constructor.
+ */
+ protected String getSql() {
+ return sql;
+ }
+
+ /**
+ * Returns the underlying prepared statement.
+ * @return the underlying prepared statement.
+ */
+ protected PreparedStatement getStatement() {
+ return stmt;
+ }
+
+ /**
+ * Returns the underlying connection.
+ * @return the underlying connection.
+ */
+ protected Connection getConnection() {
+ return conn;
+ }
+
+ /**
+ * Throws an exception if there are unmapped params.
+ * @throws SQLException if there are unmapped params.
+ */
+ protected void throwIfUnmappedParams() throws SQLException {
+ if(paramPosMap.size() != 0) {
+ final Set<String> unmappedParams = paramPosMap.keySet();
+ final StringBuilder sb = new StringBuilder("There are unbound parameters: ");
+
+ for(String param:unmappedParams) {
+ sb.append(param);
+ sb.append(", ");
+ }
+
+ // remove the last comma
+ sb.delete(sb.length()-2, sb.length());
+
+ // throw our exception
+ throw new SQLException(sb.toString());
+ }
+ }
+
+ /**
+ * Binds a named parameter to a value.
+ *
+ * @param name the name of the parameter in the SQL statement.
+ * @param value the value of the parameter in the SQL statement.
+ * @return this execution object to provide the fluent style.
+ * @throws SQLException thrown if the parameter is not found, already bound, or there is an issue binding it.
+ */
+ public T bind(final String name, final Object value) throws SQLException {
+ return bind(name, value, true);
+ }
+
+ /**
+ * Binds null to a parameter.
+ * Types.VARCHAR is used as the type's parameter.
+ * This usually works, but fails with some Oracle and MS SQL drivers.
+ * @param name the name of the parameter.
+ * @return this execution object to provide the fluent style.
+ * @throws SQLException throw if the parameter is not found, already bound, or there is an issue binding null.
+ */
+ public T bindNull(final String name) throws SQLException {
+ return bindNull(name, Types.VARCHAR, true);
+ }
+
+ /**
+ * Binds null to a parameter, specifying the parameter's type.
+ * @param name the name of the parameter.
+ * @param sqlType the type of the parameter.
+ * @return this execution object to provide the fluent style.
+ * @throws SQLException throw if the parameter is not found, already bound, or there is an issue binding null.
+ */
+ public T bindNull(final String name, final int sqlType) throws SQLException {
+ return bindNull(name, sqlType, true);
+ }
+
+ /**
+ * Given a param name and sqlType, binds a null to that parameter.
+ * @param name the name of the parameter.
+ * @param sqlType the type of the parameter.
+ * @param removeFromPosMap if the param should be removed from the pos map.
+ * @return this
+ * @throws SQLException if there is an SQLException during binding.
+ */
+ protected T bindNull(String name, int sqlType, boolean removeFromPosMap) throws SQLException {
+ name = name.replace(COLON, ""); // so we can take ":name" or "name"
+
+ final List<Integer> pos = removeFromPosMap ? paramPosMap.remove(name) : paramPosMap.get(name);
+
+ if(pos == null) {
+ throw new SQLException(name + " is not found in the SQL statement");
+ }
+
+ // go through and bind all of the positions for this name
+ for(Integer p:pos) {
+ stmt.setNull(p, sqlType);
+ }
+
+ // add the param and value to our map
+ paramValueMap.put(name, null);
+
+ // suppressed because the casting will always work here
+ @SuppressWarnings("unchecked")
+ final T ret = (T) this;
+
+ return ret;
+ }
+
+ /**
+ * Binds value to name, but does not do the bookkeeping.
+ * @param name the parameter name.
+ * @param value the value.
+ * @param removeFromPosMap if the param should be removed from the pos map.
+ * @return this
+ * @throws SQLException if there is an SQLException during binding.
+ */
+ protected T bind(String name, final Object value, boolean removeFromPosMap) throws SQLException {
+ name = name.replace(COLON, ""); // so we can take ":name" or "name"
+
+ final List<Integer> pos = removeFromPosMap ? paramPosMap.remove(name) : paramPosMap.get(name);
+
+ if(pos == null) {
+ throw new SQLException(name + " is not found in the SQL statement");
+ }
+
+ // go through and bind all of the positions for this name
+ for(Integer p:pos) {
+ // TODO: need to figure out how to bind NULL
+ stmt.setObject(p, value);
+ }
+
+ // add the param and value to our map
+ paramValueMap.put(name, value);
+
+ // suppressed because the casting will always work here
+ @SuppressWarnings("unchecked")
+ final T ret = (T) this;
+
+ return ret;
+ }
+
+ /**
+ * Used for batch calls so we can clear the map after the addBatch call.
+ */
+ protected void clearValueMap() {
+ paramValueMap.clear();
+ }
+
+ /**
+ * Throws a new exception with a more informative error message.
+ *
+ * @param cause The original exception that will be chained to the new
+ * exception when it's rethrown.
+ *
+ * @throws SQLException if a database access error occurs
+ */
+ protected void rethrow(SQLException cause) throws SQLException {
+ String causeMessage = cause.getMessage();
+
+ if (causeMessage == null) {
+ causeMessage = "";
+ }
+
+ final StringBuffer msg = new StringBuffer(causeMessage);
+
+ msg.append(" Query: ");
+ msg.append(sql);
+ msg.append(" Parameters: ");
+
+ // loop through adding the parameter to value mappings
+ for(Map.Entry<String, Object> param:paramValueMap.entrySet()) {
+ msg.append(param.getKey());
+ msg.append("=");
+ msg.append(param.getValue());
+ msg.append(" ");
+ }
+
+ final SQLException e = new SQLException(msg.toString(), cause.getSQLState(), cause.getErrorCode());
+ e.setNextException(cause);
+
+ throw e;
+ }
+
+ /**
+ * Wrap the <code>ResultSet</code> in a decorator before processing it. This
+ * implementation returns the <code>ResultSet</code> it is given without any
+ * decoration.
+ *
+ * @param rs The <code>ResultSet</code> to decorate; never <code>null</code>.
+ * @return The <code>ResultSet</code> wrapped in some decorator.
+ */
+ protected ResultSet wrap(ResultSet rs) {
+ return rs;
+ }
+
+ /**
+ * Close a <code>Connection</code>. This implementation avoids closing if
+ * null and does <strong>not</strong> suppress any exceptions. Subclasses
+ * can override to provide special handling like logging.
+ *
+ * @param conn Connection to close
+ * @throws SQLException if a database access error occurs
+ */
+ protected void close(Connection conn) throws SQLException {
+ DbUtils.close(conn);
+ }
+
+ /**
+ * Close a <code>Statement</code>. This implementation avoids closing if
+ * null and does <strong>not</strong> suppress any exceptions. Subclasses
+ * can override to provide special handling like logging.
+ *
+ * @param stmt Statement to close
+ * @throws SQLException if a database access error occurs
+ */
+ protected void close(Statement stmt) throws SQLException {
+ DbUtils.close(stmt);
+ }
+
+ /**
+ * Close a <code>ResultSet</code>. This implementation avoids closing if
+ * null and does <strong>not</strong> suppress any exceptions. Subclasses
+ * can override to provide special handling like logging.
+ *
+ * @param rs ResultSet to close
+ * @throws SQLException if a database access error occurs
+ */
+ protected void close(ResultSet rs) throws SQLException {
+ DbUtils.close(rs);
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/main/java/org/apache/commons/dbutils2/AsyncExecutor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/AsyncExecutor.java b/src/main/java/org/apache/commons/dbutils2/AsyncExecutor.java
new file mode 100644
index 0000000..41cb990
--- /dev/null
+++ b/src/main/java/org/apache/commons/dbutils2/AsyncExecutor.java
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.dbutils2;
+
+import java.sql.SQLException;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Future;
+
+/**
+ * Convenience class for executing QueryExecutor, InsertExecutor, or UpdateExecutors asynchronously.
+ *
+ * @author William Speirs <ws...@apache.org>
+ * @since 2.0
+ */
+public class AsyncExecutor {
+
+ private final ExecutorService executorService;
+
+ /**
+ * Constructor for AsyncQueryRunner which uses a provided ExecutorService and underlying QueryRunner.
+ *
+ * @param executorService the {@code ExecutorService} instance used to run JDBC invocations concurrently.
+ * @param queryRunner the {@code QueryRunner} instance to use for the queries.
+ */
+ public AsyncExecutor(ExecutorService executorService) {
+ this.executorService = executorService;
+ }
+
+ /**
+ * Execute a {@link org.apache.commons.dbutils2.BatchExecutor}.
+ * @return A <code>Future</code> which returns the result of the batch call.
+ * @throws SQLException if a database access error occurs
+ */
+ public Future<int[]> execute(final BatchExecutor executor) throws SQLException {
+ return executorService.submit(new Callable<int[]>() {
+
+ @Override
+ public int[] call() throws Exception {
+ return executor.execute();
+ }
+
+ });
+ }
+
+ /**
+ * Execute a {@link org.apache.commons.dbutils2.QueryExecutor} given a handler.
+ * @param <T> The type of object that the handler returns
+ * @param handler The handler that converts the results into an object.
+ * @return A <code>Future</code> which returns the result of the query call.
+ * @throws SQLException if a database access error occurs
+ */
+ public <T> Future<T> execute(final QueryExecutor executor, final ResultSetHandler<T> handler) throws SQLException {
+ return executorService.submit(new Callable<T>() {
+
+ @Override
+ public T call() throws Exception {
+ return executor.execute(handler);
+ }
+
+ });
+ }
+
+ /**
+ * Execute a {@link org.apache.commons.dbutils2.UpdateExecutor}.
+ * @param <T> The type of object that the handler returns
+ * @return A <code>Future</code> which returns the result of the query call.
+ * @throws SQLException if a database access error occurs
+ */
+ public Future<Integer> execute(final UpdateExecutor executor) throws SQLException {
+ return executorService.submit(new Callable<Integer>() {
+
+ @Override
+ public Integer call() throws Exception {
+ return executor.execute();
+ }
+
+ });
+ }
+
+ /**
+ * Execute a {@link org.apache.commons.dbutils2.InsertExecutor} given a handler.
+ * @param <T> The type of object that the handler returns
+ * @param handler The handler that converts the results into an object.
+ * @return A <code>Future</code> which returns the result of the query call.
+ * @throws SQLException if a database access error occurs
+ */
+ public <T> Future<T> execute(final InsertExecutor executor, final ResultSetHandler<T> handler) throws SQLException {
+ return executorService.submit(new Callable<T>() {
+
+ @Override
+ public T call() throws Exception {
+ return executor.execute(handler);
+ }
+
+ });
+ }
+
+ /**
+ * Execute a {@link org.apache.commons.dbutils2.InsertExecutor} given a handler.
+ * @return A <code>Future</code> which returns the number of rows inserted.
+ * @throws SQLException if a database access error occurs
+ */
+ public Future<Integer> execute(final InsertExecutor executor) throws SQLException {
+ return executorService.submit(new Callable<Integer>() {
+
+ @Override
+ public Integer call() throws Exception {
+ return executor.execute();
+ }
+
+ });
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/main/java/org/apache/commons/dbutils2/BaseResultSetHandler.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/BaseResultSetHandler.java b/src/main/java/org/apache/commons/dbutils2/BaseResultSetHandler.java
new file mode 100644
index 0000000..361f9fa
--- /dev/null
+++ b/src/main/java/org/apache/commons/dbutils2/BaseResultSetHandler.java
@@ -0,0 +1,1923 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.dbutils2;
+
+import java.io.InputStream;
+import java.io.Reader;
+import java.math.BigDecimal;
+import java.net.URL;
+import java.sql.Array;
+import java.sql.Blob;
+import java.sql.Clob;
+import java.sql.Date;
+import java.sql.NClob;
+import java.sql.Ref;
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.RowId;
+import java.sql.SQLException;
+import java.sql.SQLWarning;
+import java.sql.SQLXML;
+import java.sql.Statement;
+import java.sql.Time;
+import java.sql.Timestamp;
+import java.util.Calendar;
+import java.util.Map;
+
+/**
+ * Extensions of this class convert ResultSets into other objects.
+ *
+ * According to the <i>DRY</i> principle (Don't Repeat Yourself), repeating <code>resultSet</code>
+ * variable inside the {@link ResultSetHandler#handle(ResultSet)} over and over for each iteration
+ * can get a little tedious, <code>AbstractResultSetHandler</code> implicitly gives users access to
+ * <code>ResultSet</code>'s methods.
+ *
+ * <b>NOTE</b> This class is <i>NOT</i> thread safe!
+ *
+ * @param <T> the target type the input ResultSet will be converted to.
+ * @since 1.6
+ */
+public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> {
+
+ /**
+ * The adapted ResultSet.
+ */
+ private ResultSet rs;
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public final T handle(ResultSet rs) throws SQLException {
+ if (this.rs != null) {
+ throw new IllegalStateException("Re-entry not allowed!");
+ }
+
+ this.rs = rs;
+
+ try {
+ return handle();
+ } finally {
+ this.rs = null;
+ }
+ }
+
+ /**
+ * Turn the <code>ResultSet</code> into an Object.
+ *
+ * @return An Object initialized with <code>ResultSet</code> data
+ * @throws SQLException if a database access error occurs
+ * @see {@link ResultSetHandler#handle(ResultSet)}
+ */
+ protected abstract T handle() throws SQLException;
+
+ /**
+ * @param row
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#absolute(int)
+ */
+ protected final boolean absolute(int row) throws SQLException {
+ return rs.absolute(row);
+ }
+
+ /**
+ * @throws SQLException
+ * @see java.sql.ResultSet#afterLast()
+ */
+ protected final void afterLast() throws SQLException {
+ rs.afterLast();
+ }
+
+ /**
+ * @throws SQLException
+ * @see java.sql.ResultSet#beforeFirst()
+ */
+ protected final void beforeFirst() throws SQLException {
+ rs.beforeFirst();
+ }
+
+ /**
+ * @throws SQLException
+ * @see java.sql.ResultSet#cancelRowUpdates()
+ */
+ protected final void cancelRowUpdates() throws SQLException {
+ rs.cancelRowUpdates();
+ }
+
+ /**
+ * @throws SQLException
+ * @see java.sql.ResultSet#clearWarnings()
+ */
+ protected final void clearWarnings() throws SQLException {
+ rs.clearWarnings();
+ }
+
+ /**
+ * @throws SQLException
+ * @see java.sql.ResultSet#close()
+ */
+ protected final void close() throws SQLException {
+ rs.close();
+ }
+
+ /**
+ * @throws SQLException
+ * @see java.sql.ResultSet#deleteRow()
+ */
+ protected final void deleteRow() throws SQLException {
+ rs.deleteRow();
+ }
+
+ /**
+ * @param columnLabel
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#findColumn(java.lang.String)
+ */
+ protected final int findColumn(String columnLabel) throws SQLException {
+ return rs.findColumn(columnLabel);
+ }
+
+ /**
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#first()
+ */
+ protected final boolean first() throws SQLException {
+ return rs.first();
+ }
+
+ /**
+ * @param columnIndex
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#getArray(int)
+ */
+ protected final Array getArray(int columnIndex) throws SQLException {
+ return rs.getArray(columnIndex);
+ }
+
+ /**
+ * @param columnLabel
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#getArray(java.lang.String)
+ */
+ protected final Array getArray(String columnLabel) throws SQLException {
+ return rs.getArray(columnLabel);
+ }
+
+ /**
+ * @param columnIndex
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#getAsciiStream(int)
+ */
+ protected final InputStream getAsciiStream(int columnIndex) throws SQLException {
+ return rs.getAsciiStream(columnIndex);
+ }
+
+ /**
+ * @param columnLabel
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#getAsciiStream(java.lang.String)
+ */
+ protected final InputStream getAsciiStream(String columnLabel) throws SQLException {
+ return rs.getAsciiStream(columnLabel);
+ }
+
+ /**
+ * @param columnIndex
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#getBigDecimal(int)
+ */
+ protected final BigDecimal getBigDecimal(int columnIndex) throws SQLException {
+ return rs.getBigDecimal(columnIndex);
+ }
+
+ /**
+ * @param columnLabel
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#getBigDecimal(java.lang.String)
+ */
+ protected final BigDecimal getBigDecimal(String columnLabel) throws SQLException {
+ return rs.getBigDecimal(columnLabel);
+ }
+
+ /**
+ * @param columnIndex
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#getBinaryStream(int)
+ */
+ protected final InputStream getBinaryStream(int columnIndex) throws SQLException {
+ return rs.getBinaryStream(columnIndex);
+ }
+
+ /**
+ * @param columnLabel
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#getBinaryStream(java.lang.String)
+ */
+ protected final InputStream getBinaryStream(String columnLabel) throws SQLException {
+ return rs.getBinaryStream(columnLabel);
+ }
+
+ /**
+ * @param columnIndex
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#getBlob(int)
+ */
+ protected final Blob getBlob(int columnIndex) throws SQLException {
+ return rs.getBlob(columnIndex);
+ }
+
+ /**
+ * @param columnLabel
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#getBlob(java.lang.String)
+ */
+ protected final Blob getBlob(String columnLabel) throws SQLException {
+ return rs.getBlob(columnLabel);
+ }
+
+ /**
+ * @param columnIndex
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#getBoolean(int)
+ */
+ protected final boolean getBoolean(int columnIndex) throws SQLException {
+ return rs.getBoolean(columnIndex);
+ }
+
+ /**
+ * @param columnLabel
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#getBoolean(java.lang.String)
+ */
+ protected final boolean getBoolean(String columnLabel) throws SQLException {
+ return rs.getBoolean(columnLabel);
+ }
+
+ /**
+ * @param columnIndex
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#getByte(int)
+ */
+ protected final byte getByte(int columnIndex) throws SQLException {
+ return rs.getByte(columnIndex);
+ }
+
+ /**
+ * @param columnLabel
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#getByte(java.lang.String)
+ */
+ protected final byte getByte(String columnLabel) throws SQLException {
+ return rs.getByte(columnLabel);
+ }
+
+ /**
+ * @param columnIndex
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#getBytes(int)
+ */
+ protected final byte[] getBytes(int columnIndex) throws SQLException {
+ return rs.getBytes(columnIndex);
+ }
+
+ /**
+ * @param columnLabel
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#getBytes(java.lang.String)
+ */
+ protected final byte[] getBytes(String columnLabel) throws SQLException {
+ return rs.getBytes(columnLabel);
+ }
+
+ /**
+ * @param columnIndex
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#getCharacterStream(int)
+ */
+ protected final Reader getCharacterStream(int columnIndex) throws SQLException {
+ return rs.getCharacterStream(columnIndex);
+ }
+
+ /**
+ * @param columnLabel
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#getCharacterStream(java.lang.String)
+ */
+ protected final Reader getCharacterStream(String columnLabel) throws SQLException {
+ return rs.getCharacterStream(columnLabel);
+ }
+
+ /**
+ * @param columnIndex
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#getClob(int)
+ */
+ protected final Clob getClob(int columnIndex) throws SQLException {
+ return rs.getClob(columnIndex);
+ }
+
+ /**
+ * @param columnLabel
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#getClob(java.lang.String)
+ */
+ protected final Clob getClob(String columnLabel) throws SQLException {
+ return rs.getClob(columnLabel);
+ }
+
+ /**
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#getConcurrency()
+ */
+ protected final int getConcurrency() throws SQLException {
+ return rs.getConcurrency();
+ }
+
+ /**
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#getCursorName()
+ */
+ protected final String getCursorName() throws SQLException {
+ return rs.getCursorName();
+ }
+
+ /**
+ * @param columnIndex
+ * @param cal
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#getDate(int, java.util.Calendar)
+ */
+ protected final Date getDate(int columnIndex, Calendar cal) throws SQLException {
+ return rs.getDate(columnIndex, cal);
+ }
+
+ /**
+ * @param columnIndex
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#getDate(int)
+ */
+ protected final Date getDate(int columnIndex) throws SQLException {
+ return rs.getDate(columnIndex);
+ }
+
+ /**
+ * @param columnLabel
+ * @param cal
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#getDate(java.lang.String, java.util.Calendar)
+ */
+ protected final Date getDate(String columnLabel, Calendar cal) throws SQLException {
+ return rs.getDate(columnLabel, cal);
+ }
+
+ /**
+ * @param columnLabel
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#getDate(java.lang.String)
+ */
+ protected final Date getDate(String columnLabel) throws SQLException {
+ return rs.getDate(columnLabel);
+ }
+
+ /**
+ * @param columnIndex
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#getDouble(int)
+ */
+ protected final double getDouble(int columnIndex) throws SQLException {
+ return rs.getDouble(columnIndex);
+ }
+
+ /**
+ * @param columnLabel
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#getDouble(java.lang.String)
+ */
+ protected final double getDouble(String columnLabel) throws SQLException {
+ return rs.getDouble(columnLabel);
+ }
+
+ /**
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#getFetchDirection()
+ */
+ protected final int getFetchDirection() throws SQLException {
+ return rs.getFetchDirection();
+ }
+
+ /**
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#getFetchSize()
+ */
+ protected final int getFetchSize() throws SQLException {
+ return rs.getFetchSize();
+ }
+
+ /**
+ * @param columnIndex
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#getFloat(int)
+ */
+ protected final float getFloat(int columnIndex) throws SQLException {
+ return rs.getFloat(columnIndex);
+ }
+
+ /**
+ * @param columnLabel
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#getFloat(java.lang.String)
+ */
+ protected final float getFloat(String columnLabel) throws SQLException {
+ return rs.getFloat(columnLabel);
+ }
+
+ /**
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#getHoldability()
+ */
+ protected final int getHoldability() throws SQLException {
+ return rs.getHoldability();
+ }
+
+ /**
+ * @param columnIndex
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#getInt(int)
+ */
+ protected final int getInt(int columnIndex) throws SQLException {
+ return rs.getInt(columnIndex);
+ }
+
+ /**
+ * @param columnLabel
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#getInt(java.lang.String)
+ */
+ protected final int getInt(String columnLabel) throws SQLException {
+ return rs.getInt(columnLabel);
+ }
+
+ /**
+ * @param columnIndex
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#getLong(int)
+ */
+ protected final long getLong(int columnIndex) throws SQLException {
+ return rs.getLong(columnIndex);
+ }
+
+ /**
+ * @param columnLabel
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#getLong(java.lang.String)
+ */
+ protected final long getLong(String columnLabel) throws SQLException {
+ return rs.getLong(columnLabel);
+ }
+
+ /**
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#getMetaData()
+ */
+ protected final ResultSetMetaData getMetaData() throws SQLException {
+ return rs.getMetaData();
+ }
+
+ /**
+ * @param columnIndex
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#getNCharacterStream(int)
+ */
+ protected final Reader getNCharacterStream(int columnIndex) throws SQLException {
+ return rs.getNCharacterStream(columnIndex);
+ }
+
+ /**
+ * @param columnLabel
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#getNCharacterStream(java.lang.String)
+ */
+ protected final Reader getNCharacterStream(String columnLabel) throws SQLException {
+ return rs.getNCharacterStream(columnLabel);
+ }
+
+ /**
+ * @param columnIndex
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#getNClob(int)
+ */
+ protected final NClob getNClob(int columnIndex) throws SQLException {
+ return rs.getNClob(columnIndex);
+ }
+
+ /**
+ * @param columnLabel
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#getNClob(java.lang.String)
+ */
+ protected final NClob getNClob(String columnLabel) throws SQLException {
+ return rs.getNClob(columnLabel);
+ }
+
+ /**
+ * @param columnIndex
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#getNString(int)
+ */
+ protected final String getNString(int columnIndex) throws SQLException {
+ return rs.getNString(columnIndex);
+ }
+
+ /**
+ * @param columnLabel
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#getNString(java.lang.String)
+ */
+ protected final String getNString(String columnLabel) throws SQLException {
+ return rs.getNString(columnLabel);
+ }
+
+ /**
+ * @param columnIndex
+ * @param map
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#getObject(int, java.util.Map)
+ */
+ protected final Object getObject(int columnIndex, Map<String, Class<?>> map) throws SQLException {
+ return rs.getObject(columnIndex, map);
+ }
+
+ /**
+ * @param columnIndex
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#getObject(int)
+ */
+ protected final Object getObject(int columnIndex) throws SQLException {
+ return rs.getObject(columnIndex);
+ }
+
+ /**
+ * @param columnLabel
+ * @param map
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#getObject(java.lang.String, java.util.Map)
+ */
+ protected final Object getObject(String columnLabel, Map<String, Class<?>> map) throws SQLException {
+ return rs.getObject(columnLabel, map);
+ }
+
+ /**
+ * @param columnLabel
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#getObject(java.lang.String)
+ */
+ protected final Object getObject(String columnLabel) throws SQLException {
+ return rs.getObject(columnLabel);
+ }
+
+ /**
+ * @param columnIndex
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#getRef(int)
+ */
+ protected final Ref getRef(int columnIndex) throws SQLException {
+ return rs.getRef(columnIndex);
+ }
+
+ /**
+ * @param columnLabel
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#getRef(java.lang.String)
+ */
+ protected final Ref getRef(String columnLabel) throws SQLException {
+ return rs.getRef(columnLabel);
+ }
+
+ /**
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#getRow()
+ */
+ protected final int getRow() throws SQLException {
+ return rs.getRow();
+ }
+
+ /**
+ * @param columnIndex
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#getRowId(int)
+ */
+ protected final RowId getRowId(int columnIndex) throws SQLException {
+ return rs.getRowId(columnIndex);
+ }
+
+ /**
+ * @param columnLabel
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#getRowId(java.lang.String)
+ */
+ protected final RowId getRowId(String columnLabel) throws SQLException {
+ return rs.getRowId(columnLabel);
+ }
+
+ /**
+ * @param columnIndex
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#getSQLXML(int)
+ */
+ protected final SQLXML getSQLXML(int columnIndex) throws SQLException {
+ return rs.getSQLXML(columnIndex);
+ }
+
+ /**
+ * @param columnLabel
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#getSQLXML(java.lang.String)
+ */
+ protected final SQLXML getSQLXML(String columnLabel) throws SQLException {
+ return rs.getSQLXML(columnLabel);
+ }
+
+ /**
+ * @param columnIndex
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#getShort(int)
+ */
+ protected final short getShort(int columnIndex) throws SQLException {
+ return rs.getShort(columnIndex);
+ }
+
+ /**
+ * @param columnLabel
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#getShort(java.lang.String)
+ */
+ protected final short getShort(String columnLabel) throws SQLException {
+ return rs.getShort(columnLabel);
+ }
+
+ /**
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#getStatement()
+ */
+ protected final Statement getStatement() throws SQLException {
+ return rs.getStatement();
+ }
+
+ /**
+ * @param columnIndex
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#getString(int)
+ */
+ protected final String getString(int columnIndex) throws SQLException {
+ return rs.getString(columnIndex);
+ }
+
+ /**
+ * @param columnLabel
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#getString(java.lang.String)
+ */
+ protected final String getString(String columnLabel) throws SQLException {
+ return rs.getString(columnLabel);
+ }
+
+ /**
+ * @param columnIndex
+ * @param cal
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#getTime(int, java.util.Calendar)
+ */
+ protected final Time getTime(int columnIndex, Calendar cal) throws SQLException {
+ return rs.getTime(columnIndex, cal);
+ }
+
+ /**
+ * @param columnIndex
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#getTime(int)
+ */
+ protected final Time getTime(int columnIndex) throws SQLException {
+ return rs.getTime(columnIndex);
+ }
+
+ /**
+ * @param columnLabel
+ * @param cal
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#getTime(java.lang.String, java.util.Calendar)
+ */
+ protected final Time getTime(String columnLabel, Calendar cal) throws SQLException {
+ return rs.getTime(columnLabel, cal);
+ }
+
+ /**
+ * @param columnLabel
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#getTime(java.lang.String)
+ */
+ protected final Time getTime(String columnLabel) throws SQLException {
+ return rs.getTime(columnLabel);
+ }
+
+ /**
+ * @param columnIndex
+ * @param cal
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#getTimestamp(int, java.util.Calendar)
+ */
+ protected final Timestamp getTimestamp(int columnIndex, Calendar cal) throws SQLException {
+ return rs.getTimestamp(columnIndex, cal);
+ }
+
+ /**
+ * @param columnIndex
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#getTimestamp(int)
+ */
+ protected final Timestamp getTimestamp(int columnIndex) throws SQLException {
+ return rs.getTimestamp(columnIndex);
+ }
+
+ /**
+ * @param columnLabel
+ * @param cal
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#getTimestamp(java.lang.String, java.util.Calendar)
+ */
+ protected final Timestamp getTimestamp(String columnLabel, Calendar cal) throws SQLException {
+ return rs.getTimestamp(columnLabel, cal);
+ }
+
+ /**
+ * @param columnLabel
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#getTimestamp(java.lang.String)
+ */
+ protected final Timestamp getTimestamp(String columnLabel) throws SQLException {
+ return rs.getTimestamp(columnLabel);
+ }
+
+ /**
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#getType()
+ */
+ protected final int getType() throws SQLException {
+ return rs.getType();
+ }
+
+ /**
+ * @param columnIndex
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#getURL(int)
+ */
+ protected final URL getURL(int columnIndex) throws SQLException {
+ return rs.getURL(columnIndex);
+ }
+
+ /**
+ * @param columnLabel
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#getURL(java.lang.String)
+ */
+ protected final URL getURL(String columnLabel) throws SQLException {
+ return rs.getURL(columnLabel);
+ }
+
+ /**
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#getWarnings()
+ */
+ protected final SQLWarning getWarnings() throws SQLException {
+ return rs.getWarnings();
+ }
+
+ /**
+ * @throws SQLException
+ * @see java.sql.ResultSet#insertRow()
+ */
+ protected final void insertRow() throws SQLException {
+ rs.insertRow();
+ }
+
+ /**
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#isAfterLast()
+ */
+ protected final boolean isAfterLast() throws SQLException {
+ return rs.isAfterLast();
+ }
+
+ /**
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#isBeforeFirst()
+ */
+ protected final boolean isBeforeFirst() throws SQLException {
+ return rs.isBeforeFirst();
+ }
+
+ /**
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#isClosed()
+ */
+ protected final boolean isClosed() throws SQLException {
+ return rs.isClosed();
+ }
+
+ /**
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#isFirst()
+ */
+ protected final boolean isFirst() throws SQLException {
+ return rs.isFirst();
+ }
+
+ /**
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#isLast()
+ */
+ protected final boolean isLast() throws SQLException {
+ return rs.isLast();
+ }
+
+ /**
+ * @param iface
+ * @return
+ * @throws SQLException
+ * @see java.sql.Wrapper#isWrapperFor(java.lang.Class)
+ */
+ protected final boolean isWrapperFor(Class<?> iface) throws SQLException {
+ return rs.isWrapperFor(iface);
+ }
+
+ /**
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#last()
+ */
+ protected final boolean last() throws SQLException {
+ return rs.last();
+ }
+
+ /**
+ * @throws SQLException
+ * @see java.sql.ResultSet#moveToCurrentRow()
+ */
+ protected final void moveToCurrentRow() throws SQLException {
+ rs.moveToCurrentRow();
+ }
+
+ /**
+ * @throws SQLException
+ * @see java.sql.ResultSet#moveToInsertRow()
+ */
+ protected final void moveToInsertRow() throws SQLException {
+ rs.moveToInsertRow();
+ }
+
+ /**
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#next()
+ */
+ protected final boolean next() throws SQLException {
+ return rs.next();
+ }
+
+ /**
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#previous()
+ */
+ protected final boolean previous() throws SQLException {
+ return rs.previous();
+ }
+
+ /**
+ * @throws SQLException
+ * @see java.sql.ResultSet#refreshRow()
+ */
+ protected final void refreshRow() throws SQLException {
+ rs.refreshRow();
+ }
+
+ /**
+ * @param rows
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#relative(int)
+ */
+ protected final boolean relative(int rows) throws SQLException {
+ return rs.relative(rows);
+ }
+
+ /**
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#rowDeleted()
+ */
+ protected final boolean rowDeleted() throws SQLException {
+ return rs.rowDeleted();
+ }
+
+ /**
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#rowInserted()
+ */
+ protected final boolean rowInserted() throws SQLException {
+ return rs.rowInserted();
+ }
+
+ /**
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#rowUpdated()
+ */
+ protected final boolean rowUpdated() throws SQLException {
+ return rs.rowUpdated();
+ }
+
+ /**
+ * @param direction
+ * @throws SQLException
+ * @see java.sql.ResultSet#setFetchDirection(int)
+ */
+ protected final void setFetchDirection(int direction) throws SQLException {
+ rs.setFetchDirection(direction);
+ }
+
+ /**
+ * @param rows
+ * @throws SQLException
+ * @see java.sql.ResultSet#setFetchSize(int)
+ */
+ protected final void setFetchSize(int rows) throws SQLException {
+ rs.setFetchSize(rows);
+ }
+
+ /**
+ * @param iface
+ * @return
+ * @throws SQLException
+ * @see java.sql.Wrapper#unwrap(java.lang.Class)
+ */
+ protected final <E> E unwrap(Class<E> iface) throws SQLException {
+ return rs.unwrap(iface);
+ }
+
+ /**
+ * @param columnIndex
+ * @param x
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateArray(int, java.sql.Array)
+ */
+ protected final void updateArray(int columnIndex, Array x) throws SQLException {
+ rs.updateArray(columnIndex, x);
+ }
+
+ /**
+ * @param columnLabel
+ * @param x
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateArray(java.lang.String, java.sql.Array)
+ */
+ protected final void updateArray(String columnLabel, Array x) throws SQLException {
+ rs.updateArray(columnLabel, x);
+ }
+
+ /**
+ * @param columnIndex
+ * @param x
+ * @param length
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateAsciiStream(int, java.io.InputStream, int)
+ */
+ protected final void updateAsciiStream(int columnIndex, InputStream x, int length) throws SQLException {
+ rs.updateAsciiStream(columnIndex, x, length);
+ }
+
+ /**
+ * @param columnIndex
+ * @param x
+ * @param length
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateAsciiStream(int, java.io.InputStream, long)
+ */
+ protected final void updateAsciiStream(int columnIndex, InputStream x, long length) throws SQLException {
+ rs.updateAsciiStream(columnIndex, x, length);
+ }
+
+ /**
+ * @param columnIndex
+ * @param x
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateAsciiStream(int, java.io.InputStream)
+ */
+ protected final void updateAsciiStream(int columnIndex, InputStream x) throws SQLException {
+ rs.updateAsciiStream(columnIndex, x);
+ }
+
+ /**
+ * @param columnLabel
+ * @param x
+ * @param length
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateAsciiStream(java.lang.String, java.io.InputStream, int)
+ */
+ protected final void updateAsciiStream(String columnLabel, InputStream x, int length) throws SQLException {
+ rs.updateAsciiStream(columnLabel, x, length);
+ }
+
+ /**
+ * @param columnLabel
+ * @param x
+ * @param length
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateAsciiStream(java.lang.String, java.io.InputStream, long)
+ */
+ protected final void updateAsciiStream(String columnLabel, InputStream x, long length) throws SQLException {
+ rs.updateAsciiStream(columnLabel, x, length);
+ }
+
+ /**
+ * @param columnLabel
+ * @param x
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateAsciiStream(java.lang.String, java.io.InputStream)
+ */
+ protected final void updateAsciiStream(String columnLabel, InputStream x) throws SQLException {
+ rs.updateAsciiStream(columnLabel, x);
+ }
+
+ /**
+ * @param columnIndex
+ * @param x
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateBigDecimal(int, java.math.BigDecimal)
+ */
+ protected final void updateBigDecimal(int columnIndex, BigDecimal x) throws SQLException {
+ rs.updateBigDecimal(columnIndex, x);
+ }
+
+ /**
+ * @param columnLabel
+ * @param x
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateBigDecimal(java.lang.String, java.math.BigDecimal)
+ */
+ protected final void updateBigDecimal(String columnLabel, BigDecimal x) throws SQLException {
+ rs.updateBigDecimal(columnLabel, x);
+ }
+
+ /**
+ * @param columnIndex
+ * @param x
+ * @param length
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateBinaryStream(int, java.io.InputStream, int)
+ */
+ protected final void updateBinaryStream(int columnIndex, InputStream x, int length) throws SQLException {
+ rs.updateBinaryStream(columnIndex, x, length);
+ }
+
+ /**
+ * @param columnIndex
+ * @param x
+ * @param length
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateBinaryStream(int, java.io.InputStream, long)
+ */
+ protected final void updateBinaryStream(int columnIndex, InputStream x, long length) throws SQLException {
+ rs.updateBinaryStream(columnIndex, x, length);
+ }
+
+ /**
+ * @param columnIndex
+ * @param x
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateBinaryStream(int, java.io.InputStream)
+ */
+ protected final void updateBinaryStream(int columnIndex, InputStream x) throws SQLException {
+ rs.updateBinaryStream(columnIndex, x);
+ }
+
+ /**
+ * @param columnLabel
+ * @param x
+ * @param length
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateBinaryStream(java.lang.String, java.io.InputStream, int)
+ */
+ protected final void updateBinaryStream(String columnLabel, InputStream x, int length) throws SQLException {
+ rs.updateBinaryStream(columnLabel, x, length);
+ }
+
+ /**
+ * @param columnLabel
+ * @param x
+ * @param length
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateBinaryStream(java.lang.String, java.io.InputStream, long)
+ */
+ protected final void updateBinaryStream(String columnLabel, InputStream x, long length) throws SQLException {
+ rs.updateBinaryStream(columnLabel, x, length);
+ }
+
+ /**
+ * @param columnLabel
+ * @param x
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateBinaryStream(java.lang.String, java.io.InputStream)
+ */
+ protected final void updateBinaryStream(String columnLabel, InputStream x) throws SQLException {
+ rs.updateBinaryStream(columnLabel, x);
+ }
+
+ /**
+ * @param columnIndex
+ * @param x
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateBlob(int, java.sql.Blob)
+ */
+ protected final void updateBlob(int columnIndex, Blob x) throws SQLException {
+ rs.updateBlob(columnIndex, x);
+ }
+
+ /**
+ * @param columnIndex
+ * @param inputStream
+ * @param length
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateBlob(int, java.io.InputStream, long)
+ */
+ protected final void updateBlob(int columnIndex, InputStream inputStream, long length) throws SQLException {
+ rs.updateBlob(columnIndex, inputStream, length);
+ }
+
+ /**
+ * @param columnIndex
+ * @param inputStream
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateBlob(int, java.io.InputStream)
+ */
+ protected final void updateBlob(int columnIndex, InputStream inputStream) throws SQLException {
+ rs.updateBlob(columnIndex, inputStream);
+ }
+
+ /**
+ * @param columnLabel
+ * @param x
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateBlob(java.lang.String, java.sql.Blob)
+ */
+ protected final void updateBlob(String columnLabel, Blob x) throws SQLException {
+ rs.updateBlob(columnLabel, x);
+ }
+
+ /**
+ * @param columnLabel
+ * @param inputStream
+ * @param length
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateBlob(java.lang.String, java.io.InputStream, long)
+ */
+ protected final void updateBlob(String columnLabel, InputStream inputStream, long length) throws SQLException {
+ rs.updateBlob(columnLabel, inputStream, length);
+ }
+
+ /**
+ * @param columnLabel
+ * @param inputStream
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateBlob(java.lang.String, java.io.InputStream)
+ */
+ protected final void updateBlob(String columnLabel, InputStream inputStream) throws SQLException {
+ rs.updateBlob(columnLabel, inputStream);
+ }
+
+ /**
+ * @param columnIndex
+ * @param x
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateBoolean(int, boolean)
+ */
+ protected final void updateBoolean(int columnIndex, boolean x) throws SQLException {
+ rs.updateBoolean(columnIndex, x);
+ }
+
+ /**
+ * @param columnLabel
+ * @param x
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateBoolean(java.lang.String, boolean)
+ */
+ protected final void updateBoolean(String columnLabel, boolean x) throws SQLException {
+ rs.updateBoolean(columnLabel, x);
+ }
+
+ /**
+ * @param columnIndex
+ * @param x
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateByte(int, byte)
+ */
+ protected final void updateByte(int columnIndex, byte x) throws SQLException {
+ rs.updateByte(columnIndex, x);
+ }
+
+ /**
+ * @param columnLabel
+ * @param x
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateByte(java.lang.String, byte)
+ */
+ protected final void updateByte(String columnLabel, byte x) throws SQLException {
+ rs.updateByte(columnLabel, x);
+ }
+
+ /**
+ * @param columnIndex
+ * @param x
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateBytes(int, byte[])
+ */
+ protected final void updateBytes(int columnIndex, byte[] x) throws SQLException {
+ rs.updateBytes(columnIndex, x);
+ }
+
+ /**
+ * @param columnLabel
+ * @param x
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateBytes(java.lang.String, byte[])
+ */
+ protected final void updateBytes(String columnLabel, byte[] x) throws SQLException {
+ rs.updateBytes(columnLabel, x);
+ }
+
+ /**
+ * @param columnIndex
+ * @param x
+ * @param length
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateCharacterStream(int, java.io.Reader, int)
+ */
+ protected final void updateCharacterStream(int columnIndex, Reader x, int length) throws SQLException {
+ rs.updateCharacterStream(columnIndex, x, length);
+ }
+
+ /**
+ * @param columnIndex
+ * @param x
+ * @param length
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateCharacterStream(int, java.io.Reader, long)
+ */
+ protected final void updateCharacterStream(int columnIndex, Reader x, long length) throws SQLException {
+ rs.updateCharacterStream(columnIndex, x, length);
+ }
+
+ /**
+ * @param columnIndex
+ * @param x
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateCharacterStream(int, java.io.Reader)
+ */
+ protected final void updateCharacterStream(int columnIndex, Reader x) throws SQLException {
+ rs.updateCharacterStream(columnIndex, x);
+ }
+
+ /**
+ * @param columnLabel
+ * @param reader
+ * @param length
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateCharacterStream(java.lang.String, java.io.Reader, int)
+ */
+ protected final void updateCharacterStream(String columnLabel, Reader reader, int length) throws SQLException {
+ rs.updateCharacterStream(columnLabel, reader, length);
+ }
+
+ /**
+ * @param columnLabel
+ * @param reader
+ * @param length
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateCharacterStream(java.lang.String, java.io.Reader, long)
+ */
+ protected final void updateCharacterStream(String columnLabel, Reader reader, long length) throws SQLException {
+ rs.updateCharacterStream(columnLabel, reader, length);
+ }
+
+ /**
+ * @param columnLabel
+ * @param reader
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateCharacterStream(java.lang.String, java.io.Reader)
+ */
+ protected final void updateCharacterStream(String columnLabel, Reader reader) throws SQLException {
+ rs.updateCharacterStream(columnLabel, reader);
+ }
+
+ /**
+ * @param columnIndex
+ * @param x
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateClob(int, java.sql.Clob)
+ */
+ protected final void updateClob(int columnIndex, Clob x) throws SQLException {
+ rs.updateClob(columnIndex, x);
+ }
+
+ /**
+ * @param columnIndex
+ * @param reader
+ * @param length
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateClob(int, java.io.Reader, long)
+ */
+ protected final void updateClob(int columnIndex, Reader reader, long length) throws SQLException {
+ rs.updateClob(columnIndex, reader, length);
+ }
+
+ /**
+ * @param columnIndex
+ * @param reader
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateClob(int, java.io.Reader)
+ */
+ protected final void updateClob(int columnIndex, Reader reader) throws SQLException {
+ rs.updateClob(columnIndex, reader);
+ }
+
+ /**
+ * @param columnLabel
+ * @param x
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateClob(java.lang.String, java.sql.Clob)
+ */
+ protected final void updateClob(String columnLabel, Clob x) throws SQLException {
+ rs.updateClob(columnLabel, x);
+ }
+
+ /**
+ * @param columnLabel
+ * @param reader
+ * @param length
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateClob(java.lang.String, java.io.Reader, long)
+ */
+ protected final void updateClob(String columnLabel, Reader reader, long length) throws SQLException {
+ rs.updateClob(columnLabel, reader, length);
+ }
+
+ /**
+ * @param columnLabel
+ * @param reader
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateClob(java.lang.String, java.io.Reader)
+ */
+ protected final void updateClob(String columnLabel, Reader reader) throws SQLException {
+ rs.updateClob(columnLabel, reader);
+ }
+
+ /**
+ * @param columnIndex
+ * @param x
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateDate(int, java.sql.Date)
+ */
+ protected final void updateDate(int columnIndex, Date x) throws SQLException {
+ rs.updateDate(columnIndex, x);
+ }
+
+ /**
+ * @param columnLabel
+ * @param x
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateDate(java.lang.String, java.sql.Date)
+ */
+ protected final void updateDate(String columnLabel, Date x) throws SQLException {
+ rs.updateDate(columnLabel, x);
+ }
+
+ /**
+ * @param columnIndex
+ * @param x
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateDouble(int, double)
+ */
+ protected final void updateDouble(int columnIndex, double x) throws SQLException {
+ rs.updateDouble(columnIndex, x);
+ }
+
+ /**
+ * @param columnLabel
+ * @param x
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateDouble(java.lang.String, double)
+ */
+ protected final void updateDouble(String columnLabel, double x) throws SQLException {
+ rs.updateDouble(columnLabel, x);
+ }
+
+ /**
+ * @param columnIndex
+ * @param x
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateFloat(int, float)
+ */
+ protected final void updateFloat(int columnIndex, float x) throws SQLException {
+ rs.updateFloat(columnIndex, x);
+ }
+
+ /**
+ * @param columnLabel
+ * @param x
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateFloat(java.lang.String, float)
+ */
+ protected final void updateFloat(String columnLabel, float x) throws SQLException {
+ rs.updateFloat(columnLabel, x);
+ }
+
+ /**
+ * @param columnIndex
+ * @param x
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateInt(int, int)
+ */
+ protected final void updateInt(int columnIndex, int x) throws SQLException {
+ rs.updateInt(columnIndex, x);
+ }
+
+ /**
+ * @param columnLabel
+ * @param x
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateInt(java.lang.String, int)
+ */
+ protected final void updateInt(String columnLabel, int x) throws SQLException {
+ rs.updateInt(columnLabel, x);
+ }
+
+ /**
+ * @param columnIndex
+ * @param x
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateLong(int, long)
+ */
+ protected final void updateLong(int columnIndex, long x) throws SQLException {
+ rs.updateLong(columnIndex, x);
+ }
+
+ /**
+ * @param columnLabel
+ * @param x
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateLong(java.lang.String, long)
+ */
+ protected final void updateLong(String columnLabel, long x) throws SQLException {
+ rs.updateLong(columnLabel, x);
+ }
+
+ /**
+ * @param columnIndex
+ * @param x
+ * @param length
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateNCharacterStream(int, java.io.Reader, long)
+ */
+ protected final void updateNCharacterStream(int columnIndex, Reader x, long length) throws SQLException {
+ rs.updateNCharacterStream(columnIndex, x, length);
+ }
+
+ /**
+ * @param columnIndex
+ * @param x
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateNCharacterStream(int, java.io.Reader)
+ */
+ protected final void updateNCharacterStream(int columnIndex, Reader x) throws SQLException {
+ rs.updateNCharacterStream(columnIndex, x);
+ }
+
+ /**
+ * @param columnLabel
+ * @param reader
+ * @param length
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateNCharacterStream(java.lang.String, java.io.Reader, long)
+ */
+ protected final void updateNCharacterStream(String columnLabel, Reader reader, long length) throws SQLException {
+ rs.updateNCharacterStream(columnLabel, reader, length);
+ }
+
+ /**
+ * @param columnLabel
+ * @param reader
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateNCharacterStream(java.lang.String, java.io.Reader)
+ */
+ protected final void updateNCharacterStream(String columnLabel, Reader reader) throws SQLException {
+ rs.updateNCharacterStream(columnLabel, reader);
+ }
+
+ /**
+ * @param columnIndex
+ * @param nClob
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateNClob(int, java.sql.NClob)
+ */
+ protected final void updateNClob(int columnIndex, NClob nClob) throws SQLException {
+ rs.updateNClob(columnIndex, nClob);
+ }
+
+ /**
+ * @param columnIndex
+ * @param reader
+ * @param length
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateNClob(int, java.io.Reader, long)
+ */
+ protected final void updateNClob(int columnIndex, Reader reader, long length) throws SQLException {
+ rs.updateNClob(columnIndex, reader, length);
+ }
+
+ /**
+ * @param columnIndex
+ * @param reader
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateNClob(int, java.io.Reader)
+ */
+ protected final void updateNClob(int columnIndex, Reader reader) throws SQLException {
+ rs.updateNClob(columnIndex, reader);
+ }
+
+ /**
+ * @param columnLabel
+ * @param nClob
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateNClob(java.lang.String, java.sql.NClob)
+ */
+ protected final void updateNClob(String columnLabel, NClob nClob) throws SQLException {
+ rs.updateNClob(columnLabel, nClob);
+ }
+
+ /**
+ * @param columnLabel
+ * @param reader
+ * @param length
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateNClob(java.lang.String, java.io.Reader, long)
+ */
+ protected final void updateNClob(String columnLabel, Reader reader, long length) throws SQLException {
+ rs.updateNClob(columnLabel, reader, length);
+ }
+
+ /**
+ * @param columnLabel
+ * @param reader
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateNClob(java.lang.String, java.io.Reader)
+ */
+ protected final void updateNClob(String columnLabel, Reader reader) throws SQLException {
+ rs.updateNClob(columnLabel, reader);
+ }
+
+ /**
+ * @param columnIndex
+ * @param nString
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateNString(int, java.lang.String)
+ */
+ protected final void updateNString(int columnIndex, String nString) throws SQLException {
+ rs.updateNString(columnIndex, nString);
+ }
+
+ /**
+ * @param columnLabel
+ * @param nString
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateNString(java.lang.String, java.lang.String)
+ */
+ protected final void updateNString(String columnLabel, String nString) throws SQLException {
+ rs.updateNString(columnLabel, nString);
+ }
+
+ /**
+ * @param columnIndex
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateNull(int)
+ */
+ protected final void updateNull(int columnIndex) throws SQLException {
+ rs.updateNull(columnIndex);
+ }
+
+ /**
+ * @param columnLabel
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateNull(java.lang.String)
+ */
+ protected final void updateNull(String columnLabel) throws SQLException {
+ rs.updateNull(columnLabel);
+ }
+
+ /**
+ * @param columnIndex
+ * @param x
+ * @param scaleOrLength
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateObject(int, java.lang.Object, int)
+ */
+ protected final void updateObject(int columnIndex, Object x, int scaleOrLength) throws SQLException {
+ rs.updateObject(columnIndex, x, scaleOrLength);
+ }
+
+ /**
+ * @param columnIndex
+ * @param x
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateObject(int, java.lang.Object)
+ */
+ protected final void updateObject(int columnIndex, Object x) throws SQLException {
+ rs.updateObject(columnIndex, x);
+ }
+
+ /**
+ * @param columnLabel
+ * @param x
+ * @param scaleOrLength
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateObject(java.lang.String, java.lang.Object, int)
+ */
+ protected final void updateObject(String columnLabel, Object x, int scaleOrLength) throws SQLException {
+ rs.updateObject(columnLabel, x, scaleOrLength);
+ }
+
+ /**
+ * @param columnLabel
+ * @param x
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateObject(java.lang.String, java.lang.Object)
+ */
+ protected final void updateObject(String columnLabel, Object x) throws SQLException {
+ rs.updateObject(columnLabel, x);
+ }
+
+ /**
+ * @param columnIndex
+ * @param x
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateRef(int, java.sql.Ref)
+ */
+ protected final void updateRef(int columnIndex, Ref x) throws SQLException {
+ rs.updateRef(columnIndex, x);
+ }
+
+ /**
+ * @param columnLabel
+ * @param x
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateRef(java.lang.String, java.sql.Ref)
+ */
+ protected final void updateRef(String columnLabel, Ref x) throws SQLException {
+ rs.updateRef(columnLabel, x);
+ }
+
+ /**
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateRow()
+ */
+ protected final void updateRow() throws SQLException {
+ rs.updateRow();
+ }
+
+ /**
+ * @param columnIndex
+ * @param x
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateRowId(int, java.sql.RowId)
+ */
+ protected final void updateRowId(int columnIndex, RowId x) throws SQLException {
+ rs.updateRowId(columnIndex, x);
+ }
+
+ /**
+ * @param columnLabel
+ * @param x
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateRowId(java.lang.String, java.sql.RowId)
+ */
+ protected final void updateRowId(String columnLabel, RowId x) throws SQLException {
+ rs.updateRowId(columnLabel, x);
+ }
+
+ /**
+ * @param columnIndex
+ * @param xmlObject
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateSQLXML(int, java.sql.SQLXML)
+ */
+ protected final void updateSQLXML(int columnIndex, SQLXML xmlObject) throws SQLException {
+ rs.updateSQLXML(columnIndex, xmlObject);
+ }
+
+ /**
+ * @param columnLabel
+ * @param xmlObject
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateSQLXML(java.lang.String, java.sql.SQLXML)
+ */
+ protected final void updateSQLXML(String columnLabel, SQLXML xmlObject) throws SQLException {
+ rs.updateSQLXML(columnLabel, xmlObject);
+ }
+
+ /**
+ * @param columnIndex
+ * @param x
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateShort(int, short)
+ */
+ protected final void updateShort(int columnIndex, short x) throws SQLException {
+ rs.updateShort(columnIndex, x);
+ }
+
+ /**
+ * @param columnLabel
+ * @param x
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateShort(java.lang.String, short)
+ */
+ protected final void updateShort(String columnLabel, short x) throws SQLException {
+ rs.updateShort(columnLabel, x);
+ }
+
+ /**
+ * @param columnIndex
+ * @param x
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateString(int, java.lang.String)
+ */
+ protected final void updateString(int columnIndex, String x) throws SQLException {
+ rs.updateString(columnIndex, x);
+ }
+
+ /**
+ * @param columnLabel
+ * @param x
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateString(java.lang.String, java.lang.String)
+ */
+ protected final void updateString(String columnLabel, String x) throws SQLException {
+ rs.updateString(columnLabel, x);
+ }
+
+ /**
+ * @param columnIndex
+ * @param x
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateTime(int, java.sql.Time)
+ */
+ protected final void updateTime(int columnIndex, Time x) throws SQLException {
+ rs.updateTime(columnIndex, x);
+ }
+
+ /**
+ * @param columnLabel
+ * @param x
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateTime(java.lang.String, java.sql.Time)
+ */
+ protected final void updateTime(String columnLabel, Time x) throws SQLException {
+ rs.updateTime(columnLabel, x);
+ }
+
+ /**
+ * @param columnIndex
+ * @param x
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateTimestamp(int, java.sql.Timestamp)
+ */
+ protected final void updateTimestamp(int columnIndex, Timestamp x) throws SQLException {
+ rs.updateTimestamp(columnIndex, x);
+ }
+
+ /**
+ * @param columnLabel
+ * @param x
+ * @throws SQLException
+ * @see java.sql.ResultSet#updateTimestamp(java.lang.String, java.sql.Timestamp)
+ */
+ protected final void updateTimestamp(String columnLabel, Timestamp x) throws SQLException {
+ rs.updateTimestamp(columnLabel, x);
+ }
+
+ /**
+ * @return
+ * @throws SQLException
+ * @see java.sql.ResultSet#wasNull()
+ */
+ protected final boolean wasNull() throws SQLException {
+ return rs.wasNull();
+ }
+
+ protected final ResultSet getAdaptedResultSet() {
+ return rs;
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/main/java/org/apache/commons/dbutils2/BasicRowProcessor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/BasicRowProcessor.java b/src/main/java/org/apache/commons/dbutils2/BasicRowProcessor.java
new file mode 100644
index 0000000..51129f9
--- /dev/null
+++ b/src/main/java/org/apache/commons/dbutils2/BasicRowProcessor.java
@@ -0,0 +1,239 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.dbutils2;
+
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+/**
+ * Basic implementation of the <code>RowProcessor</code> interface.
+ *
+ * <p>
+ * This class is thread-safe.
+ * </p>
+ *
+ * @see RowProcessor
+ */
+public class BasicRowProcessor implements RowProcessor {
+
+ /**
+ * The default BeanProcessor instance to use if not supplied in the
+ * constructor.
+ */
+ private static final BeanProcessor defaultConvert = new BeanProcessor();
+
+ /**
+ * Use this to process beans.
+ */
+ private final BeanProcessor convert;
+
+ /**
+ * BasicRowProcessor constructor. Bean processing defaults to a
+ * BeanProcessor instance.
+ */
+ public BasicRowProcessor() {
+ this(defaultConvert);
+ }
+
+ /**
+ * BasicRowProcessor constructor.
+ * @param convert The BeanProcessor to use when converting columns to
+ * bean properties.
+ * @since DbUtils 1.1
+ */
+ public BasicRowProcessor(BeanProcessor convert) {
+ super();
+ this.convert = convert;
+ }
+
+ /**
+ * Convert a <code>ResultSet</code> row into an <code>Object[]</code>.
+ * This implementation copies column values into the array in the same
+ * order they're returned from the <code>ResultSet</code>. Array elements
+ * will be set to <code>null</code> if the column was SQL NULL.
+ *
+ * @see org.apache.commons.dbutils2.RowProcessor#toArray(java.sql.ResultSet)
+ * @param rs ResultSet that supplies the array data
+ * @throws SQLException if a database access error occurs
+ * @return the newly created array
+ */
+ @Override
+ public Object[] toArray(ResultSet rs) throws SQLException {
+ ResultSetMetaData meta = rs.getMetaData();
+ int cols = meta.getColumnCount();
+ Object[] result = new Object[cols];
+
+ for (int i = 0; i < cols; i++) {
+ result[i] = rs.getObject(i + 1);
+ }
+
+ return result;
+ }
+
+ /**
+ * Convert a <code>ResultSet</code> row into a JavaBean. This
+ * implementation delegates to a BeanProcessor instance.
+ * @see org.apache.commons.dbutils2.RowProcessor#toBean(java.sql.ResultSet, java.lang.Class)
+ * @see org.apache.commons.dbutils2.BeanProcessor#toBean(java.sql.ResultSet, java.lang.Class)
+ * @param <T> The type of bean to create
+ * @param rs ResultSet that supplies the bean data
+ * @param type Class from which to create the bean instance
+ * @throws SQLException if a database access error occurs
+ * @return the newly created bean
+ */
+ @Override
+ public <T> T toBean(ResultSet rs, Class<T> type) throws SQLException {
+ return this.convert.toBean(rs, type);
+ }
+
+ /**
+ * Convert a <code>ResultSet</code> into a <code>List</code> of JavaBeans.
+ * This implementation delegates to a BeanProcessor instance.
+ * @see org.apache.commons.dbutils2.RowProcessor#toBeanList(java.sql.ResultSet, java.lang.Class)
+ * @see org.apache.commons.dbutils2.BeanProcessor#toBeanList(java.sql.ResultSet, java.lang.Class)
+ * @param <T> The type of bean to create
+ * @param rs ResultSet that supplies the bean data
+ * @param type Class from which to create the bean instance
+ * @throws SQLException if a database access error occurs
+ * @return A <code>List</code> of beans with the given type in the order
+ * they were returned by the <code>ResultSet</code>.
+ */
+ @Override
+ public <T> List<T> toBeanList(ResultSet rs, Class<T> type) throws SQLException {
+ return this.convert.toBeanList(rs, type);
+ }
+
+ /**
+ * Convert a <code>ResultSet</code> row into a <code>Map</code>. This
+ * implementation returns a <code>Map</code> with case insensitive column
+ * names as keys. Calls to <code>map.get("COL")</code> and
+ * <code>map.get("col")</code> return the same value.
+ * @see org.apache.commons.dbutils2.RowProcessor#toMap(java.sql.ResultSet)
+ * @param rs ResultSet that supplies the map data
+ * @throws SQLException if a database access error occurs
+ * @return the newly created Map
+ */
+ @Override
+ public Map<String, Object> toMap(ResultSet rs) throws SQLException {
+ Map<String, Object> result = new CaseInsensitiveHashMap();
+ ResultSetMetaData rsmd = rs.getMetaData();
+ int cols = rsmd.getColumnCount();
+
+ for (int i = 1; i <= cols; i++) {
+ result.put(rsmd.getColumnName(i), rs.getObject(i));
+ }
+
+ return result;
+ }
+
+ /**
+ * A Map that converts all keys to lowercase Strings for case insensitive
+ * lookups. This is needed for the toMap() implementation because
+ * databases don't consistently handle the casing of column names.
+ *
+ * <p>The keys are stored as they are given [BUG #DBUTILS-34], so we maintain
+ * an internal mapping from lowercase keys to the real keys in order to
+ * achieve the case insensitive lookup.
+ *
+ * <p>Note: This implementation does not allow <tt>null</tt>
+ * for key, whereas {@link HashMap} does, because of the code:
+ * <pre>
+ * key.toString().toLowerCase()
+ * </pre>
+ */
+ private static class CaseInsensitiveHashMap extends HashMap<String, Object> {
+ /**
+ * The internal mapping from lowercase keys to the real keys.
+ *
+ * <p>
+ * Any query operation using the key
+ * ({@link #get(Object)}, {@link #containsKey(Object)})
+ * is done in three steps:
+ * <ul>
+ * <li>convert the parameter key to lower case</li>
+ * <li>get the actual key that corresponds to the lower case key</li>
+ * <li>query the map with the actual key</li>
+ * </ul>
+ * </p>
+ */
+ private final Map<String, String> lowerCaseMap = new HashMap<String, String>();
+
+ /**
+ * Required for serialization support.
+ *
+ * @see java.io.Serializable
+ */
+ private static final long serialVersionUID = -2848100435296897392L;
+
+ /** {@inheritDoc} */
+ @Override
+ public boolean containsKey(Object key) {
+ Object realKey = lowerCaseMap.get(key.toString().toLowerCase(Locale.ENGLISH));
+ return super.containsKey(realKey);
+ // Possible optimisation here:
+ // Since the lowerCaseMap contains a mapping for all the keys,
+ // we could just do this:
+ // return lowerCaseMap.containsKey(key.toString().toLowerCase());
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public Object get(Object key) {
+ Object realKey = lowerCaseMap.get(key.toString().toLowerCase(Locale.ENGLISH));
+ return super.get(realKey);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public Object put(String key, Object value) {
+ /*
+ * In order to keep the map and lowerCaseMap synchronized,
+ * we have to remove the old mapping before putting the
+ * new one. Indeed, oldKey and key are not necessaliry equals.
+ * (That's why we call super.remove(oldKey) and not just
+ * super.put(key, value))
+ */
+ Object oldKey = lowerCaseMap.put(key.toLowerCase(Locale.ENGLISH), key);
+ Object oldValue = super.remove(oldKey);
+ super.put(key, value);
+ return oldValue;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public void putAll(Map<? extends String, ?> m) {
+ for (Map.Entry<? extends String, ?> entry : m.entrySet()) {
+ String key = entry.getKey();
+ Object value = entry.getValue();
+ this.put(key, value);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public Object remove(Object key) {
+ Object realKey = lowerCaseMap.remove(key.toString().toLowerCase(Locale.ENGLISH));
+ return super.remove(realKey);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/main/java/org/apache/commons/dbutils2/BatchExecutor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/BatchExecutor.java b/src/main/java/org/apache/commons/dbutils2/BatchExecutor.java
new file mode 100644
index 0000000..cb1773e
--- /dev/null
+++ b/src/main/java/org/apache/commons/dbutils2/BatchExecutor.java
@@ -0,0 +1,117 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.dbutils2;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.sql.Types;
+
+/**
+ * This class provides the ability to execute a batch of statements.
+ *
+ * It is really just a facade to an array of UpdateExecutors.
+ *
+ * @author William Speirs <ws...@apache.org>
+ */
+public class BatchExecutor extends AbstractExecutor<BatchExecutor> {
+
+ private final boolean closeConn;
+
+ public BatchExecutor(final Connection conn, final String sql, final boolean closeConnection) throws SQLException {
+ super(conn, sql);
+ this.closeConn = closeConnection;
+ }
+
+ /**
+ * Binds a parameter name to a value for a given statement.
+ * @param statement the statement number to operate on.
+ * @param name the name of the parameter.
+ * @param value the value to bind to the parameter.
+ * @return this object.
+ * @throws SQLException thrown if the statement number does not exist, or any other SQLException.
+ * @see org.apache.commons.dbutils.UpdateExecutor.bind(String, Object)
+ */
+ @Override
+ public BatchExecutor bind(final String name, final Object value) throws SQLException {
+ return bind(name, value, false);
+ }
+
+ /**
+ * Binds null to a parameter.
+ * Types.VARCHAR is used as the type's parameter.
+ * This usually works, but fails with some Oracle and MS SQL drivers.
+ * @param name the name of the parameter.
+ * @return this execution object to provide the fluent style.
+ * @throws SQLException throw if the parameter is not found, already bound, or there is an issue binding null.
+ */
+ @Override
+ public BatchExecutor bindNull(final String name) throws SQLException {
+ return bindNull(name, Types.VARCHAR, false);
+ }
+
+ /**
+ * Binds null to a parameter, specifying the parameter's type.
+ * @param name the name of the parameter.
+ * @param sqlType the type of the parameter.
+ * @return this execution object to provide the fluent style.
+ * @throws SQLException throw if the parameter is not found, already bound, or there is an issue binding null.
+ */
+ @Override
+ public BatchExecutor bindNull(final String name, final int sqlType) throws SQLException {
+ return bindNull(name, sqlType, false);
+ }
+
+ /**
+ * Adds the statement to the batch after binding all of the parameters.
+ * @return this object.
+ * @throws SQLException if a SQLException is thrown during the addBatch() call.
+ * @see java.sql.PreparedStatement.addBatch()
+ */
+ public BatchExecutor addBatch() throws SQLException {
+ try {
+ getStatement().addBatch();
+ clearValueMap();
+ } catch(SQLException e) {
+ rethrow(e);
+ }
+
+ return this;
+ }
+
+ /**
+ * Calls batch after checking the parameters to ensure nothing is null.
+ * @return an array containing the number of rows updated for each statement.
+ * @throws SQLException If there are database or parameter errors.
+ * @see org.apache.commons.dbutils.UpdateExecutor.update()
+ */
+ public int[] execute() throws SQLException {
+ try {
+ return getStatement().executeBatch();
+ } catch (SQLException e) {
+ rethrow(e);
+ } finally {
+ close(getStatement());
+ if (closeConn) {
+ close(getConnection());
+ }
+ }
+
+ // we get here only if something is thrown
+ return null;
+ }
+
+}
[18/58] [abbrv] commons-dbutils git commit: Unnecessary
@SuppressWarnings
Posted by th...@apache.org.
Unnecessary @SuppressWarnings
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/dbutils/branches/2_0@1457560 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/commons-dbutils/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-dbutils/commit/afeafeac
Tree: http://git-wip-us.apache.org/repos/asf/commons-dbutils/tree/afeafeac
Diff: http://git-wip-us.apache.org/repos/asf/commons-dbutils/diff/afeafeac
Branch: refs/heads/2_0
Commit: afeafeacd5d6b81d47e1438d38d6f872373f640d
Parents: ac37a34
Author: Sebastian Bazley <se...@apache.org>
Authored: Sun Mar 17 20:49:26 2013 +0000
Committer: Sebastian Bazley <se...@apache.org>
Committed: Sun Mar 17 20:49:26 2013 +0000
----------------------------------------------------------------------
src/test/java/org/apache/commons/dbutils2/AsyncExecutorTest.java | 1 -
src/test/java/org/apache/commons/dbutils2/QueryRunnerTest.java | 1 -
2 files changed, 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/afeafeac/src/test/java/org/apache/commons/dbutils2/AsyncExecutorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils2/AsyncExecutorTest.java b/src/test/java/org/apache/commons/dbutils2/AsyncExecutorTest.java
index fe7f6f7..85657c3 100644
--- a/src/test/java/org/apache/commons/dbutils2/AsyncExecutorTest.java
+++ b/src/test/java/org/apache/commons/dbutils2/AsyncExecutorTest.java
@@ -34,7 +34,6 @@ import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
-@SuppressWarnings("boxing") // test code
public class AsyncExecutorTest {
AsyncExecutor runner;
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/afeafeac/src/test/java/org/apache/commons/dbutils2/QueryRunnerTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils2/QueryRunnerTest.java b/src/test/java/org/apache/commons/dbutils2/QueryRunnerTest.java
index 9944972..bc3de75 100644
--- a/src/test/java/org/apache/commons/dbutils2/QueryRunnerTest.java
+++ b/src/test/java/org/apache/commons/dbutils2/QueryRunnerTest.java
@@ -30,7 +30,6 @@ import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
-@SuppressWarnings("boxing") // test code
public class QueryRunnerTest {
QueryRunner runner;
[44/58] [abbrv] commons-dbutils git commit: Document fix
Posted by th...@apache.org.
Document fix
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/dbutils/branches/2_0@1482096 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/commons-dbutils/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-dbutils/commit/b389bb3e
Tree: http://git-wip-us.apache.org/repos/asf/commons-dbutils/tree/b389bb3e
Diff: http://git-wip-us.apache.org/repos/asf/commons-dbutils/diff/b389bb3e
Branch: refs/heads/2_0
Commit: b389bb3e0511803da2d2d3631b1d8f365ad61289
Parents: a45782e
Author: Sebastian Bazley <se...@apache.org>
Authored: Mon May 13 20:47:14 2013 +0000
Committer: Sebastian Bazley <se...@apache.org>
Committed: Mon May 13 20:47:14 2013 +0000
----------------------------------------------------------------------
src/changes/changes.xml | 3 +++
1 file changed, 3 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/b389bb3e/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 8c2f41c..04a3b04 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -48,6 +48,9 @@ The <action> type attribute can be add,update,fix,remove.
This is the first release of the 2.x branch of the Commons DbUtils package, DbUtils2.
The motivation for creating DbUtils2 was two-fold: a number of deprecated methods in the original DbUtils, and the desire to support named parameters (DBUTILS-105).
</action>
+ <action dev="sebb" type="fix" issue="DBUTILS-109">
+ AbstractExecutor.currentPosition should be an int
+ </action>
<action dev="wspeirs" type="add" issue="DBUTILS-105">
Added named parameter support with fluent API
</action>
[38/58] [abbrv] commons-dbutils git commit: Updated changes.xml file
per e-mail discussion
Posted by th...@apache.org.
Updated changes.xml file per e-mail discussion
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/dbutils/branches/2_0@1482043 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/commons-dbutils/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-dbutils/commit/04b2f8e0
Tree: http://git-wip-us.apache.org/repos/asf/commons-dbutils/tree/04b2f8e0
Diff: http://git-wip-us.apache.org/repos/asf/commons-dbutils/diff/04b2f8e0
Branch: refs/heads/2_0
Commit: 04b2f8e03e91305799af073ecd0a1f080cb3c7ce
Parents: 487aff9
Author: Bill Speirs <ws...@apache.org>
Authored: Mon May 13 19:32:14 2013 +0000
Committer: Bill Speirs <ws...@apache.org>
Committed: Mon May 13 19:32:14 2013 +0000
----------------------------------------------------------------------
src/changes/changes.xml | 231 +------------------------------------------
1 file changed, 3 insertions(+), 228 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/04b2f8e0/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 311c99f..dd38c43 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -44,238 +44,13 @@ The <action> type attribute can be add,update,fix,remove.
</properties>
<body>
<release version="2.0" date="2013-??-??" description="Backwards incompatible update of Commons DBUtils">
+ <action dev="wspeirs" type="add">
+ This is the first release of the 2.x branch of the Commons DbUtils package, DbUtils2.
+ The motivation for creating DbUtils2 was two-fold: a number of deprecated methods in the original DbUtils, and the desire to support named parameters (DBUTILS-105).
<action dev="wspeirs" type="add" issue="DBUTILS-105">
Added named parameter support with fluent API
</action>
</release>
- <release version="1.6" date="2013-??-??" description="Bugfixes and addition of insert methods">
- <action dev="simonetripodi" due-to="Moandji Ezana" type="add" issue="DBUTILS-98">
- Add missing JavaDoc to QueryRunner#insert
- </action>
- <action dev="simonetripodi" type="add" issue="DBUTILS-97">
- Add an Abstract ResultSetHandler implementation in order to reduce redundant 'resultSet' variable invocation
- </action>
- <action dev="wspeirs" due-to="Moandji Ezana" type="add" issue="DBUTILS-87">
- Added insert methods to QueryRunner and AsyncQueryRunner that return the generated key.
- </action>
- <action dev="simonetripodi" due-to="yuyf" type="fix" issue="DBUTILS-96">
- DbUtils#loadDriver(ClassLoader,String) makes DriverManager throwing "No suitable driver found for jdbc"
- if ClassLoader is not the System's one
- </action>
- </release>
- <release version="1.5" date="2012-07-20" description="Bugfixes and addition of BeanMapHandler">
- <action dev="simonetripodi" due-to="Benedikt Ritter" type="update" issue="DBUTILS-94">
- Provide test coverage for org.apache.commons.dbutils.DbUtils
- </action>
- <action dev="simonetripodi" due-to="Stevo Slavic" type="fix" issue="DBUTILS-93">
- Source assembly artifact fails to build a site because of missing pmd-ruleset.xml
- </action>
- <action dev="simonetripodi" due-to="Stevo Slavic" type="update" issue="DBUTILS-91">
- Enhance BasicRowProcessor to have row mapping easier to configure
- </action>
- <action due-to="wspeirs" type="update">
- Updated pom.xml: Java 1.6 now required, clirr and compiler plugin removed
- </action>
- <action due-to="Tiago Cavaleiro" dev="wspeirs" type="fix" issue="DBUTILS-84">
- BeanProcessor method processColumn should take SQLXML in consideration
- </action>
- <action dev="wspeirs" type="update" issue="DBUTILS-77">
- Updated documentation to better reflect the use of pmdKnownBroken
- </action>
- <action due-to="Sebb" type="fix" issue="DBUTILS-73">
- Added a fixed Locale (Locale.ENGLISH) to all toLowerCase calls in BasicRowProcessor
- </action>
- <action due-to="Michael Osipov" type="add" issue="DBUTILS-67">
- Added BeanMapHandler
- </action>
- <action due-to="Michael Osipov" type="update" issue="DBUTILS-66">
- Added generics to ScalarHandler, ColumnHandler, and KeyedHandler
- </action>
- </release>
- <release version="1.4" date="2011-10-23" description="Bugfixes and addition of asynchronous QueryLoader">
- <action type="fix" issue="DBUTILS-81">
- DbUtils.loadDriver() uses Class.forName()
- </action>
- <action type="fix" issue="DBUTILS-80">
- DbUtils.loadDriver catches Throwable
- </action>
- <action type="fix" issue="DBUTILS-65">
- Duplicate code introduced during Java 1.5 branch merge
- </action>
- <action type="fix" issue="DBUTILS-79">
- fillStatement doesn't complain when there are too few parameters
- </action>
- <action type="update" issue="DBUTILS-75">
- efficient usage from findbugs
- </action>
- <action dev="wspeirs" type="add" issue="DBUTILS-78">
- Add asynchronous batch, query, and update calls
- </action>
- </release>
- <release version="1.3" date="2009-11-04" description="Adds Java5 generics and varargs">
- <action dev="dfabulich" type="add" issue="DBUTILS-48">
- Java 1.5 generics and varargs
- </action>
- <action dev="dfabulich" type="update" issue="DBUTILS-57">
- BeanProcessor#mapColumnsToProperties now prefers to use column labels over column names (where aliases are not set, these should be identical)
- </action>
- <action dev="dfabulich" type="update" issue="DBUTILS-58">
- Setting pmdKnownBroken in QueryRunner constructor now completely ignores ParameterMetaData
- </action>
- <action dev="dfabulich" type="fix" issue="DBUTILS-60">
- Fixed error message in QueryRunner#rethrow
- </action>
- </release>
- <release version="1.2" date="2009-03-06" description="Another round of fixes; deprecates methods in preparation for varargs in java5">
- <action dev="dfabulich" type="update" issue="DBUTILS-52">
- Removed setDataSource method to guarantee thread safety
- </action>
- <action dev="sebb" type="update" issue="DBUTILS-51">
- Made numerous private instance members final to guarantee thread safety; changed protected member of KeyedHandler to final
- </action>
- <action dev="bayard" type="remove">
- Remove old Maven1/Ant build scripts
- </action>
- <action dev="dfabulich" type="update" issue="DBUTILS-29">
- Support bean property to SQL IN parameter mapping
- </action>
- <action dev="dfabulich" type="fix" issue="DBUTILS-31">
- fillStatement setNull bug with the Postgres/Derby JDBC driver (and others)
- </action>
- <action dev="dfabulich" type="update" issue="DBUTILS-33">
- Make GenericListHandler (now AbstractListHandler) public
- </action>
- <action dev="dfabulich" type="update" issue="DBUTILS-34">
- BasicRowProcessor loses any information on database field case
- </action>
- <action dev="dfabulich" type="update" issue="DBUTILS-37">
- BeanListHandler#handle(ResultSet) is not optimal
- </action>
- <action dev="dfabulich" type="fix" issue="DBUTILS-40">
- NullPointerException occured at rethrow method
- </action>
- <action dev="dfabulich" type="update" issue="DBUTILS-42">
- Object with Long or Decimal got initial zero value while database field is null
- </action>
- <action dev="dennisl" type="update" issue="DBUTILS-38">
- example documentation page, update query
- </action>
- <action dev="bayard" type="fix" issue="DBUTILS-36">
- Add serialVersionUID to BasicRowProcessor.CaseInsensitiveHashMap
- </action>
- </release>
- <release version="1.1" date="2006-12-01" description="Last couple of years of fixes">
-
- <action dev="bayard" type="fix" issue="DBUTILS-32">
- Tests fail to build under 1.6, and warning while compiling source
- </action>
- <action dev="bayard" type="fix" issue="DBUTILS-1">
- BeanListHandler and BeanHandler fail to support java.sql.Date()
- </action>
- <action dev="bayard" type="update" issue="DBUTILS-16">
- ResultSetRowProcessor abstract handler and some classes rework
- </action>
- <action dev="bayard" type="fix" issue="DBUTILS-3">
- Setting bean properties fails silently
- </action>
- <action dev="dgraham" type="fix" issue="DBUTILS-9">
- MockResultSet needs to handle equals and hashCode
- </action>
- <action dev="bayard" type="fix" issue="DBUTILS-7">
- MockResultSet: Throw UnsupportedOperationException for not implemented methods
- </action>
- <action dev="dgraham" type="add" issue="DBUTILS-20">
- Implement Pluggable Adaptors to Make BeanHandler Smarter
- </action>
- <action dev="dgraham" type="update" issue="DBUTILS-15">
- Patch for extending BasicRowProcessor
- </action>
- <action dev="dgraham" type="add" issue="DBUTILS-12">
- Protected QueryRunner.close() methods
- </action>
- <action dev="dgraham" type="update" issue="DBUTILS-23">
- Updated docs for example.html page (select AS)
- </action>
- <action dev="dgraham" type="add" issue="DBUTILS-4">
- Added protected ResultSetIterator.rethrow() method to wrap SQLExceptions in
- RuntimeExceptions.
- </action>
- <action dev="dgraham" type="update" issue="DBUTILS-5">
- Added SQLState and error code to rethrown SQLExceptions.
- </action>
- <action dev="dgraham" type="add" issue="DBUTILS-25">
- Added KeyedHandler to create a Map of Maps from a ResultSet.
- </action>
- <action dev="dgraham" type="update" issue="DBUTILS-2">
- Use current class' ClassLoader instead of QueryLoader's ClassLoader
- in loadQueries().
- </action>
- <action dev="dgraham" type="update" issue="DBUTILS-22">
- Made QueryLoader.loadQueries() protected so subclasses can use query
- repositories other than properties files.
- </action>
- <action dev="dgraham" type="update">
- QueryRunner now calls getDataSource() internally any time it needs access
- to its DataSource object to allow subclasses to provide different behavior.
- </action>
- <action dev="dgraham" type="add">
- Added DbUtils.rollbackAndClose() and DbUtils.rollbackAndCloseQuietly().
- </action>
- <action dev="dgraham" type="update" issue="DBUTILS-26">
- Call ResultSet.getTimestamp() in BeanProcessor.processColumn() if
- the bean property is a java.sql.Timestamp. Oracle's getObject()
- implementation returns its own incompatible Timestamp class.
- </action>
- <action dev="dgraham" type="update" issue="DBUTILS-18">
- Changed QueryRunner.fillStatement() null handling
- to use Types.VARCHAR instead of Types.OTHER. This works for the
- following tested drivers: Firebird 1.5/firebirdsql 1.5RC3,
- Oracle 9/ Thin driver, MySQL 4.0/Msql Connecttor 3.0 and mm.mysql
- 2.0.4 MaxDB 7.5, HSQLDB 1.7.1, and MS Access/ODBC Bridge.
- </action>
- <action dev="dgraham" type="add" issue="DBUTILS-21">
- Added a protected QueryRunner.prepareConnection() method to
- allow subclasses to customize the Connections retrieved from
- the DataSource before they're used.
- </action>
- <action dev="dgraham" type="add">
- Refactored bean handling from BasicRowProcessor into new
- BeanProcessor class. This also fixes the common problem with
- Oracle NUMERIC fields not being set into bean properties.
- </action>
- <action dev="dgraham" type="add" issue="DBUTILS-13">
- Added QueryRunner.batch() methods for batch updates.
- </action>
- <action dev="dgraham" type="add" issue="DBUTILS-11">
- Added new ResultSetHandler implementation, ColumnListHandler, that
- converts one ResultSet column into a List of Objects.
- </action>
- </release>
-
- <release version="1.0" date="2003-11-10" description="First release of DbUtils">
- <action type="add">
- This is the first release of the Commons DbUtils package. DbUtils
- is a small set of classes designed to make working with JDBC easier.
- </action>
- <action type="add">
- QueryRunner class with ResultSetHandler interface allow you to easily query or
- update a database and handle the ResultSet. Several useful implementations
- of the ResultSetHandler interface are located in the
- org.apache.commons.dbutils.handlers.* package.
- </action>
- <action type="add">
- ResultSet wrappers that decorate ResultSets with specialized
- behavior. See the classes in the org.apache.commons.dbutils.wrappers.*
- package for details.
- </action>
- <action type="add">
- Dynamic JDBC API interface implementations via the standard
- java.lang.reflect.Proxy class. This allows you to implement JDBC
- interfaces such as ResultSet at runtime to avoid API version
- incompatibilities. See org.apache.commons.dbutils.ProxyFactory
- for details.
- </action>
- </release>
</body>
</document>
[52/58] [abbrv] commons-dbutils git commit: ArrayHandler is no longer
generic
Posted by th...@apache.org.
ArrayHandler is no longer generic
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/dbutils/branches/2_0@1482409 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/commons-dbutils/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-dbutils/commit/1ae657bf
Tree: http://git-wip-us.apache.org/repos/asf/commons-dbutils/tree/1ae657bf
Diff: http://git-wip-us.apache.org/repos/asf/commons-dbutils/diff/1ae657bf
Branch: refs/heads/2_0
Commit: 1ae657bfd203e6ed659e2fb4dba0be2ac1e63214
Parents: c0dba07
Author: Sebastian Bazley <se...@apache.org>
Authored: Tue May 14 15:49:42 2013 +0000
Committer: Sebastian Bazley <se...@apache.org>
Committed: Tue May 14 15:49:42 2013 +0000
----------------------------------------------------------------------
.../org/apache/commons/dbutils2/handlers/ArrayHandlerTest.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/1ae657bf/src/test/java/org/apache/commons/dbutils2/handlers/ArrayHandlerTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils2/handlers/ArrayHandlerTest.java b/src/test/java/org/apache/commons/dbutils2/handlers/ArrayHandlerTest.java
index 847a5e5..b893b89 100644
--- a/src/test/java/org/apache/commons/dbutils2/handlers/ArrayHandlerTest.java
+++ b/src/test/java/org/apache/commons/dbutils2/handlers/ArrayHandlerTest.java
@@ -28,7 +28,7 @@ import org.apache.commons.dbutils2.handlers.ArrayHandler;
public class ArrayHandlerTest extends BaseTestCase {
public void testHandle() throws SQLException {
- ResultSetHandler<Object[]> h = new ArrayHandler<Object>();
+ ResultSetHandler<Object[]> h = new ArrayHandler();
Object[] results = h.handle(this.rs);
assertNotNull(results);
@@ -39,7 +39,7 @@ public class ArrayHandlerTest extends BaseTestCase {
}
public void testEmptyResultSetHandle() throws SQLException {
- ResultSetHandler<Object[]> h = new ArrayHandler<Object>();
+ ResultSetHandler<Object[]> h = new ArrayHandler();
Object[] results = h.handle(this.emptyResultSet);
assertNull(results);
[53/58] [abbrv] commons-dbutils git commit: Don't omit Apache from
the name
Posted by th...@apache.org.
Don't omit Apache from the name
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/dbutils/branches/2_0@1482414 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/commons-dbutils/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-dbutils/commit/949c5d9c
Tree: http://git-wip-us.apache.org/repos/asf/commons-dbutils/tree/949c5d9c
Diff: http://git-wip-us.apache.org/repos/asf/commons-dbutils/diff/949c5d9c
Branch: refs/heads/2_0
Commit: 949c5d9c3b2a4cbc9f26620dcfa2901c17ef671c
Parents: 1ae657b
Author: Sebastian Bazley <se...@apache.org>
Authored: Tue May 14 16:04:06 2013 +0000
Committer: Sebastian Bazley <se...@apache.org>
Committed: Tue May 14 16:04:06 2013 +0000
----------------------------------------------------------------------
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/949c5d9c/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 4ba01d4..bd7096d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -25,7 +25,7 @@
<groupId>org.apache.commons</groupId>
<artifactId>commons-dbutils</artifactId>
<version>2.0-SNAPSHOT</version>
- <name>Commons DbUtils</name>
+ <name>Apache Commons DbUtils</name>
<inceptionYear>2002</inceptionYear>
<description>The Apache Commons-DbUtils package is a set of
[19/58] [abbrv] commons-dbutils git commit: Suppress boxing warnings
for test code
Posted by th...@apache.org.
Suppress boxing warnings for test code
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/dbutils/branches/2_0@1457562 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/commons-dbutils/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-dbutils/commit/2d180b9f
Tree: http://git-wip-us.apache.org/repos/asf/commons-dbutils/tree/2d180b9f
Diff: http://git-wip-us.apache.org/repos/asf/commons-dbutils/diff/2d180b9f
Branch: refs/heads/2_0
Commit: 2d180b9f04605502e16add8620c32c74ed77e44f
Parents: afeafea
Author: Sebastian Bazley <se...@apache.org>
Authored: Sun Mar 17 20:55:18 2013 +0000
Committer: Sebastian Bazley <se...@apache.org>
Committed: Sun Mar 17 20:55:18 2013 +0000
----------------------------------------------------------------------
.../java/org/apache/commons/dbutils2/GenerousBeanProcessorTest.java | 1 +
src/test/java/org/apache/commons/dbutils2/UpdateExecutorTest.java | 1 +
2 files changed, 2 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/2d180b9f/src/test/java/org/apache/commons/dbutils2/GenerousBeanProcessorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils2/GenerousBeanProcessorTest.java b/src/test/java/org/apache/commons/dbutils2/GenerousBeanProcessorTest.java
index 11d0394..c31bcdd 100644
--- a/src/test/java/org/apache/commons/dbutils2/GenerousBeanProcessorTest.java
+++ b/src/test/java/org/apache/commons/dbutils2/GenerousBeanProcessorTest.java
@@ -29,6 +29,7 @@ import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
+@SuppressWarnings("boxing") // test code
public class GenerousBeanProcessorTest {
GenerousBeanProcessor processor = new GenerousBeanProcessor();
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/2d180b9f/src/test/java/org/apache/commons/dbutils2/UpdateExecutorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils2/UpdateExecutorTest.java b/src/test/java/org/apache/commons/dbutils2/UpdateExecutorTest.java
index 462fa4d..d245dba 100644
--- a/src/test/java/org/apache/commons/dbutils2/UpdateExecutorTest.java
+++ b/src/test/java/org/apache/commons/dbutils2/UpdateExecutorTest.java
@@ -39,6 +39,7 @@ public class UpdateExecutorTest {
@Mock private Connection conn;
@Mock private PreparedStatement stmt;
+ @SuppressWarnings("boxing") // test code
@Before
public void setup() throws SQLException {
MockitoAnnotations.initMocks(this);
[21/58] [abbrv] commons-dbutils git commit: Suppress boxing warnings
for test code
Posted by th...@apache.org.
Suppress boxing warnings for test code
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/dbutils/branches/2_0@1457565 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/commons-dbutils/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-dbutils/commit/df2e2f38
Tree: http://git-wip-us.apache.org/repos/asf/commons-dbutils/tree/df2e2f38
Diff: http://git-wip-us.apache.org/repos/asf/commons-dbutils/diff/df2e2f38
Branch: refs/heads/2_0
Commit: df2e2f389418462a72e597f5fc8a4b09e54a8261
Parents: 946aadb
Author: Sebastian Bazley <se...@apache.org>
Authored: Sun Mar 17 21:09:34 2013 +0000
Committer: Sebastian Bazley <se...@apache.org>
Committed: Sun Mar 17 21:09:34 2013 +0000
----------------------------------------------------------------------
src/test/java/org/apache/commons/dbutils2/AbstractExecutorTest.java | 1 +
1 file changed, 1 insertion(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/df2e2f38/src/test/java/org/apache/commons/dbutils2/AbstractExecutorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils2/AbstractExecutorTest.java b/src/test/java/org/apache/commons/dbutils2/AbstractExecutorTest.java
index 61fcc91..1d7c270 100644
--- a/src/test/java/org/apache/commons/dbutils2/AbstractExecutorTest.java
+++ b/src/test/java/org/apache/commons/dbutils2/AbstractExecutorTest.java
@@ -70,6 +70,7 @@ public class AbstractExecutorTest {
executor.throwIfUnmappedParams();
}
+ @SuppressWarnings("boxing") // test code
@Test
public void testNoParamsSql() throws SQLException {
createExecutor("select * from blah");
[06/58] [abbrv] commons-dbutils git commit: Changed the package names
so dbutils and dbutils2 won't conflict if both loaded
Posted by th...@apache.org.
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/main/java/org/apache/commons/dbutils2/BeanProcessor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/BeanProcessor.java b/src/main/java/org/apache/commons/dbutils2/BeanProcessor.java
new file mode 100644
index 0000000..46c089b
--- /dev/null
+++ b/src/main/java/org/apache/commons/dbutils2/BeanProcessor.java
@@ -0,0 +1,504 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.dbutils2;
+
+import java.beans.BeanInfo;
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
+import java.sql.SQLXML;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * <p>
+ * <code>BeanProcessor</code> matches column names to bean property names
+ * and converts <code>ResultSet</code> columns into objects for those bean
+ * properties. Subclasses should override the methods in the processing chain
+ * to customize behavior.
+ * </p>
+ *
+ * <p>
+ * This class is thread-safe.
+ * </p>
+ *
+ * @see BasicRowProcessor
+ *
+ * @since DbUtils 1.1
+ */
+public class BeanProcessor {
+
+ /**
+ * Special array value used by <code>mapColumnsToProperties</code> that
+ * indicates there is no bean property that matches a column from a
+ * <code>ResultSet</code>.
+ */
+ protected static final int PROPERTY_NOT_FOUND = -1;
+
+ /**
+ * Set a bean's primitive properties to these defaults when SQL NULL
+ * is returned. These are the same as the defaults that ResultSet get*
+ * methods return in the event of a NULL column.
+ */
+ private static final Map<Class<?>, Object> primitiveDefaults = new HashMap<Class<?>, Object>();
+
+ /**
+ * ResultSet column to bean property name overrides.
+ */
+ private final Map<String, String> columnToPropertyOverrides;
+
+ static {
+ primitiveDefaults.put(Integer.TYPE, Integer.valueOf(0));
+ primitiveDefaults.put(Short.TYPE, Short.valueOf((short) 0));
+ primitiveDefaults.put(Byte.TYPE, Byte.valueOf((byte) 0));
+ primitiveDefaults.put(Float.TYPE, Float.valueOf(0f));
+ primitiveDefaults.put(Double.TYPE, Double.valueOf(0d));
+ primitiveDefaults.put(Long.TYPE, Long.valueOf(0L));
+ primitiveDefaults.put(Boolean.TYPE, Boolean.FALSE);
+ primitiveDefaults.put(Character.TYPE, Character.valueOf((char) 0));
+ }
+
+ /**
+ * Constructor for BeanProcessor.
+ */
+ public BeanProcessor() {
+ this(new HashMap<String, String>());
+ }
+
+ /**
+ * Constructor for BeanProcessor configured with column to property name overrides.
+ *
+ * @param columnToPropertyOverrides ResultSet column to bean property name overrides
+ * @since 1.5
+ */
+ public BeanProcessor(Map<String, String> columnToPropertyOverrides) {
+ super();
+ if (columnToPropertyOverrides == null) {
+ throw new IllegalArgumentException("columnToPropertyOverrides map cannot be null");
+ }
+ this.columnToPropertyOverrides = columnToPropertyOverrides;
+ }
+
+ /**
+ * Convert a <code>ResultSet</code> row into a JavaBean. This
+ * implementation uses reflection and <code>BeanInfo</code> classes to
+ * match column names to bean property names. Properties are matched to
+ * columns based on several factors:
+ * <br/>
+ * <ol>
+ * <li>
+ * The class has a writable property with the same name as a column.
+ * The name comparison is case insensitive.
+ * </li>
+ *
+ * <li>
+ * The column type can be converted to the property's set method
+ * parameter type with a ResultSet.get* method. If the conversion fails
+ * (ie. the property was an int and the column was a Timestamp) an
+ * SQLException is thrown.
+ * </li>
+ * </ol>
+ *
+ * <p>
+ * Primitive bean properties are set to their defaults when SQL NULL is
+ * returned from the <code>ResultSet</code>. Numeric fields are set to 0
+ * and booleans are set to false. Object bean properties are set to
+ * <code>null</code> when SQL NULL is returned. This is the same behavior
+ * as the <code>ResultSet</code> get* methods.
+ * </p>
+ * @param <T> The type of bean to create
+ * @param rs ResultSet that supplies the bean data
+ * @param type Class from which to create the bean instance
+ * @throws SQLException if a database access error occurs
+ * @return the newly created bean
+ */
+ public <T> T toBean(ResultSet rs, Class<T> type) throws SQLException {
+
+ PropertyDescriptor[] props = this.propertyDescriptors(type);
+
+ ResultSetMetaData rsmd = rs.getMetaData();
+ int[] columnToProperty = this.mapColumnsToProperties(rsmd, props);
+
+ return this.createBean(rs, type, props, columnToProperty);
+ }
+
+ /**
+ * Convert a <code>ResultSet</code> into a <code>List</code> of JavaBeans.
+ * This implementation uses reflection and <code>BeanInfo</code> classes to
+ * match column names to bean property names. Properties are matched to
+ * columns based on several factors:
+ * <br/>
+ * <ol>
+ * <li>
+ * The class has a writable property with the same name as a column.
+ * The name comparison is case insensitive.
+ * </li>
+ *
+ * <li>
+ * The column type can be converted to the property's set method
+ * parameter type with a ResultSet.get* method. If the conversion fails
+ * (ie. the property was an int and the column was a Timestamp) an
+ * SQLException is thrown.
+ * </li>
+ * </ol>
+ *
+ * <p>
+ * Primitive bean properties are set to their defaults when SQL NULL is
+ * returned from the <code>ResultSet</code>. Numeric fields are set to 0
+ * and booleans are set to false. Object bean properties are set to
+ * <code>null</code> when SQL NULL is returned. This is the same behavior
+ * as the <code>ResultSet</code> get* methods.
+ * </p>
+ * @param <T> The type of bean to create
+ * @param rs ResultSet that supplies the bean data
+ * @param type Class from which to create the bean instance
+ * @throws SQLException if a database access error occurs
+ * @return the newly created List of beans
+ */
+ public <T> List<T> toBeanList(ResultSet rs, Class<T> type) throws SQLException {
+ List<T> results = new ArrayList<T>();
+
+ if (!rs.next()) {
+ return results;
+ }
+
+ PropertyDescriptor[] props = this.propertyDescriptors(type);
+ ResultSetMetaData rsmd = rs.getMetaData();
+ int[] columnToProperty = this.mapColumnsToProperties(rsmd, props);
+
+ do {
+ results.add(this.createBean(rs, type, props, columnToProperty));
+ } while (rs.next());
+
+ return results;
+ }
+
+ /**
+ * Creates a new object and initializes its fields from the ResultSet.
+ * @param <T> The type of bean to create
+ * @param rs The result set.
+ * @param type The bean type (the return type of the object).
+ * @param props The property descriptors.
+ * @param columnToProperty The column indices in the result set.
+ * @return An initialized object.
+ * @throws SQLException if a database error occurs.
+ */
+ private <T> T createBean(ResultSet rs, Class<T> type,
+ PropertyDescriptor[] props, int[] columnToProperty)
+ throws SQLException {
+
+ T bean = this.newInstance(type);
+
+ for (int i = 1; i < columnToProperty.length; i++) {
+
+ if (columnToProperty[i] == PROPERTY_NOT_FOUND) {
+ continue;
+ }
+
+ PropertyDescriptor prop = props[columnToProperty[i]];
+ Class<?> propType = prop.getPropertyType();
+
+ Object value = this.processColumn(rs, i, propType);
+
+ if (propType != null && value == null && propType.isPrimitive()) {
+ value = primitiveDefaults.get(propType);
+ }
+
+ this.callSetter(bean, prop, value);
+ }
+
+ return bean;
+ }
+
+ /**
+ * Calls the setter method on the target object for the given property.
+ * If no setter method exists for the property, this method does nothing.
+ * @param target The object to set the property on.
+ * @param prop The property to set.
+ * @param value The value to pass into the setter.
+ * @throws SQLException if an error occurs setting the property.
+ */
+ private void callSetter(Object target, PropertyDescriptor prop, Object value)
+ throws SQLException {
+
+ Method setter = prop.getWriteMethod();
+
+ if (setter == null) {
+ return;
+ }
+
+ Class<?>[] params = setter.getParameterTypes();
+ try {
+ // convert types for some popular ones
+ if (value instanceof java.util.Date) {
+ final String targetType = params[0].getName();
+ if ("java.sql.Date".equals(targetType)) {
+ value = new java.sql.Date(((java.util.Date) value).getTime());
+ } else
+ if ("java.sql.Time".equals(targetType)) {
+ value = new java.sql.Time(((java.util.Date) value).getTime());
+ } else
+ if ("java.sql.Timestamp".equals(targetType)) {
+ value = new java.sql.Timestamp(((java.util.Date) value).getTime());
+ }
+ }
+
+ // Don't call setter if the value object isn't the right type
+ if (this.isCompatibleType(value, params[0])) {
+ setter.invoke(target, new Object[]{value});
+ } else {
+ throw new SQLException(
+ "Cannot set " + prop.getName() + ": incompatible types, cannot convert "
+ + value.getClass().getName() + " to " + params[0].getName());
+ // value cannot be null here because isCompatibleType allows null
+ }
+
+ } catch (IllegalArgumentException e) {
+ throw new SQLException(
+ "Cannot set " + prop.getName() + ": " + e.getMessage());
+
+ } catch (IllegalAccessException e) {
+ throw new SQLException(
+ "Cannot set " + prop.getName() + ": " + e.getMessage());
+
+ } catch (InvocationTargetException e) {
+ throw new SQLException(
+ "Cannot set " + prop.getName() + ": " + e.getMessage());
+ }
+ }
+
+ /**
+ * ResultSet.getObject() returns an Integer object for an INT column. The
+ * setter method for the property might take an Integer or a primitive int.
+ * This method returns true if the value can be successfully passed into
+ * the setter method. Remember, Method.invoke() handles the unwrapping
+ * of Integer into an int.
+ *
+ * @param value The value to be passed into the setter method.
+ * @param type The setter's parameter type (non-null)
+ * @return boolean True if the value is compatible (null => true)
+ */
+ private boolean isCompatibleType(Object value, Class<?> type) {
+ // Do object check first, then primitives
+ if (value == null || type.isInstance(value)) {
+ return true;
+
+ } else if (type.equals(Integer.TYPE) && Integer.class.isInstance(value)) {
+ return true;
+
+ } else if (type.equals(Long.TYPE) && Long.class.isInstance(value)) {
+ return true;
+
+ } else if (type.equals(Double.TYPE) && Double.class.isInstance(value)) {
+ return true;
+
+ } else if (type.equals(Float.TYPE) && Float.class.isInstance(value)) {
+ return true;
+
+ } else if (type.equals(Short.TYPE) && Short.class.isInstance(value)) {
+ return true;
+
+ } else if (type.equals(Byte.TYPE) && Byte.class.isInstance(value)) {
+ return true;
+
+ } else if (type.equals(Character.TYPE) && Character.class.isInstance(value)) {
+ return true;
+
+ } else if (type.equals(Boolean.TYPE) && Boolean.class.isInstance(value)) {
+ return true;
+
+ }
+ return false;
+
+ }
+
+ /**
+ * Factory method that returns a new instance of the given Class. This
+ * is called at the start of the bean creation process and may be
+ * overridden to provide custom behavior like returning a cached bean
+ * instance.
+ * @param <T> The type of object to create
+ * @param c The Class to create an object from.
+ * @return A newly created object of the Class.
+ * @throws SQLException if creation failed.
+ */
+ protected <T> T newInstance(Class<T> c) throws SQLException {
+ try {
+ return c.newInstance();
+
+ } catch (InstantiationException e) {
+ throw new SQLException(
+ "Cannot create " + c.getName() + ": " + e.getMessage());
+
+ } catch (IllegalAccessException e) {
+ throw new SQLException(
+ "Cannot create " + c.getName() + ": " + e.getMessage());
+ }
+ }
+
+ /**
+ * Returns a PropertyDescriptor[] for the given Class.
+ *
+ * @param c The Class to retrieve PropertyDescriptors for.
+ * @return A PropertyDescriptor[] describing the Class.
+ * @throws SQLException if introspection failed.
+ */
+ private PropertyDescriptor[] propertyDescriptors(Class<?> c)
+ throws SQLException {
+ // Introspector caches BeanInfo classes for better performance
+ BeanInfo beanInfo = null;
+ try {
+ beanInfo = Introspector.getBeanInfo(c);
+
+ } catch (IntrospectionException e) {
+ throw new SQLException(
+ "Bean introspection failed: " + e.getMessage());
+ }
+
+ return beanInfo.getPropertyDescriptors();
+ }
+
+ /**
+ * The positions in the returned array represent column numbers. The
+ * values stored at each position represent the index in the
+ * <code>PropertyDescriptor[]</code> for the bean property that matches
+ * the column name. If no bean property was found for a column, the
+ * position is set to <code>PROPERTY_NOT_FOUND</code>.
+ *
+ * @param rsmd The <code>ResultSetMetaData</code> containing column
+ * information.
+ *
+ * @param props The bean property descriptors.
+ *
+ * @throws SQLException if a database access error occurs
+ *
+ * @return An int[] with column index to property index mappings. The 0th
+ * element is meaningless because JDBC column indexing starts at 1.
+ */
+ protected int[] mapColumnsToProperties(ResultSetMetaData rsmd,
+ PropertyDescriptor[] props) throws SQLException {
+
+ int cols = rsmd.getColumnCount();
+ int[] columnToProperty = new int[cols + 1];
+ Arrays.fill(columnToProperty, PROPERTY_NOT_FOUND);
+
+ for (int col = 1; col <= cols; col++) {
+ String columnName = rsmd.getColumnLabel(col);
+ if (null == columnName || 0 == columnName.length()) {
+ columnName = rsmd.getColumnName(col);
+ }
+ String propertyName = columnToPropertyOverrides.get(columnName);
+ if (propertyName == null) {
+ propertyName = columnName;
+ }
+ for (int i = 0; i < props.length; i++) {
+
+ if (propertyName.equalsIgnoreCase(props[i].getName())) {
+ columnToProperty[col] = i;
+ break;
+ }
+ }
+ }
+
+ return columnToProperty;
+ }
+
+ /**
+ * Convert a <code>ResultSet</code> column into an object. Simple
+ * implementations could just call <code>rs.getObject(index)</code> while
+ * more complex implementations could perform type manipulation to match
+ * the column's type to the bean property type.
+ *
+ * <p>
+ * This implementation calls the appropriate <code>ResultSet</code> getter
+ * method for the given property type to perform the type conversion. If
+ * the property type doesn't match one of the supported
+ * <code>ResultSet</code> types, <code>getObject</code> is called.
+ * </p>
+ *
+ * @param rs The <code>ResultSet</code> currently being processed. It is
+ * positioned on a valid row before being passed into this method.
+ *
+ * @param index The current column index being processed.
+ *
+ * @param propType The bean property type that this column needs to be
+ * converted into.
+ *
+ * @throws SQLException if a database access error occurs
+ *
+ * @return The object from the <code>ResultSet</code> at the given column
+ * index after optional type processing or <code>null</code> if the column
+ * value was SQL NULL.
+ */
+ protected Object processColumn(ResultSet rs, int index, Class<?> propType)
+ throws SQLException {
+
+ if ( !propType.isPrimitive() && rs.getObject(index) == null ) {
+ return null;
+ }
+
+ if (propType.equals(String.class)) {
+ return rs.getString(index);
+
+ } else if (
+ propType.equals(Integer.TYPE) || propType.equals(Integer.class)) {
+ return Integer.valueOf(rs.getInt(index));
+
+ } else if (
+ propType.equals(Boolean.TYPE) || propType.equals(Boolean.class)) {
+ return Boolean.valueOf(rs.getBoolean(index));
+
+ } else if (propType.equals(Long.TYPE) || propType.equals(Long.class)) {
+ return Long.valueOf(rs.getLong(index));
+
+ } else if (
+ propType.equals(Double.TYPE) || propType.equals(Double.class)) {
+ return Double.valueOf(rs.getDouble(index));
+
+ } else if (
+ propType.equals(Float.TYPE) || propType.equals(Float.class)) {
+ return Float.valueOf(rs.getFloat(index));
+
+ } else if (
+ propType.equals(Short.TYPE) || propType.equals(Short.class)) {
+ return Short.valueOf(rs.getShort(index));
+
+ } else if (propType.equals(Byte.TYPE) || propType.equals(Byte.class)) {
+ return Byte.valueOf(rs.getByte(index));
+
+ } else if (propType.equals(Timestamp.class)) {
+ return rs.getTimestamp(index);
+
+ } else if (propType.equals(SQLXML.class)) {
+ return rs.getSQLXML(index);
+
+ } else {
+ return rs.getObject(index);
+ }
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/main/java/org/apache/commons/dbutils2/DbUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/DbUtils.java b/src/main/java/org/apache/commons/dbutils2/DbUtils.java
new file mode 100644
index 0000000..5968d4e
--- /dev/null
+++ b/src/main/java/org/apache/commons/dbutils2/DbUtils.java
@@ -0,0 +1,406 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.dbutils2;
+
+import static java.sql.DriverManager.registerDriver;
+import java.io.PrintWriter;
+import java.lang.reflect.Constructor;
+import java.sql.Connection;
+import java.sql.Driver;
+import java.sql.DriverPropertyInfo;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.SQLFeatureNotSupportedException;
+import java.sql.Statement;
+import java.util.Properties;
+import java.util.logging.Logger;
+
+/**
+ * A collection of JDBC helper methods. This class is thread safe.
+ */
+public final class DbUtils {
+
+ /**
+ * Utility classes do not have a public default constructor.
+ *
+ * @since 1.4
+ */
+ private DbUtils() {
+ // do nothing
+ }
+
+ /**
+ * Close a <code>Connection</code>, avoid closing if null.
+ *
+ * @param conn Connection to close.
+ * @throws SQLException if a database access error occurs
+ */
+ public static void close(Connection conn) throws SQLException {
+ if (conn != null) {
+ conn.close();
+ }
+ }
+
+ /**
+ * Close a <code>ResultSet</code>, avoid closing if null.
+ *
+ * @param rs ResultSet to close.
+ * @throws SQLException if a database access error occurs
+ */
+ public static void close(ResultSet rs) throws SQLException {
+ if (rs != null) {
+ rs.close();
+ }
+ }
+
+ /**
+ * Close a <code>Statement</code>, avoid closing if null.
+ *
+ * @param stmt Statement to close.
+ * @throws SQLException if a database access error occurs
+ */
+ public static void close(Statement stmt) throws SQLException {
+ if (stmt != null) {
+ stmt.close();
+ }
+ }
+
+ /**
+ * Close a <code>Connection</code>, avoid closing if null and hide
+ * any SQLExceptions that occur.
+ *
+ * @param conn Connection to close.
+ */
+ public static void closeQuietly(Connection conn) {
+ try {
+ close(conn);
+ } catch (SQLException e) { // NOPMD
+ // quiet
+ }
+ }
+
+ /**
+ * Close a <code>Connection</code>, <code>Statement</code> and
+ * <code>ResultSet</code>. Avoid closing if null and hide any
+ * SQLExceptions that occur.
+ *
+ * @param conn Connection to close.
+ * @param stmt Statement to close.
+ * @param rs ResultSet to close.
+ */
+ public static void closeQuietly(Connection conn, Statement stmt,
+ ResultSet rs) {
+
+ try {
+ closeQuietly(rs);
+ } finally {
+ try {
+ closeQuietly(stmt);
+ } finally {
+ closeQuietly(conn);
+ }
+ }
+
+ }
+
+ /**
+ * Close a <code>ResultSet</code>, avoid closing if null and hide any
+ * SQLExceptions that occur.
+ *
+ * @param rs ResultSet to close.
+ */
+ public static void closeQuietly(ResultSet rs) {
+ try {
+ close(rs);
+ } catch (SQLException e) { // NOPMD
+ // quiet
+ }
+ }
+
+ /**
+ * Close a <code>Statement</code>, avoid closing if null and hide
+ * any SQLExceptions that occur.
+ *
+ * @param stmt Statement to close.
+ */
+ public static void closeQuietly(Statement stmt) {
+ try {
+ close(stmt);
+ } catch (SQLException e) { // NOPMD
+ // quiet
+ }
+ }
+
+ /**
+ * Commits a <code>Connection</code> then closes it, avoid closing if null.
+ *
+ * @param conn Connection to close.
+ * @throws SQLException if a database access error occurs
+ */
+ public static void commitAndClose(Connection conn) throws SQLException {
+ if (conn != null) {
+ try {
+ conn.commit();
+ } finally {
+ conn.close();
+ }
+ }
+ }
+
+ /**
+ * Commits a <code>Connection</code> then closes it, avoid closing if null
+ * and hide any SQLExceptions that occur.
+ *
+ * @param conn Connection to close.
+ */
+ public static void commitAndCloseQuietly(Connection conn) {
+ try {
+ commitAndClose(conn);
+ } catch (SQLException e) { // NOPMD
+ // quiet
+ }
+ }
+
+ /**
+ * Loads and registers a database driver class.
+ * If this succeeds, it returns true, else it returns false.
+ *
+ * @param driverClassName of driver to load
+ * @return boolean <code>true</code> if the driver was found, otherwise <code>false</code>
+ */
+ public static boolean loadDriver(String driverClassName) {
+ return loadDriver(DbUtils.class.getClassLoader(), driverClassName);
+ }
+
+ /**
+ * Loads and registers a database driver class.
+ * If this succeeds, it returns true, else it returns false.
+ *
+ * @param classLoader the class loader used to load the driver class
+ * @param driverClassName of driver to load
+ * @return boolean <code>true</code> if the driver was found, otherwise <code>false</code>
+ * @since 1.4
+ */
+ public static boolean loadDriver(ClassLoader classLoader, String driverClassName) {
+ try {
+ Class<?> loadedClass = classLoader.loadClass(driverClassName);
+
+ if (!Driver.class.isAssignableFrom(loadedClass)) {
+ return false;
+ }
+
+ @SuppressWarnings("unchecked") // guarded by previous check
+ Class<Driver> driverClass = (Class<Driver>) loadedClass;
+ Constructor<Driver> driverConstructor = driverClass.getConstructor();
+
+ // make Constructor accessible if it is private
+ boolean isConstructorAccessible = driverConstructor.isAccessible();
+ if (!isConstructorAccessible) {
+ driverConstructor.setAccessible(true);
+ }
+
+ try {
+ Driver driver = driverConstructor.newInstance();
+ registerDriver(new DriverProxy(driver));
+ } finally {
+ driverConstructor.setAccessible(isConstructorAccessible);
+ }
+
+ return true;
+ } catch (Exception e) {
+ return false;
+
+ }
+ }
+
+ /**
+ * Print the stack trace for a SQLException to STDERR.
+ *
+ * @param e SQLException to print stack trace of
+ */
+ public static void printStackTrace(SQLException e) {
+ printStackTrace(e, new PrintWriter(System.err));
+ }
+
+ /**
+ * Print the stack trace for a SQLException to a
+ * specified PrintWriter.
+ *
+ * @param e SQLException to print stack trace of
+ * @param pw PrintWriter to print to
+ */
+ public static void printStackTrace(SQLException e, PrintWriter pw) {
+
+ SQLException next = e;
+ while (next != null) {
+ next.printStackTrace(pw);
+ next = next.getNextException();
+ if (next != null) {
+ pw.println("Next SQLException:");
+ }
+ }
+ }
+
+ /**
+ * Print warnings on a Connection to STDERR.
+ *
+ * @param conn Connection to print warnings from
+ */
+ public static void printWarnings(Connection conn) {
+ printWarnings(conn, new PrintWriter(System.err));
+ }
+
+ /**
+ * Print warnings on a Connection to a specified PrintWriter.
+ *
+ * @param conn Connection to print warnings from
+ * @param pw PrintWriter to print to
+ */
+ public static void printWarnings(Connection conn, PrintWriter pw) {
+ if (conn != null) {
+ try {
+ printStackTrace(conn.getWarnings(), pw);
+ } catch (SQLException e) {
+ printStackTrace(e, pw);
+ }
+ }
+ }
+
+ /**
+ * Rollback any changes made on the given connection.
+ * @param conn Connection to rollback. A null value is legal.
+ * @throws SQLException if a database access error occurs
+ */
+ public static void rollback(Connection conn) throws SQLException {
+ if (conn != null) {
+ conn.rollback();
+ }
+ }
+
+ /**
+ * Performs a rollback on the <code>Connection</code> then closes it,
+ * avoid closing if null.
+ *
+ * @param conn Connection to rollback. A null value is legal.
+ * @throws SQLException if a database access error occurs
+ * @since DbUtils 1.1
+ */
+ public static void rollbackAndClose(Connection conn) throws SQLException {
+ if (conn != null) {
+ try {
+ conn.rollback();
+ } finally {
+ conn.close();
+ }
+ }
+ }
+
+ /**
+ * Performs a rollback on the <code>Connection</code> then closes it,
+ * avoid closing if null and hide any SQLExceptions that occur.
+ *
+ * @param conn Connection to rollback. A null value is legal.
+ * @since DbUtils 1.1
+ */
+ public static void rollbackAndCloseQuietly(Connection conn) {
+ try {
+ rollbackAndClose(conn);
+ } catch (SQLException e) { // NOPMD
+ // quiet
+ }
+ }
+
+ /**
+ * Simple {@link Driver} proxy class that proxies a JDBC Driver loaded dynamically.
+ *
+ * @since 1.6
+ */
+ private static final class DriverProxy implements Driver {
+
+ /**
+ * The adapted JDBC Driver loaded dynamically.
+ */
+ private final Driver adapted;
+
+ /**
+ * Creates a new JDBC Driver that adapts a JDBC Driver loaded dynamically.
+ *
+ * @param adapted the adapted JDBC Driver loaded dynamically.
+ */
+ public DriverProxy(Driver adapted) {
+ this.adapted = adapted;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean acceptsURL(String url) throws SQLException {
+ return adapted.acceptsURL(url);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Connection connect(String url, Properties info) throws SQLException {
+ return adapted.connect(url, info);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int getMajorVersion() {
+ return adapted.getMajorVersion();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int getMinorVersion() {
+ return adapted.getMinorVersion();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException {
+ return adapted.getPropertyInfo(url, info);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean jdbcCompliant() {
+ return adapted.jdbcCompliant();
+ }
+
+ /**
+ * Java 1.7 method.
+ */
+ @SuppressWarnings("unused")
+ public Logger getParentLogger() throws SQLFeatureNotSupportedException {
+ throw new SQLFeatureNotSupportedException();
+ }
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/main/java/org/apache/commons/dbutils2/GenerousBeanProcessor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/GenerousBeanProcessor.java b/src/main/java/org/apache/commons/dbutils2/GenerousBeanProcessor.java
new file mode 100644
index 0000000..b85b66e
--- /dev/null
+++ b/src/main/java/org/apache/commons/dbutils2/GenerousBeanProcessor.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.dbutils2;
+
+
+import java.beans.PropertyDescriptor;
+import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
+import java.util.Arrays;
+
+
+/**
+ * Provides generous name matching (e.g. underscore-aware) from DB
+ * columns to Java Bean properties.
+ */
+public class GenerousBeanProcessor extends BeanProcessor {
+
+ /**
+ * Default constructor.
+ */
+ public GenerousBeanProcessor() {
+ super();
+ }
+
+ @Override
+ protected int[] mapColumnsToProperties(final ResultSetMetaData rsmd,
+ final PropertyDescriptor[] props) throws SQLException {
+
+ final int cols = rsmd.getColumnCount();
+ final int[] columnToProperty = new int[cols + 1];
+ Arrays.fill(columnToProperty, PROPERTY_NOT_FOUND);
+
+ for (int col = 1; col <= cols; col++) {
+ String columnName = rsmd.getColumnLabel(col);
+
+ if (null == columnName || 0 == columnName.length()) {
+ columnName = rsmd.getColumnName(col);
+ }
+
+ final String generousColumnName = columnName.replace("_","");
+
+ for (int i = 0; i < props.length; i++) {
+ final String propName = props[i].getName();
+
+ // see if either the column name, or the generous one matches
+ if (columnName.equalsIgnoreCase(propName) ||
+ generousColumnName.equalsIgnoreCase(propName)) {
+ columnToProperty[col] = i;
+ break;
+ }
+ }
+ }
+
+ return columnToProperty;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/main/java/org/apache/commons/dbutils2/InsertExecutor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/InsertExecutor.java b/src/main/java/org/apache/commons/dbutils2/InsertExecutor.java
new file mode 100644
index 0000000..39a6db6
--- /dev/null
+++ b/src/main/java/org/apache/commons/dbutils2/InsertExecutor.java
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.dbutils2;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+
+public class InsertExecutor extends AbstractExecutor<InsertExecutor> {
+
+ private final boolean closeConn;
+
+ public InsertExecutor(final Connection conn, final String sql, final boolean closeConnection) throws SQLException {
+ super(conn, sql);
+ this.closeConn = closeConnection;
+ }
+
+ /**
+ * Executes the given INSERT SQL statement.
+ *
+ * @param handler The handler used to create the result object from
+ * the <code>ResultSet</code> of auto-generated keys.
+ *
+ * @return An object generated by the handler.
+ * @throws SQLException If there are database or parameter errors.
+ */
+ public <T> T execute(ResultSetHandler<T> handler) throws SQLException {
+ // throw an exception if there are unmapped parameters
+ this.throwIfUnmappedParams();
+
+ // make sure our handler is not null
+ if (handler == null) {
+ if (closeConn) {
+ close(getConnection());
+ }
+ throw new SQLException("Null ResultSetHandler");
+ }
+
+ try {
+ // execute the update
+ getStatement().executeUpdate();
+
+ // get the result set
+ final ResultSet resultSet = getStatement().getGeneratedKeys();
+
+ // run the handler over the results and return them
+ return handler.handle(resultSet);
+ } catch (SQLException e) {
+ this.rethrow(e);
+ } finally {
+ close(getStatement());
+ if (closeConn) {
+ close(getConnection());
+ }
+ }
+
+ // we get here only if something is thrown
+ return null;
+ }
+
+ /**
+ * Executes the given INSERT SQL statement.
+ * @return the number of rows updated.
+ * @throws SQLException If there are database or parameter errors.
+ */
+ public int execute() throws SQLException {
+ // throw an exception if there are unmapped parameters
+ this.throwIfUnmappedParams();
+
+ try {
+ // execute the insert
+ return getStatement().executeUpdate();
+ } catch (SQLException e) {
+ this.rethrow(e);
+ } finally {
+ close(getStatement());
+ if (closeConn) {
+ close(getConnection());
+ }
+ }
+
+ return 0; // only get here on an error
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/main/java/org/apache/commons/dbutils2/ProxyFactory.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/ProxyFactory.java b/src/main/java/org/apache/commons/dbutils2/ProxyFactory.java
new file mode 100644
index 0000000..9410f27
--- /dev/null
+++ b/src/main/java/org/apache/commons/dbutils2/ProxyFactory.java
@@ -0,0 +1,135 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.dbutils2;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Proxy;
+import java.sql.CallableStatement;
+import java.sql.Connection;
+import java.sql.Driver;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.Statement;
+
+/**
+ * Creates proxy implementations of JDBC interfaces. This avoids
+ * incompatibilities between the JDBC 2 and JDBC 3 interfaces. This class is
+ * thread safe.
+ *
+ * @see java.lang.reflect.Proxy
+ * @see java.lang.reflect.InvocationHandler
+ */
+public class ProxyFactory {
+
+ /**
+ * The Singleton instance of this class.
+ */
+ private static final ProxyFactory instance = new ProxyFactory();
+
+ /**
+ * Returns the Singleton instance of this class.
+ *
+ * @return singleton instance
+ */
+ public static ProxyFactory instance() {
+ return instance;
+ }
+
+ /**
+ * Protected constructor for ProxyFactory subclasses to use.
+ */
+ protected ProxyFactory() {
+ super();
+ }
+
+ /**
+ * Convenience method to generate a single-interface proxy using the handler's classloader
+ *
+ * @param <T> The type of object to proxy
+ * @param type The type of object to proxy
+ * @param handler The handler that intercepts/overrides method calls.
+ * @return proxied object
+ */
+ public <T> T newProxyInstance(Class<T> type, InvocationHandler handler) {
+ return type.cast(Proxy.newProxyInstance(handler.getClass().getClassLoader(), new Class<?>[] {type}, handler));
+ }
+
+ /**
+ * Creates a new proxy <code>CallableStatement</code> object.
+ * @param handler The handler that intercepts/overrides method calls.
+ * @return proxied CallableStatement
+ */
+ public CallableStatement createCallableStatement(InvocationHandler handler) {
+ return newProxyInstance(CallableStatement.class, handler);
+ }
+
+ /**
+ * Creates a new proxy <code>Connection</code> object.
+ * @param handler The handler that intercepts/overrides method calls.
+ * @return proxied Connection
+ */
+ public Connection createConnection(InvocationHandler handler) {
+ return newProxyInstance(Connection.class, handler);
+ }
+
+ /**
+ * Creates a new proxy <code>Driver</code> object.
+ * @param handler The handler that intercepts/overrides method calls.
+ * @return proxied Driver
+ */
+ public Driver createDriver(InvocationHandler handler) {
+ return newProxyInstance(Driver.class, handler);
+ }
+
+ /**
+ * Creates a new proxy <code>PreparedStatement</code> object.
+ * @param handler The handler that intercepts/overrides method calls.
+ * @return proxied PreparedStatement
+ */
+ public PreparedStatement createPreparedStatement(InvocationHandler handler) {
+ return newProxyInstance(PreparedStatement.class, handler);
+ }
+
+ /**
+ * Creates a new proxy <code>ResultSet</code> object.
+ * @param handler The handler that intercepts/overrides method calls.
+ * @return proxied ResultSet
+ */
+ public ResultSet createResultSet(InvocationHandler handler) {
+ return newProxyInstance(ResultSet.class, handler);
+ }
+
+ /**
+ * Creates a new proxy <code>ResultSetMetaData</code> object.
+ * @param handler The handler that intercepts/overrides method calls.
+ * @return proxied ResultSetMetaData
+ */
+ public ResultSetMetaData createResultSetMetaData(InvocationHandler handler) {
+ return newProxyInstance(ResultSetMetaData.class, handler);
+ }
+
+ /**
+ * Creates a new proxy <code>Statement</code> object.
+ * @param handler The handler that intercepts/overrides method calls.
+ * @return proxied Statement
+ */
+ public Statement createStatement(InvocationHandler handler) {
+ return newProxyInstance(Statement.class, handler);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/main/java/org/apache/commons/dbutils2/QueryExecutor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/QueryExecutor.java b/src/main/java/org/apache/commons/dbutils2/QueryExecutor.java
new file mode 100644
index 0000000..4a7c317
--- /dev/null
+++ b/src/main/java/org/apache/commons/dbutils2/QueryExecutor.java
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.dbutils2;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+/**
+ * Fluent class for executing a query.
+ *
+ * @since 2.0
+ * @author William Speirs <ws...@apache.org>
+ */
+class QueryExecutor extends AbstractExecutor<QueryExecutor> {
+
+ private final boolean closeConn;
+
+ public QueryExecutor(final Connection conn, final String sql, final boolean closeConnection) throws SQLException {
+ super(conn, sql);
+ this.closeConn = closeConnection;
+ }
+
+ /**
+ * Calls query after checking the parameters to ensure nothing is null.
+ *
+ * @param rsh The handler that converts the results into an object.
+ *
+ * @return The results of the query.
+ * @throws SQLException If there are database or parameter errors.
+ */
+ public <T> T execute(ResultSetHandler<T> handler) throws SQLException {
+ // throw an exception if there are unmapped parameters
+ this.throwIfUnmappedParams();
+
+ // make sure our handler is not null
+ if (handler == null) {
+ if (closeConn) {
+ close(getConnection());
+ }
+ throw new SQLException("Null ResultSetHandler");
+ }
+
+ ResultSet resultSet = null;
+
+ try {
+ // execute the query, wrapping it
+ resultSet = this.wrap(getStatement().executeQuery());
+ // execute the handler
+ return handler.handle(resultSet);
+ } catch (SQLException e) {
+ // rethrow our exception printing more information
+ this.rethrow(e);
+ } finally {
+ try {
+ close(resultSet);
+ } finally {
+ close(getStatement());
+ if (closeConn) {
+ close(getConnection());
+ }
+ }
+ }
+
+ // we get here only if something is thrown
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/main/java/org/apache/commons/dbutils2/QueryLoader.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/QueryLoader.java b/src/main/java/org/apache/commons/dbutils2/QueryLoader.java
new file mode 100644
index 0000000..df6db6f
--- /dev/null
+++ b/src/main/java/org/apache/commons/dbutils2/QueryLoader.java
@@ -0,0 +1,124 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.dbutils2;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+/**
+ * <code>QueryLoader</code> is a registry for sets of queries so
+ * that multiple copies of the same queries aren't loaded into memory.
+ * This implementation loads properties files filled with query name to
+ * SQL mappings. This class is thread safe.
+ */
+public class QueryLoader {
+
+ /**
+ * The Singleton instance of this class.
+ */
+ private static final QueryLoader instance = new QueryLoader();
+
+ /**
+ * Return an instance of this class.
+ * @return The Singleton instance.
+ */
+ public static QueryLoader instance() {
+ return instance;
+ }
+
+ /**
+ * Maps query set names to Maps of their queries.
+ */
+ private final Map<String, Map<String, String>> queries = new HashMap<String, Map<String, String>>();
+
+ /**
+ * QueryLoader constructor.
+ */
+ protected QueryLoader() {
+ super();
+ }
+
+ /**
+ * Loads a Map of query names to SQL values. The Maps are cached so a
+ * subsequent request to load queries from the same path will return
+ * the cached Map.
+ *
+ * @param path The path that the ClassLoader will use to find the file.
+ * This is <strong>not</strong> a file system path. If you had a jarred
+ * Queries.properties file in the com.yourcorp.app.jdbc package you would
+ * pass "/com/yourcorp/app/jdbc/Queries.properties" to this method.
+ * @throws IOException if a file access error occurs
+ * @throws IllegalArgumentException if the ClassLoader can't find a file at
+ * the given path.
+ * @return Map of query names to SQL values
+ */
+ public synchronized Map<String, String> load(String path) throws IOException {
+
+ Map<String, String> queryMap = this.queries.get(path);
+
+ if (queryMap == null) {
+ queryMap = this.loadQueries(path);
+ this.queries.put(path, queryMap);
+ }
+
+ return queryMap;
+ }
+
+ /**
+ * Loads a set of named queries into a Map object. This implementation
+ * reads a properties file at the given path.
+ * @param path The path that the ClassLoader will use to find the file.
+ * @throws IOException if a file access error occurs
+ * @throws IllegalArgumentException if the ClassLoader can't find a file at
+ * the given path.
+ * @since DbUtils 1.1
+ * @return Map of query names to SQL values
+ */
+ protected Map<String, String> loadQueries(String path) throws IOException {
+ // Findbugs flags getClass().getResource as a bad practice; maybe we should change the API?
+ InputStream in = getClass().getResourceAsStream(path);
+
+ if (in == null) {
+ throw new IllegalArgumentException(path + " not found.");
+ }
+
+ Properties props = new Properties();
+ try {
+ props.load(in);
+ } finally {
+ in.close();
+ }
+
+ // Copy to HashMap for better performance
+
+ @SuppressWarnings({ "rawtypes", "unchecked" }) // load() always creates <String,String> entries
+ HashMap<String, String> hashMap = new HashMap(props);
+ return hashMap;
+ }
+
+ /**
+ * Removes the queries for the given path from the cache.
+ * @param path The path that the queries were loaded from.
+ */
+ public synchronized void unload(String path) {
+ this.queries.remove(path);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/main/java/org/apache/commons/dbutils2/QueryRunner.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/QueryRunner.java b/src/main/java/org/apache/commons/dbutils2/QueryRunner.java
new file mode 100644
index 0000000..9dbc292
--- /dev/null
+++ b/src/main/java/org/apache/commons/dbutils2/QueryRunner.java
@@ -0,0 +1,315 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.dbutils2;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+import javax.sql.DataSource;
+
+/**
+ * Executes SQL queries with pluggable strategies for handling
+ * <code>ResultSet</code>s. This class is thread safe.
+ *
+ * @see ResultSetHandler
+ */
+public class QueryRunner {
+ /**
+ * The DataSource to retrieve connections from.
+ */
+ private final DataSource ds;
+
+ /**
+ * Constructor for QueryRunner.
+ */
+ public QueryRunner() {
+ ds = null;
+ }
+
+ /**
+ * Constructor for QueryRunner that takes a <code>DataSource</code> to use.
+ *
+ * Methods that do not take a <code>Connection</code> parameter will retrieve connections from this
+ * <code>DataSource</code>.
+ *
+ * @param ds The <code>DataSource</code> to retrieve connections from.
+ */
+ public QueryRunner(final DataSource ds) {
+ this.ds = ds;
+ }
+
+ /**
+ * Returns the <code>DataSource</code> this runner is using.
+ * <code>QueryRunner</code> methods always call this method to get the
+ * <code>DataSource</code> so subclasses can provide specialized behavior.
+ *
+ * @return DataSource the runner is using
+ */
+ public DataSource getDataSource() {
+ return this.ds;
+ }
+
+ /**
+ * Factory method that creates and initializes a <code>Connection</code>
+ * object. <code>QueryRunner</code> methods always call this method to
+ * retrieve connections from its DataSource. Subclasses can override this
+ * method to provide special <code>Connection</code> configuration if
+ * needed. This implementation simply calls <code>ds.getConnection()</code>.
+ *
+ * @return An initialized <code>Connection</code>.
+ * @throws SQLException if a database access error occurs
+ */
+ protected Connection prepareConnection() throws SQLException {
+ if (this.getDataSource() == null) {
+ throw new SQLException(
+ "QueryRunner requires a DataSource to be "
+ + "invoked in this way, or a Connection should be passed in");
+ }
+ return this.getDataSource().getConnection();
+ }
+
+ /**
+ * Close a <code>Connection</code>. This implementation avoids closing if
+ * null and does <strong>not</strong> suppress any exceptions. Subclasses
+ * can override to provide special handling like logging.
+ *
+ * @param conn Connection to close
+ * @throws SQLException if a database access error occurs
+ */
+ private void close(Connection conn) throws SQLException {
+ DbUtils.close(conn);
+ }
+
+ /**
+ * Creates an {@link org.apache.commons.dbutils2.BatchExecutor} for the given SQL.
+ * <code>Connection</code> is retrieved from the <code>DataSource</code>
+ * set in the constructor. This <code>Connection</code> must be in
+ * auto-commit mode or the insert will not be saved. The <code>Connection</code> is
+ * closed after the call.
+ *
+ * @param sql The SQL statement to execute.
+ *
+ * @return An {@link org.apache.commons.dbutils2.BatchExecutor} for this SQL statement.
+ * @throws SQLException If there are database or parameter errors.
+ */
+ public BatchExecutor batch(String sql) throws SQLException {
+ return this.batch(this.prepareConnection(), true, sql);
+ }
+
+ /**
+ * Creates an {@link org.apache.commons.dbutils2.BatchExecutor} for the given SQL statement and connection.
+ * The connection is <b>NOT</b> closed after execution.
+ *
+ * @param conn The connection to use for the batch call.
+ * @param sql The SQL statement to execute.
+ *
+ * @return An {@link org.apache.commons.dbutils2.BatchExecutor} for this SQL statement.
+ * @throws SQLException If there are database or parameter errors.
+ */
+ public BatchExecutor batch(Connection conn, String sql) throws SQLException {
+ return this.batch(conn, true, sql);
+ }
+
+ /**
+ * Creates an {@link org.apache.commons.dbutils2.BatchExecutor} for the given SQL statement and connection.
+ *
+ * @param conn The connection to use for the batch call.
+ * @param closeConn True if the connection should be closed, false otherwise.
+ * @param sql The SQL statement to execute.
+ *
+ * @return An {@link org.apache.commons.dbutils2.BatchExecutor} for this SQL statement.
+ * @throws SQLException If there are database or parameter errors.
+ */
+ public BatchExecutor batch(Connection conn, boolean closeConn, String sql) throws SQLException {
+ if (conn == null) {
+ throw new SQLException("Null connection");
+ }
+
+ if (sql == null) {
+ if (closeConn) {
+ close(conn);
+ }
+ throw new SQLException("Null SQL statement");
+ }
+
+ return new BatchExecutor(conn, sql, closeConn);
+ }
+
+ /**
+ * Creates an {@link org.apache.commons.dbutils2.QueryExecutor} for the given SQL.
+ * <code>Connection</code> is retrieved from the <code>DataSource</code>
+ * set in the constructor. This <code>Connection</code> must be in
+ * auto-commit mode or the insert will not be saved. The <code>Connection</code> is
+ * closed after the call.
+ *
+ * @param sql The SQL statement to execute.
+ *
+ * @return An {@link org.apache.commons.dbutils2.QueryExecutor} for this SQL statement.
+ * @throws SQLException If there are database or parameter errors.
+ */
+ public QueryExecutor query(String sql) throws SQLException {
+ return this.query(this.prepareConnection(), true, sql);
+ }
+
+ /**
+ * Creates an {@link org.apache.commons.dbutils2.QueryExecutor} for the given SQL statement and connection.
+ * The connection is <b>NOT</b> closed after execution.
+ *
+ * @param conn The connection to use for the update call.
+ * @param sql The SQL statement to execute.
+ *
+ * @return An {@link org.apache.commons.dbutils2.QueryExecutor} for this SQL statement.
+ * @throws SQLException If there are database or parameter errors.
+ */
+ public QueryExecutor query(Connection conn, String sql) throws SQLException {
+ return this.query(conn, false, sql);
+ }
+
+ /**
+ * Creates an {@link org.apache.commons.dbutils2.QueryExecutor} for the given SQL statement and connection.
+ *
+ * @param conn The connection to use for the query call.
+ * @param closeConn True if the connection should be closed, false otherwise.
+ * @param sql The SQL statement to execute.
+ *
+ * @return An {@link org.apache.commons.dbutils2.QueryExecutor} for this SQL statement.
+ * @throws SQLException If there are database or parameter errors.
+ */
+ public QueryExecutor query(Connection conn, boolean closeConn, String sql) throws SQLException {
+ if (conn == null) {
+ throw new SQLException("Null connection");
+ }
+
+ if (sql == null) {
+ if (closeConn) {
+ close(conn);
+ }
+ throw new SQLException("Null SQL statement");
+ }
+
+ return new QueryExecutor(conn, sql, closeConn);
+ }
+
+ /**
+ * Creates an {@link org.apache.commons.dbutils2.UpdateExecutor} for the given SQL.
+ * <code>Connection</code> is retrieved from the <code>DataSource</code>
+ * set in the constructor. This <code>Connection</code> must be in
+ * auto-commit mode or the insert will not be saved. The <code>Connection</code> is
+ * closed after the call.
+ *
+ * @param sql The SQL statement to execute.
+ *
+ * @return An {@link org.apache.commons.dbutils2.UpdateExecutor} for this SQL statement.
+ * @throws SQLException if a database access error occurs
+ */
+ public UpdateExecutor update(String sql) throws SQLException {
+ return this.update(this.prepareConnection(), true, sql);
+ }
+
+ /**
+ * Creates an {@link org.apache.commons.dbutils2.UpdateExecutor} for the given SQL statement and connection.
+ * The connection is <b>NOT</b> closed after execution.
+ *
+ * @param conn The connection to use for the update call.
+ * @param sql The SQL statement to execute.
+ *
+ * @return An {@link org.apache.commons.dbutils2.UpdateExecutor} for this SQL statement.
+ * @throws SQLException If there are database or parameter errors.
+ */
+ public UpdateExecutor update(Connection conn, String sql) throws SQLException {
+ return this.update(conn, false, sql);
+ }
+
+ /**
+ * Creates an {@link org.apache.commons.dbutils2.UpdateExecutor} for the given SQL statement and connection.
+ *
+ * @param conn The connection to use for the update call.
+ * @param closeConn True if the connection should be closed, false otherwise.
+ * @param sql The SQL statement to execute.
+ *
+ * @return An {@link org.apache.commons.dbutils2.UpdateExecutor} for this SQL statement.
+ * @throws SQLException If there are database or parameter errors.
+ */
+ public UpdateExecutor update(Connection conn, boolean closeConn, String sql) throws SQLException {
+ if (conn == null) {
+ throw new SQLException("Null connection");
+ }
+
+ if (sql == null) {
+ if (closeConn) {
+ close(conn);
+ }
+ throw new SQLException("Null SQL statement");
+ }
+
+ return new UpdateExecutor(conn, sql, closeConn);
+ }
+
+ /**
+ * Creates an {@link org.apache.commons.dbutils2.InsertExecutor} for the given SQL.
+ * <code>Connection</code> is retrieved from the <code>DataSource</code>
+ * set in the constructor. This <code>Connection</code> must be in
+ * auto-commit mode or the insert will not be saved. The <code>Connection</code> is
+ * closed after the call.
+ *
+ * @param sql The SQL statement to execute.
+ *
+ * @return An {@link org.apache.commons.dbutils2.InsertExecutor} for this SQL statement.
+ * @throws SQLException If there are database or parameter errors.
+ */
+ public InsertExecutor insert(String sql) throws SQLException {
+ return insert(this.prepareConnection(), true, sql);
+ }
+
+ /**
+ * Creates an {@link org.apache.commons.dbutils2.InsertExecutor} for the given SQL and connection
+ * The connection is <b>NOT</b> closed after execution.
+ *
+ * @param conn The connection to use for the query call.
+ * @param sql The SQL statement to execute.
+ *
+ * @return An {@link org.apache.commons.dbutils2.InsertExecutor} for this SQL statement.
+ * @throws SQLException If there are database or parameter errors.
+ */
+ public InsertExecutor insert(Connection conn, String sql) throws SQLException {
+ return insert(conn, false, sql);
+ }
+
+ /**
+ * Creates an {@link org.apache.commons.dbutils2.InsertExecutor} for the given SQL and connection.
+ *
+ * @param conn The connection to use for the insert call.
+ * @param closeConn True if the connection should be closed, false otherwise.
+ * @param sql The SQL statement to execute.
+ *
+ * @return An {@link org.apache.commons.dbutils2.InsertExecutor} for this SQL statement.
+ * @throws SQLException If there are database or parameter errors.
+ */
+ public InsertExecutor insert(Connection conn, boolean closeConn, String sql) throws SQLException {
+ if (conn == null) {
+ throw new SQLException("Null connection");
+ }
+
+ if (sql == null) {
+ if (closeConn) {
+ close(conn);
+ }
+ throw new SQLException("Null SQL statement");
+ }
+
+ return new InsertExecutor(conn, sql, closeConn);
+ }
+}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/main/java/org/apache/commons/dbutils2/ResultSetHandler.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/ResultSetHandler.java b/src/main/java/org/apache/commons/dbutils2/ResultSetHandler.java
new file mode 100644
index 0000000..f7ba0bd
--- /dev/null
+++ b/src/main/java/org/apache/commons/dbutils2/ResultSetHandler.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.dbutils2;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+/**
+ * Implementations of this interface convert ResultSets into other objects.
+ *
+ * @param <T> the target type the input ResultSet will be converted to.
+ */
+public interface ResultSetHandler<T> {
+
+ /**
+ * Turn the <code>ResultSet</code> into an Object.
+ *
+ * @param rs The <code>ResultSet</code> to handle. It has not been touched
+ * before being passed to this method.
+ *
+ * @return An Object initialized with <code>ResultSet</code> data. It is
+ * legal for implementations to return <code>null</code> if the
+ * <code>ResultSet</code> contained 0 rows.
+ *
+ * @throws SQLException if a database access error occurs
+ */
+ T handle(ResultSet rs) throws SQLException;
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/main/java/org/apache/commons/dbutils2/ResultSetIterator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/ResultSetIterator.java b/src/main/java/org/apache/commons/dbutils2/ResultSetIterator.java
new file mode 100644
index 0000000..ef05213
--- /dev/null
+++ b/src/main/java/org/apache/commons/dbutils2/ResultSetIterator.java
@@ -0,0 +1,141 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.dbutils2;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.Iterator;
+
+/**
+ * <p>
+ * Wraps a <code>ResultSet</code> in an <code>Iterator<Object[]></code>. This is useful
+ * when you want to present a non-database application layer with domain
+ * neutral data.
+ * </p>
+ *
+ * <p>
+ * This implementation requires the <code>ResultSet.isLast()</code> method
+ * to be implemented.
+ * </p>
+ */
+public class ResultSetIterator implements Iterator<Object[]> {
+
+ /**
+ * The wrapped <code>ResultSet</code>.
+ */
+ private final ResultSet rs;
+
+ /**
+ * The processor to use when converting a row into an Object[].
+ */
+ private final RowProcessor convert;
+
+ /**
+ * Constructor for ResultSetIterator.
+ * @param rs Wrap this <code>ResultSet</code> in an <code>Iterator</code>.
+ */
+ public ResultSetIterator(ResultSet rs) {
+ this(rs, new BasicRowProcessor());
+ }
+
+ /**
+ * Constructor for ResultSetIterator.
+ * @param rs Wrap this <code>ResultSet</code> in an <code>Iterator</code>.
+ * @param convert The processor to use when converting a row into an
+ * <code>Object[]</code>. Defaults to a
+ * <code>BasicRowProcessor</code>.
+ */
+ public ResultSetIterator(ResultSet rs, RowProcessor convert) {
+ this.rs = rs;
+ this.convert = convert;
+ }
+
+ /**
+ * Returns true if there are more rows in the ResultSet.
+ * @return boolean <code>true</code> if there are more rows
+ * @throws RuntimeException if an SQLException occurs.
+ */
+ @Override
+ public boolean hasNext() {
+ try {
+ return !rs.isLast();
+ } catch (SQLException e) {
+ rethrow(e);
+ return false;
+ }
+ }
+
+ /**
+ * Returns the next row as an <code>Object[]</code>.
+ * @return An <code>Object[]</code> with the same number of elements as
+ * columns in the <code>ResultSet</code>.
+ * @see java.util.Iterator#next()
+ * @throws RuntimeException if an SQLException occurs.
+ */
+ @Override
+ public Object[] next() {
+ try {
+ rs.next();
+ return this.convert.toArray(rs);
+ } catch (SQLException e) {
+ rethrow(e);
+ return null;
+ }
+ }
+
+ /**
+ * Deletes the current row from the <code>ResultSet</code>.
+ * @see java.util.Iterator#remove()
+ * @throws RuntimeException if an SQLException occurs.
+ */
+ @Override
+ public void remove() {
+ try {
+ this.rs.deleteRow();
+ } catch (SQLException e) {
+ rethrow(e);
+ }
+ }
+
+ /**
+ * Rethrow the SQLException as a RuntimeException. This implementation
+ * creates a new RuntimeException with the SQLException's error message.
+ * @param e SQLException to rethrow
+ * @since DbUtils 1.1
+ */
+ protected void rethrow(SQLException e) {
+ throw new RuntimeException(e.getMessage());
+ }
+
+ /**
+ * Generates an <code>Iterable</code>, suitable for use in for-each loops.
+ *
+ * @param rs Wrap this <code>ResultSet</code> in an <code>Iterator</code>.
+ * @return an <code>Iterable</code>, suitable for use in for-each loops.
+ */
+ public static Iterable<Object[]> iterable(final ResultSet rs) {
+ return new Iterable<Object[]>() {
+
+ @Override
+ public Iterator<Object[]> iterator() {
+ return new ResultSetIterator(rs);
+ }
+
+ };
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/main/java/org/apache/commons/dbutils2/RowProcessor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/RowProcessor.java b/src/main/java/org/apache/commons/dbutils2/RowProcessor.java
new file mode 100644
index 0000000..b896b01
--- /dev/null
+++ b/src/main/java/org/apache/commons/dbutils2/RowProcessor.java
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.dbutils2;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * <code>RowProcessor</code> implementations convert
+ * <code>ResultSet</code> rows into various other objects. Implementations
+ * can extend <code>BasicRowProcessor</code> to protect themselves
+ * from changes to this interface.
+ *
+ * @see BasicRowProcessor
+ */
+public interface RowProcessor {
+
+ /**
+ * Create an <code>Object[]</code> from the column values in one
+ * <code>ResultSet</code> row. The <code>ResultSet</code> should be
+ * positioned on a valid row before passing it to this method.
+ * Implementations of this method must not alter the row position of
+ * the <code>ResultSet</code>.
+ *
+ * @param rs ResultSet that supplies the array data
+ * @throws SQLException if a database access error occurs
+ * @return the newly created array
+ */
+ Object[] toArray(ResultSet rs) throws SQLException;
+
+ /**
+ * Create a JavaBean from the column values in one <code>ResultSet</code>
+ * row. The <code>ResultSet</code> should be positioned on a valid row before
+ * passing it to this method. Implementations of this method must not
+ * alter the row position of the <code>ResultSet</code>.
+ * @param <T> The type of bean to create
+ * @param rs ResultSet that supplies the bean data
+ * @param type Class from which to create the bean instance
+ * @throws SQLException if a database access error occurs
+ * @return the newly created bean
+ */
+ <T> T toBean(ResultSet rs, Class<T> type) throws SQLException;
+
+ /**
+ * Create a <code>List</code> of JavaBeans from the column values in all
+ * <code>ResultSet</code> rows. <code>ResultSet.next()</code> should
+ * <strong>not</strong> be called before passing it to this method.
+ * @param <T> The type of bean to create
+ * @param rs ResultSet that supplies the bean data
+ * @param type Class from which to create the bean instance
+ * @throws SQLException if a database access error occurs
+ * @return A <code>List</code> of beans with the given type in the order
+ * they were returned by the <code>ResultSet</code>.
+ */
+ <T> List<T> toBeanList(ResultSet rs, Class<T> type) throws SQLException;
+
+ /**
+ * Create a <code>Map</code> from the column values in one
+ * <code>ResultSet</code> row. The <code>ResultSet</code> should be
+ * positioned on a valid row before
+ * passing it to this method. Implementations of this method must not
+ * alter the row position of the <code>ResultSet</code>.
+ *
+ * @param rs ResultSet that supplies the map data
+ * @throws SQLException if a database access error occurs
+ * @return the newly created Map
+ */
+ Map<String, Object> toMap(ResultSet rs) throws SQLException;
+
+}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/main/java/org/apache/commons/dbutils2/UpdateExecutor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/UpdateExecutor.java b/src/main/java/org/apache/commons/dbutils2/UpdateExecutor.java
new file mode 100644
index 0000000..590f069
--- /dev/null
+++ b/src/main/java/org/apache/commons/dbutils2/UpdateExecutor.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.dbutils2;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+
+
+public class UpdateExecutor extends AbstractExecutor<UpdateExecutor> {
+
+ private final boolean closeConn;
+
+ public UpdateExecutor(final Connection conn, final String sql, final boolean closeConnection) throws SQLException {
+ super(conn, sql);
+ this.closeConn = closeConnection;
+ }
+
+ /**
+ * Calls update after checking the parameters to ensure nothing is null.
+ * @return The number of rows updated.
+ * @throws SQLException If there are database or parameter errors.
+ */
+ public int execute() throws SQLException {
+ // throw an exception if there are unmapped parameters
+ this.throwIfUnmappedParams();
+
+ try {
+ return getStatement().executeUpdate();
+ } catch (SQLException e) {
+ this.rethrow(e);
+
+ } finally {
+ close(getStatement());
+ if (closeConn) {
+ close(getConnection());
+ }
+ }
+
+ // we get here only if something is thrown
+ return 0;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/main/java/org/apache/commons/dbutils2/handlers/AbstractKeyedHandler.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/handlers/AbstractKeyedHandler.java b/src/main/java/org/apache/commons/dbutils2/handlers/AbstractKeyedHandler.java
new file mode 100644
index 0000000..14e0b63
--- /dev/null
+++ b/src/main/java/org/apache/commons/dbutils2/handlers/AbstractKeyedHandler.java
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.dbutils2.handlers;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.commons.dbutils2.ResultSetHandler;
+
+/**
+ * <p>
+ * <code>ResultSetHandler</code> implementation that returns a Map.
+ * <code>ResultSet</code> rows are converted into objects (Vs) which are then stored
+ * in a Map under the given keys (Ks).
+ * </p>
+ *
+ * @param <K> the type of keys maintained by the returned map
+ * @param <V> the type of mapped values
+ * @see org.apache.commons.dbutils2.ResultSetHandler
+ * @since DbUtils 1.3
+ */
+public abstract class AbstractKeyedHandler<K, V> implements ResultSetHandler<Map<K, V>> {
+
+
+ /**
+ * Convert each row's columns into a Map and store then
+ * in a <code>Map</code> under <code>ResultSet.getObject(key)</code> key.
+ * @param rs <code>ResultSet</code> to process.
+ * @return A <code>Map</code>, never <code>null</code>.
+ * @throws SQLException if a database access error occurs
+ * @see org.apache.commons.dbutils2.ResultSetHandler#handle(java.sql.ResultSet)
+ */
+ @Override
+ public Map<K, V> handle(ResultSet rs) throws SQLException {
+ Map<K, V> result = createMap();
+ while (rs.next()) {
+ result.put(createKey(rs), createRow(rs));
+ }
+ return result;
+ }
+
+ /**
+ * This factory method is called by <code>handle()</code> to create the Map
+ * to store records in. This implementation returns a <code>HashMap</code>
+ * instance.
+ *
+ * @return Map to store records in
+ */
+ protected Map<K, V> createMap() {
+ return new HashMap<K, V>();
+ }
+
+ /**
+ * This factory method is called by <code>handle()</code> to retrieve the
+ * key value from the current <code>ResultSet</code> row.
+ * @param rs ResultSet to create a key from
+ * @return K from the configured key column name/index
+ * @throws SQLException if a database access error occurs
+ */
+ protected abstract K createKey(ResultSet rs) throws SQLException;
+
+ /**
+ * This factory method is called by <code>handle()</code> to store the
+ * current <code>ResultSet</code> row in some object.
+ * @param rs ResultSet to create a row from
+ * @return V object created from the current row
+ * @throws SQLException if a database access error occurs
+ */
+ protected abstract V createRow(ResultSet rs) throws SQLException;
+
+}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/main/java/org/apache/commons/dbutils2/handlers/AbstractListHandler.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/handlers/AbstractListHandler.java b/src/main/java/org/apache/commons/dbutils2/handlers/AbstractListHandler.java
new file mode 100644
index 0000000..8b4b68e
--- /dev/null
+++ b/src/main/java/org/apache/commons/dbutils2/handlers/AbstractListHandler.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.dbutils2.handlers;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.dbutils2.ResultSetHandler;
+
+/**
+ * Abstract class that simplify development of <code>ResultSetHandler</code>
+ * classes that convert <code>ResultSet</code> into <code>List</code>.
+ *
+ * @param <T> the target List generic type
+ * @see org.apache.commons.dbutils2.ResultSetHandler
+ */
+public abstract class AbstractListHandler<T> implements ResultSetHandler<List<T>> {
+ /**
+ * Whole <code>ResultSet</code> handler. It produce <code>List</code> as
+ * result. To convert individual rows into Java objects it uses
+ * <code>handleRow(ResultSet)</code> method.
+ *
+ * @see #handleRow(ResultSet)
+ * @param rs <code>ResultSet</code> to process.
+ * @return a list of all rows in the result set
+ * @throws SQLException error occurs
+ */
+ @Override
+ public List<T> handle(ResultSet rs) throws SQLException {
+ List<T> rows = new ArrayList<T>();
+ while (rs.next()) {
+ rows.add(this.handleRow(rs));
+ }
+ return rows;
+ }
+
+ /**
+ * Row handler. Method converts current row into some Java object.
+ *
+ * @param rs <code>ResultSet</code> to process.
+ * @return row processing result
+ * @throws SQLException error occurs
+ */
+ protected abstract T handleRow(ResultSet rs) throws SQLException;
+}
[16/58] [abbrv] commons-dbutils git commit: - Updated release notes
Posted by th...@apache.org.
- Updated release notes
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/dbutils/tags/DBUTILS_2_0_RC1@1457544 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/commons-dbutils/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-dbutils/commit/83d65e39
Tree: http://git-wip-us.apache.org/repos/asf/commons-dbutils/tree/83d65e39
Diff: http://git-wip-us.apache.org/repos/asf/commons-dbutils/diff/83d65e39
Branch: refs/heads/2_0
Commit: 83d65e39ce5ac4ad11f9cfc1294386936b0b2de2
Parents: b5e15de
Author: Bill Speirs <ws...@apache.org>
Authored: Sun Mar 17 19:51:32 2013 +0000
Committer: Bill Speirs <ws...@apache.org>
Committed: Sun Mar 17 19:51:32 2013 +0000
----------------------------------------------------------------------
RELEASE-NOTES.txt | 17 +++++------------
1 file changed, 5 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/83d65e39/RELEASE-NOTES.txt
----------------------------------------------------------------------
diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt
index 33ca394..13fdbf8 100644
--- a/RELEASE-NOTES.txt
+++ b/RELEASE-NOTES.txt
@@ -1,31 +1,24 @@
Apache Commons DbUtils
- Version 1.5
+ Version 2.0
RELEASE NOTES
-The Commons DbUtils team is pleased to announce the release of Commons DbUtils 1.5
+The Commons DbUtils team is pleased to announce the release of Commons DbUtils 2.0
The Apache Commons-DbUtils package is a set of
Java utility classes for easing JDBC development.
-Bugfixes and addition of BeanMapHandler
+Complete re-write of QueryRunner to use a fluent API and provide named bindings.
+*Note: This version is NOT backwards compatible with 1.x versions.
Changes in this version include:
New features:
-o DBUTILS-67: Added BeanMapHandler Thanks to Michael Osipov.
+o DBUTILS-105: Add Named Parameter Support
Fixed Bugs:
-o DBUTILS-93: Source assembly artifact fails to build a site because of missing pmd-ruleset.xml Thanks to Stevo Slavic.
-o DBUTILS-84: BeanProcessor method processColumn should take SQLXML in consideration Thanks to Tiago Cavaleiro.
-o DBUTILS-73: Added a fixed Locale (Locale.ENGLISH) to all toLowerCase calls in BasicRowProcessor Thanks to Sebb.
Changes:
-o DBUTILS-94: Provide test coverage for org.apache.commons.dbutils.DbUtils Thanks to Benedikt Ritter.
-o DBUTILS-91: Enhance BasicRowProcessor to have row mapping easier to configure Thanks to Stevo Slavic.
-o Updated pom.xml: Java 1.6 now required, clirr and compiler plugin removed Thanks to wspeirs.
-o DBUTILS-77: Updated documentation to better reflect the use of pmdKnownBroken
-o DBUTILS-66: Added generics to ScalarHandler, ColumnHandler, and KeyedHandler Thanks to Michael Osipov.
For complete information on Commons DbUtils, including instructions on how to submit bug reports,
[08/58] [abbrv] commons-dbutils git commit: Changed the package names
so dbutils and dbutils2 won't conflict if both loaded
Posted by th...@apache.org.
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/main/java/org/apache/commons/dbutils/RowProcessor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils/RowProcessor.java b/src/main/java/org/apache/commons/dbutils/RowProcessor.java
deleted file mode 100644
index 02e9382..0000000
--- a/src/main/java/org/apache/commons/dbutils/RowProcessor.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.dbutils;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.List;
-import java.util.Map;
-
-/**
- * <code>RowProcessor</code> implementations convert
- * <code>ResultSet</code> rows into various other objects. Implementations
- * can extend <code>BasicRowProcessor</code> to protect themselves
- * from changes to this interface.
- *
- * @see BasicRowProcessor
- */
-public interface RowProcessor {
-
- /**
- * Create an <code>Object[]</code> from the column values in one
- * <code>ResultSet</code> row. The <code>ResultSet</code> should be
- * positioned on a valid row before passing it to this method.
- * Implementations of this method must not alter the row position of
- * the <code>ResultSet</code>.
- *
- * @param rs ResultSet that supplies the array data
- * @throws SQLException if a database access error occurs
- * @return the newly created array
- */
- Object[] toArray(ResultSet rs) throws SQLException;
-
- /**
- * Create a JavaBean from the column values in one <code>ResultSet</code>
- * row. The <code>ResultSet</code> should be positioned on a valid row before
- * passing it to this method. Implementations of this method must not
- * alter the row position of the <code>ResultSet</code>.
- * @param <T> The type of bean to create
- * @param rs ResultSet that supplies the bean data
- * @param type Class from which to create the bean instance
- * @throws SQLException if a database access error occurs
- * @return the newly created bean
- */
- <T> T toBean(ResultSet rs, Class<T> type) throws SQLException;
-
- /**
- * Create a <code>List</code> of JavaBeans from the column values in all
- * <code>ResultSet</code> rows. <code>ResultSet.next()</code> should
- * <strong>not</strong> be called before passing it to this method.
- * @param <T> The type of bean to create
- * @param rs ResultSet that supplies the bean data
- * @param type Class from which to create the bean instance
- * @throws SQLException if a database access error occurs
- * @return A <code>List</code> of beans with the given type in the order
- * they were returned by the <code>ResultSet</code>.
- */
- <T> List<T> toBeanList(ResultSet rs, Class<T> type) throws SQLException;
-
- /**
- * Create a <code>Map</code> from the column values in one
- * <code>ResultSet</code> row. The <code>ResultSet</code> should be
- * positioned on a valid row before
- * passing it to this method. Implementations of this method must not
- * alter the row position of the <code>ResultSet</code>.
- *
- * @param rs ResultSet that supplies the map data
- * @throws SQLException if a database access error occurs
- * @return the newly created Map
- */
- Map<String, Object> toMap(ResultSet rs) throws SQLException;
-
-}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/main/java/org/apache/commons/dbutils/UpdateExecutor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils/UpdateExecutor.java b/src/main/java/org/apache/commons/dbutils/UpdateExecutor.java
deleted file mode 100644
index 9cfaf2f..0000000
--- a/src/main/java/org/apache/commons/dbutils/UpdateExecutor.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.dbutils;
-
-import java.sql.Connection;
-import java.sql.SQLException;
-
-
-public class UpdateExecutor extends AbstractExecutor<UpdateExecutor> {
-
- private final boolean closeConn;
-
- public UpdateExecutor(final Connection conn, final String sql, final boolean closeConnection) throws SQLException {
- super(conn, sql);
- this.closeConn = closeConnection;
- }
-
- /**
- * Calls update after checking the parameters to ensure nothing is null.
- * @return The number of rows updated.
- * @throws SQLException If there are database or parameter errors.
- */
- public int execute() throws SQLException {
- // throw an exception if there are unmapped parameters
- this.throwIfUnmappedParams();
-
- try {
- return getStatement().executeUpdate();
- } catch (SQLException e) {
- this.rethrow(e);
-
- } finally {
- close(getStatement());
- if (closeConn) {
- close(getConnection());
- }
- }
-
- // we get here only if something is thrown
- return 0;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/main/java/org/apache/commons/dbutils/handlers/AbstractKeyedHandler.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils/handlers/AbstractKeyedHandler.java b/src/main/java/org/apache/commons/dbutils/handlers/AbstractKeyedHandler.java
deleted file mode 100644
index 2fc8d5d..0000000
--- a/src/main/java/org/apache/commons/dbutils/handlers/AbstractKeyedHandler.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.dbutils.handlers;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.commons.dbutils.ResultSetHandler;
-
-/**
- * <p>
- * <code>ResultSetHandler</code> implementation that returns a Map.
- * <code>ResultSet</code> rows are converted into objects (Vs) which are then stored
- * in a Map under the given keys (Ks).
- * </p>
- *
- * @param <K> the type of keys maintained by the returned map
- * @param <V> the type of mapped values
- * @see org.apache.commons.dbutils.ResultSetHandler
- * @since DbUtils 1.3
- */
-public abstract class AbstractKeyedHandler<K, V> implements ResultSetHandler<Map<K, V>> {
-
-
- /**
- * Convert each row's columns into a Map and store then
- * in a <code>Map</code> under <code>ResultSet.getObject(key)</code> key.
- * @param rs <code>ResultSet</code> to process.
- * @return A <code>Map</code>, never <code>null</code>.
- * @throws SQLException if a database access error occurs
- * @see org.apache.commons.dbutils.ResultSetHandler#handle(java.sql.ResultSet)
- */
- @Override
- public Map<K, V> handle(ResultSet rs) throws SQLException {
- Map<K, V> result = createMap();
- while (rs.next()) {
- result.put(createKey(rs), createRow(rs));
- }
- return result;
- }
-
- /**
- * This factory method is called by <code>handle()</code> to create the Map
- * to store records in. This implementation returns a <code>HashMap</code>
- * instance.
- *
- * @return Map to store records in
- */
- protected Map<K, V> createMap() {
- return new HashMap<K, V>();
- }
-
- /**
- * This factory method is called by <code>handle()</code> to retrieve the
- * key value from the current <code>ResultSet</code> row.
- * @param rs ResultSet to create a key from
- * @return K from the configured key column name/index
- * @throws SQLException if a database access error occurs
- */
- protected abstract K createKey(ResultSet rs) throws SQLException;
-
- /**
- * This factory method is called by <code>handle()</code> to store the
- * current <code>ResultSet</code> row in some object.
- * @param rs ResultSet to create a row from
- * @return V object created from the current row
- * @throws SQLException if a database access error occurs
- */
- protected abstract V createRow(ResultSet rs) throws SQLException;
-
-}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/main/java/org/apache/commons/dbutils/handlers/AbstractListHandler.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils/handlers/AbstractListHandler.java b/src/main/java/org/apache/commons/dbutils/handlers/AbstractListHandler.java
deleted file mode 100644
index 504b58e..0000000
--- a/src/main/java/org/apache/commons/dbutils/handlers/AbstractListHandler.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.dbutils.handlers;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.commons.dbutils.ResultSetHandler;
-
-/**
- * Abstract class that simplify development of <code>ResultSetHandler</code>
- * classes that convert <code>ResultSet</code> into <code>List</code>.
- *
- * @param <T> the target List generic type
- * @see org.apache.commons.dbutils.ResultSetHandler
- */
-public abstract class AbstractListHandler<T> implements ResultSetHandler<List<T>> {
- /**
- * Whole <code>ResultSet</code> handler. It produce <code>List</code> as
- * result. To convert individual rows into Java objects it uses
- * <code>handleRow(ResultSet)</code> method.
- *
- * @see #handleRow(ResultSet)
- * @param rs <code>ResultSet</code> to process.
- * @return a list of all rows in the result set
- * @throws SQLException error occurs
- */
- @Override
- public List<T> handle(ResultSet rs) throws SQLException {
- List<T> rows = new ArrayList<T>();
- while (rs.next()) {
- rows.add(this.handleRow(rs));
- }
- return rows;
- }
-
- /**
- * Row handler. Method converts current row into some Java object.
- *
- * @param rs <code>ResultSet</code> to process.
- * @return row processing result
- * @throws SQLException error occurs
- */
- protected abstract T handleRow(ResultSet rs) throws SQLException;
-}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/main/java/org/apache/commons/dbutils/handlers/ArrayHandler.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils/handlers/ArrayHandler.java b/src/main/java/org/apache/commons/dbutils/handlers/ArrayHandler.java
deleted file mode 100644
index 8c82210..0000000
--- a/src/main/java/org/apache/commons/dbutils/handlers/ArrayHandler.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.dbutils.handlers;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-import org.apache.commons.dbutils.BasicRowProcessor;
-import org.apache.commons.dbutils.ResultSetHandler;
-import org.apache.commons.dbutils.RowProcessor;
-
-/**
- * <code>ResultSetHandler</code> implementation that converts a
- * <code>ResultSet</code> into an <code>Object[]</code>. This class is
- * thread safe.
- *
- * @see org.apache.commons.dbutils.ResultSetHandler
- */
-public class ArrayHandler implements ResultSetHandler<Object[]> {
-
- /**
- * Singleton processor instance that handlers share to save memory. Notice
- * the default scoping to allow only classes in this package to use this
- * instance.
- */
- static final RowProcessor ROW_PROCESSOR = new BasicRowProcessor();
-
- /**
- * The RowProcessor implementation to use when converting rows
- * into arrays.
- */
- private final RowProcessor convert;
-
- /**
- * Creates a new instance of ArrayHandler using a
- * <code>BasicRowProcessor</code> for conversion.
- */
- public ArrayHandler() {
- this(ROW_PROCESSOR);
- }
-
- /**
- * Creates a new instance of ArrayHandler.
- *
- * @param convert The <code>RowProcessor</code> implementation
- * to use when converting rows into arrays.
- */
- public ArrayHandler(RowProcessor convert) {
- super();
- this.convert = convert;
- }
-
- /**
- * Places the column values from the first row in an <code>Object[]</code>.
- * @param rs <code>ResultSet</code> to process.
- * @return An Object[] or <code>null</code> if there are no rows in the
- * <code>ResultSet</code>.
- *
- * @throws SQLException if a database access error occurs
- * @see org.apache.commons.dbutils.ResultSetHandler#handle(java.sql.ResultSet)
- */
- @Override
- public Object[] handle(ResultSet rs) throws SQLException {
- return rs.next() ? this.convert.toArray(rs) : null;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/main/java/org/apache/commons/dbutils/handlers/ArrayListHandler.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils/handlers/ArrayListHandler.java b/src/main/java/org/apache/commons/dbutils/handlers/ArrayListHandler.java
deleted file mode 100644
index d2359cf..0000000
--- a/src/main/java/org/apache/commons/dbutils/handlers/ArrayListHandler.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.dbutils.handlers;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-import org.apache.commons.dbutils.RowProcessor;
-
-/**
- * <code>ResultSetHandler</code> implementation that converts the
- * <code>ResultSet</code> into a <code>List</code> of <code>Object[]</code>s.
- * This class is thread safe.
- *
- * @see org.apache.commons.dbutils.ResultSetHandler
- */
-public class ArrayListHandler extends AbstractListHandler<Object[]> {
-
- /**
- * The RowProcessor implementation to use when converting rows
- * into Object[]s.
- */
- private final RowProcessor convert;
-
- /**
- * Creates a new instance of ArrayListHandler using a
- * <code>BasicRowProcessor</code> for conversions.
- */
- public ArrayListHandler() {
- this(ArrayHandler.ROW_PROCESSOR);
- }
-
- /**
- * Creates a new instance of ArrayListHandler.
- *
- * @param convert The <code>RowProcessor</code> implementation
- * to use when converting rows into Object[]s.
- */
- public ArrayListHandler(RowProcessor convert) {
- super();
- this.convert = convert;
- }
-
-
- /**
- * Convert row's columns into an <code>Object[]</code>.
- * @param rs <code>ResultSet</code> to process.
- * @return <code>Object[]</code>, never <code>null</code>.
- *
- * @throws SQLException if a database access error occurs
- * @see org.apache.commons.dbutils.handlers.AbstractListHandler#handle(ResultSet)
- */
- @Override
- protected Object[] handleRow(ResultSet rs) throws SQLException {
- return this.convert.toArray(rs);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/main/java/org/apache/commons/dbutils/handlers/BeanHandler.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils/handlers/BeanHandler.java b/src/main/java/org/apache/commons/dbutils/handlers/BeanHandler.java
deleted file mode 100644
index daa3027..0000000
--- a/src/main/java/org/apache/commons/dbutils/handlers/BeanHandler.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.dbutils.handlers;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-import org.apache.commons.dbutils.ResultSetHandler;
-import org.apache.commons.dbutils.RowProcessor;
-
-/**
- * <code>ResultSetHandler</code> implementation that converts the first
- * <code>ResultSet</code> row into a JavaBean. This class is thread safe.
- *
- * @param <T> the target bean type
- * @see org.apache.commons.dbutils.ResultSetHandler
- */
-public class BeanHandler<T> implements ResultSetHandler<T> {
-
- /**
- * The Class of beans produced by this handler.
- */
- private final Class<T> type;
-
- /**
- * The RowProcessor implementation to use when converting rows
- * into beans.
- */
- private final RowProcessor convert;
-
- /**
- * Creates a new instance of BeanHandler.
- *
- * @param type The Class that objects returned from <code>handle()</code>
- * are created from.
- */
- public BeanHandler(Class<T> type) {
- this(type, ArrayHandler.ROW_PROCESSOR);
- }
-
- /**
- * Creates a new instance of BeanHandler.
- *
- * @param type The Class that objects returned from <code>handle()</code>
- * are created from.
- * @param convert The <code>RowProcessor</code> implementation
- * to use when converting rows into beans.
- */
- public BeanHandler(Class<T> type, RowProcessor convert) {
- this.type = type;
- this.convert = convert;
- }
-
- /**
- * Convert the first row of the <code>ResultSet</code> into a bean with the
- * <code>Class</code> given in the constructor.
- * @param rs <code>ResultSet</code> to process.
- * @return An initialized JavaBean or <code>null</code> if there were no
- * rows in the <code>ResultSet</code>.
- *
- * @throws SQLException if a database access error occurs
- * @see org.apache.commons.dbutils.ResultSetHandler#handle(java.sql.ResultSet)
- */
- @Override
- public T handle(ResultSet rs) throws SQLException {
- return rs.next() ? this.convert.toBean(rs, this.type) : null;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/main/java/org/apache/commons/dbutils/handlers/BeanListHandler.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils/handlers/BeanListHandler.java b/src/main/java/org/apache/commons/dbutils/handlers/BeanListHandler.java
deleted file mode 100644
index 1541a66..0000000
--- a/src/main/java/org/apache/commons/dbutils/handlers/BeanListHandler.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.dbutils.handlers;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.List;
-
-import org.apache.commons.dbutils.ResultSetHandler;
-import org.apache.commons.dbutils.RowProcessor;
-
-/**
- * <code>ResultSetHandler</code> implementation that converts a
- * <code>ResultSet</code> into a <code>List</code> of beans. This class is
- * thread safe.
- *
- * @param <T> the target bean type
- * @see org.apache.commons.dbutils.ResultSetHandler
- */
-public class BeanListHandler<T> implements ResultSetHandler<List<T>> {
-
- /**
- * The Class of beans produced by this handler.
- */
- private final Class<T> type;
-
- /**
- * The RowProcessor implementation to use when converting rows
- * into beans.
- */
- private final RowProcessor convert;
-
- /**
- * Creates a new instance of BeanListHandler.
- *
- * @param type The Class that objects returned from <code>handle()</code>
- * are created from.
- */
- public BeanListHandler(Class<T> type) {
- this(type, ArrayHandler.ROW_PROCESSOR);
- }
-
- /**
- * Creates a new instance of BeanListHandler.
- *
- * @param type The Class that objects returned from <code>handle()</code>
- * are created from.
- * @param convert The <code>RowProcessor</code> implementation
- * to use when converting rows into beans.
- */
- public BeanListHandler(Class<T> type, RowProcessor convert) {
- this.type = type;
- this.convert = convert;
- }
-
- /**
- * Convert the whole <code>ResultSet</code> into a List of beans with
- * the <code>Class</code> given in the constructor.
- *
- * @param rs The <code>ResultSet</code> to handle.
- *
- * @return A List of beans, never <code>null</code>.
- *
- * @throws SQLException if a database access error occurs
- * @see org.apache.commons.dbutils.RowProcessor#toBeanList(ResultSet, Class)
- */
- @Override
- public List<T> handle(ResultSet rs) throws SQLException {
- return this.convert.toBeanList(rs, type);
- }
-}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/main/java/org/apache/commons/dbutils/handlers/BeanMapHandler.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils/handlers/BeanMapHandler.java b/src/main/java/org/apache/commons/dbutils/handlers/BeanMapHandler.java
deleted file mode 100644
index 32a1e1c..0000000
--- a/src/main/java/org/apache/commons/dbutils/handlers/BeanMapHandler.java
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.dbutils.handlers;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-import org.apache.commons.dbutils.RowProcessor;
-
-/**
- * <p>
- * <code>ResultSetHandler</code> implementation that returns a Map of Beans.
- * <code>ResultSet</code> rows are converted into Beans which are then stored in
- * a Map under the given key.
- * </p>
- * <p>
- * If you had a Person table with a primary key column called ID, you could
- * retrieve rows from the table like this:
- *
- * <pre>
- * ResultSetHandler<Map<Long, Person>> h = new BeanMapdHandler<Long, Person>(Person.class, "id");
- * Map&ltLong, Person> found = queryRunner.query("select id, name, age from person", h);
- * Person jane = found.get(1L); // jane's id is 1
- * String janesName = jane.getName();
- * Integer janesAge = jane.getAge();
- * </pre>
- *
- * Note that the "id" passed to BeanMapHandler can be in any case. The data type
- * returned for id is dependent upon how your JDBC driver converts SQL column
- * types from the Person table into Java types. The "name" and "age" columns are
- * converted according to their property descriptors by DbUtils.
- * </p>
- * <p>
- * This class is thread safe.
- * </p>
- *
- * @param <K>
- * the type of keys maintained by the returned map
- * @param <V>
- * the type of the bean
- * @see org.apache.commons.dbutils.ResultSetHandler
- * @since DbUtils 1.5
- */
-public class BeanMapHandler<K, V> extends AbstractKeyedHandler<K, V> {
-
- /**
- * The Class of beans produced by this handler.
- */
- private final Class<V> type;
-
- /**
- * The RowProcessor implementation to use when converting rows into Objects.
- */
- private final RowProcessor convert;
-
- /**
- * The column index to retrieve key values from. Defaults to 1.
- */
- private final int columnIndex;
-
- /**
- * The column name to retrieve key values from. Either columnName or
- * columnIndex will be used but never both.
- */
- private final String columnName;
-
- /**
- * Creates a new instance of BeanMapHandler. The value of the first column
- * of each row will be a key in the Map.
- *
- * @param type
- * The Class that objects returned from <code>createRow()</code>
- * are created from.
- */
- public BeanMapHandler(Class<V> type) {
- this(type, ArrayHandler.ROW_PROCESSOR, 1, null);
- }
-
- /**
- * Creates a new instance of BeanMapHandler. The value of the first column
- * of each row will be a key in the Map.
- *
- * @param type
- * The Class that objects returned from <code>createRow()</code>
- * are created from.
- * @param convert
- * The <code>RowProcessor</code> implementation to use when
- * converting rows into Beans
- */
- public BeanMapHandler(Class<V> type, RowProcessor convert) {
- this(type, convert, 1, null);
- }
-
- /**
- * Creates a new instance of BeanMapHandler.
- *
- * @param type
- * The Class that objects returned from <code>createRow()</code>
- * are created from.
- * @param columnIndex
- * The values to use as keys in the Map are retrieved from the
- * column at this index.
- */
- public BeanMapHandler(Class<V> type, int columnIndex) {
- this(type, ArrayHandler.ROW_PROCESSOR, columnIndex, null);
- }
-
- /**
- * Creates a new instance of BeanMapHandler.
- *
- * @param type
- * The Class that objects returned from <code>createRow()</code>
- * are created from.
- * @param columnName
- * The values to use as keys in the Map are retrieved from the
- * column with this name.
- */
- public BeanMapHandler(Class<V> type, String columnName) {
- this(type, ArrayHandler.ROW_PROCESSOR, 1, columnName);
- }
-
- /**
- * Private Helper
- *
- * @param convert
- * The <code>RowProcessor</code> implementation to use when
- * converting rows into Beans
- * @param columnIndex
- * The values to use as keys in the Map are retrieved from the
- * column at this index.
- * @param columnName
- * The values to use as keys in the Map are retrieved from the
- * column with this name.
- */
- private BeanMapHandler(Class<V> type, RowProcessor convert,
- int columnIndex, String columnName) {
- super();
- this.type = type;
- this.convert = convert;
- this.columnIndex = columnIndex;
- this.columnName = columnName;
- }
-
- /**
- * This factory method is called by <code>handle()</code> to retrieve the
- * key value from the current <code>ResultSet</code> row.
- * @param rs ResultSet to create a key from
- *
- * @return K from the configured key column name/index
- *
- * @throws SQLException if a database access error occurs
- * @throws ClassCastException if the class datatype does not match the column type
- *
- * @see org.apache.commons.dbutils.handlers.AbstractKeyedHandler#createKey(ResultSet)
- */
- // We assume that the user has picked the correct type to match the column
- // so getObject will return the appropriate type and the cast will succeed.
- @SuppressWarnings("unchecked")
- @Override
- protected K createKey(ResultSet rs) throws SQLException {
- return (columnName == null) ?
- (K) rs.getObject(columnIndex) :
- (K) rs.getObject(columnName);
- }
-
- @Override
- protected V createRow(ResultSet rs) throws SQLException {
- return this.convert.toBean(rs, type);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/main/java/org/apache/commons/dbutils/handlers/ColumnListHandler.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils/handlers/ColumnListHandler.java b/src/main/java/org/apache/commons/dbutils/handlers/ColumnListHandler.java
deleted file mode 100644
index 4f3e506..0000000
--- a/src/main/java/org/apache/commons/dbutils/handlers/ColumnListHandler.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.dbutils.handlers;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-/**
- * <code>ResultSetHandler</code> implementation that converts one
- * <code>ResultSet</code> column into a <code>List</code> of
- * <code>Object</code>s. This class is thread safe.
- *
- * @param <T> The type of the column.
- * @see org.apache.commons.dbutils.ResultSetHandler
- * @since DbUtils 1.1
- */
-public class ColumnListHandler<T> extends AbstractListHandler<T> {
-
- /**
- * The column number to retrieve.
- */
- private final int columnIndex;
-
- /**
- * The column name to retrieve. Either columnName or columnIndex
- * will be used but never both.
- */
- private final String columnName;
-
- /**
- * Creates a new instance of ColumnListHandler. The first column of each
- * row will be returned from <code>handle()</code>.
- */
- public ColumnListHandler() {
- this(1, null);
- }
-
- /**
- * Creates a new instance of ColumnListHandler.
- *
- * @param columnIndex The index of the column to retrieve from the
- * <code>ResultSet</code>.
- */
- public ColumnListHandler(int columnIndex) {
- this(columnIndex, null);
- }
-
- /**
- * Creates a new instance of ColumnListHandler.
- *
- * @param columnName The name of the column to retrieve from the
- * <code>ResultSet</code>.
- */
- public ColumnListHandler(String columnName) {
- this(1, columnName);
- }
-
- /** Private Helper
- * @param columnIndex The index of the column to retrieve from the
- * <code>ResultSet</code>.
- * @param columnName The name of the column to retrieve from the
- * <code>ResultSet</code>.
- */
- private ColumnListHandler(int columnIndex, String columnName) {
- super();
- this.columnIndex = columnIndex;
- this.columnName = columnName;
- }
-
- /**
- * Returns one <code>ResultSet</code> column value as <code>Object</code>.
- * @param rs <code>ResultSet</code> to process.
- * @return <code>Object</code>, never <code>null</code>.
- *
- * @throws SQLException if a database access error occurs
- * @throws ClassCastException if the class datatype does not match the column type
- *
- * @see org.apache.commons.dbutils.handlers.AbstractListHandler#handle(ResultSet)
- */
- // We assume that the user has picked the correct type to match the column
- // so getObject will return the appropriate type and the cast will succeed.
- @SuppressWarnings("unchecked")
- @Override
- protected T handleRow(ResultSet rs) throws SQLException {
- if (this.columnName == null) {
- return (T) rs.getObject(this.columnIndex);
- }
- return (T) rs.getObject(this.columnName);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/main/java/org/apache/commons/dbutils/handlers/KeyedHandler.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils/handlers/KeyedHandler.java b/src/main/java/org/apache/commons/dbutils/handlers/KeyedHandler.java
deleted file mode 100644
index 6ef9bbe..0000000
--- a/src/main/java/org/apache/commons/dbutils/handlers/KeyedHandler.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.dbutils.handlers;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.Map;
-
-import org.apache.commons.dbutils.RowProcessor;
-
-/**
- * <p>
- * <code>ResultSetHandler</code> implementation that returns a Map of Maps.
- * <code>ResultSet</code> rows are converted into Maps which are then stored
- * in a Map under the given key.
- * </p>
- * <p>
- * If you had a Person table with a primary key column called ID, you could
- * retrieve rows from the table like this:
- * <pre>
- * ResultSetHandler h = new KeyedHandler("id");
- * Map found = (Map) queryRunner.query("select id, name, age from person", h);
- * Map jane = (Map) found.get(new Long(1)); // jane's id is 1
- * String janesName = (String) jane.get("name");
- * Integer janesAge = (Integer) jane.get("age");
- * </pre>
- * Note that the "id" passed to KeyedHandler and "name" and "age" passed to the
- * returned Map's get() method can be in any case. The data types returned for
- * name and age are dependent upon how your JDBC driver converts SQL column
- * types from the Person table into Java types.
- * </p>
- * <p>This class is thread safe.</p>
- *
- * @param <K> The type of the key
- * @see org.apache.commons.dbutils.ResultSetHandler
- * @since DbUtils 1.1
- */
-public class KeyedHandler<K> extends AbstractKeyedHandler<K, Map<String, Object>> {
-
- /**
- * The RowProcessor implementation to use when converting rows
- * into Objects.
- */
- protected final RowProcessor convert;
-
- /**
- * The column index to retrieve key values from. Defaults to 1.
- */
- protected final int columnIndex;
-
- /**
- * The column name to retrieve key values from. Either columnName or
- * columnIndex will be used but never both.
- */
- protected final String columnName;
-
- /**
- * Creates a new instance of KeyedHandler. The value of the first column
- * of each row will be a key in the Map.
- */
- public KeyedHandler() {
- this(ArrayHandler.ROW_PROCESSOR, 1, null);
- }
-
- /**
- * Creates a new instance of KeyedHandler. The value of the first column
- * of each row will be a key in the Map.
- *
- * @param convert The <code>RowProcessor</code> implementation
- * to use when converting rows into Maps
- */
- public KeyedHandler(RowProcessor convert) {
- this(convert, 1, null);
- }
-
- /**
- * Creates a new instance of KeyedHandler.
- *
- * @param columnIndex The values to use as keys in the Map are
- * retrieved from the column at this index.
- */
- public KeyedHandler(int columnIndex) {
- this(ArrayHandler.ROW_PROCESSOR, columnIndex, null);
- }
-
- /**
- * Creates a new instance of KeyedHandler.
- *
- * @param columnName The values to use as keys in the Map are
- * retrieved from the column with this name.
- */
- public KeyedHandler(String columnName) {
- this(ArrayHandler.ROW_PROCESSOR, 1, columnName);
- }
-
- /** Private Helper
- * @param convert The <code>RowProcessor</code> implementation
- * to use when converting rows into Maps
- * @param columnIndex The values to use as keys in the Map are
- * retrieved from the column at this index.
- * @param columnName The values to use as keys in the Map are
- * retrieved from the column with this name.
- */
- private KeyedHandler(RowProcessor convert, int columnIndex,
- String columnName) {
- super();
- this.convert = convert;
- this.columnIndex = columnIndex;
- this.columnName = columnName;
- }
- /**
- * This factory method is called by <code>handle()</code> to retrieve the
- * key value from the current <code>ResultSet</code> row. This
- * implementation returns <code>ResultSet.getObject()</code> for the
- * configured key column name or index.
- * @param rs ResultSet to create a key from
- * @return Object from the configured key column name/index
- *
- * @throws SQLException if a database access error occurs
- * @throws ClassCastException if the class datatype does not match the column type
- */
- // We assume that the user has picked the correct type to match the column
- // so getObject will return the appropriate type and the cast will succeed.
- @SuppressWarnings("unchecked")
- @Override
- protected K createKey(ResultSet rs) throws SQLException {
- return (columnName == null) ?
- (K) rs.getObject(columnIndex) :
- (K) rs.getObject(columnName);
- }
-
- /**
- * This factory method is called by <code>handle()</code> to store the
- * current <code>ResultSet</code> row in some object. This
- * implementation returns a <code>Map</code> with case insensitive column
- * names as keys. Calls to <code>map.get("COL")</code> and
- * <code>map.get("col")</code> return the same value.
- * @param rs ResultSet to create a row from
- * @return Object typed Map containing column names to values
- * @throws SQLException if a database access error occurs
- */
- @Override
- protected Map<String, Object> createRow(ResultSet rs) throws SQLException {
- return this.convert.toMap(rs);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/main/java/org/apache/commons/dbutils/handlers/MapHandler.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils/handlers/MapHandler.java b/src/main/java/org/apache/commons/dbutils/handlers/MapHandler.java
deleted file mode 100644
index db00345..0000000
--- a/src/main/java/org/apache/commons/dbutils/handlers/MapHandler.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.dbutils.handlers;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.Map;
-
-import org.apache.commons.dbutils.ResultSetHandler;
-import org.apache.commons.dbutils.RowProcessor;
-
-/**
- * <code>ResultSetHandler</code> implementation that converts the first
- * <code>ResultSet</code> row into a <code>Map</code>. This class is thread
- * safe.
- *
- * @see org.apache.commons.dbutils.ResultSetHandler
- */
-public class MapHandler implements ResultSetHandler<Map<String, Object>> {
-
- /**
- * The RowProcessor implementation to use when converting rows
- * into Maps.
- */
- private final RowProcessor convert;
-
- /**
- * Creates a new instance of MapHandler using a
- * <code>BasicRowProcessor</code> for conversion.
- */
- public MapHandler() {
- this(ArrayHandler.ROW_PROCESSOR);
- }
-
- /**
- * Creates a new instance of MapHandler.
- *
- * @param convert The <code>RowProcessor</code> implementation
- * to use when converting rows into Maps.
- */
- public MapHandler(RowProcessor convert) {
- super();
- this.convert = convert;
- }
-
- /**
- * Converts the first row in the <code>ResultSet</code> into a
- * <code>Map</code>.
- * @param rs <code>ResultSet</code> to process.
- * @return A <code>Map</code> with the values from the first row or
- * <code>null</code> if there are no rows in the <code>ResultSet</code>.
- *
- * @throws SQLException if a database access error occurs
- *
- * @see org.apache.commons.dbutils.ResultSetHandler#handle(java.sql.ResultSet)
- */
- @Override
- public Map<String, Object> handle(ResultSet rs) throws SQLException {
- return rs.next() ? this.convert.toMap(rs) : null;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/main/java/org/apache/commons/dbutils/handlers/MapListHandler.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils/handlers/MapListHandler.java b/src/main/java/org/apache/commons/dbutils/handlers/MapListHandler.java
deleted file mode 100644
index a055f2a..0000000
--- a/src/main/java/org/apache/commons/dbutils/handlers/MapListHandler.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.dbutils.handlers;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.Map;
-
-import org.apache.commons.dbutils.RowProcessor;
-
-/**
- * <code>ResultSetHandler</code> implementation that converts a
- * <code>ResultSet</code> into a <code>List</code> of <code>Map</code>s.
- * This class is thread safe.
- *
- * @see org.apache.commons.dbutils.ResultSetHandler
- */
-public class MapListHandler extends AbstractListHandler<Map<String, Object>> {
-
- /**
- * The RowProcessor implementation to use when converting rows
- * into Maps.
- */
- private final RowProcessor convert;
-
- /**
- * Creates a new instance of MapListHandler using a
- * <code>BasicRowProcessor</code> for conversion.
- */
- public MapListHandler() {
- this(ArrayHandler.ROW_PROCESSOR);
- }
-
- /**
- * Creates a new instance of MapListHandler.
- *
- * @param convert The <code>RowProcessor</code> implementation
- * to use when converting rows into Maps.
- */
- public MapListHandler(RowProcessor convert) {
- super();
- this.convert = convert;
- }
-
- /**
- * Converts the <code>ResultSet</code> row into a <code>Map</code> object.
- * @param rs <code>ResultSet</code> to process.
- * @return A <code>Map</code>, never null.
- *
- * @throws SQLException if a database access error occurs
- *
- * @see org.apache.commons.dbutils.handlers.AbstractListHandler#handle(ResultSet)
- */
- @Override
- protected Map<String, Object> handleRow(ResultSet rs) throws SQLException {
- return this.convert.toMap(rs);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/main/java/org/apache/commons/dbutils/handlers/ScalarHandler.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils/handlers/ScalarHandler.java b/src/main/java/org/apache/commons/dbutils/handlers/ScalarHandler.java
deleted file mode 100644
index 4b70604..0000000
--- a/src/main/java/org/apache/commons/dbutils/handlers/ScalarHandler.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.dbutils.handlers;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-import org.apache.commons.dbutils.ResultSetHandler;
-
-/**
- * <code>ResultSetHandler</code> implementation that converts one
- * <code>ResultSet</code> column into an Object. This class is thread safe.
- *
- * @param <T> The type of the scalar
- * @see org.apache.commons.dbutils.ResultSetHandler
- */
-public class ScalarHandler<T> implements ResultSetHandler<T> {
-
- /**
- * The column number to retrieve.
- */
- private final int columnIndex;
-
- /**
- * The column name to retrieve. Either columnName or columnIndex
- * will be used but never both.
- */
- private final String columnName;
-
- /**
- * Creates a new instance of ScalarHandler. The first column will
- * be returned from <code>handle()</code>.
- */
- public ScalarHandler() {
- this(1, null);
- }
-
- /**
- * Creates a new instance of ScalarHandler.
- *
- * @param columnIndex The index of the column to retrieve from the
- * <code>ResultSet</code>.
- */
- public ScalarHandler(int columnIndex) {
- this(columnIndex, null);
- }
-
- /**
- * Creates a new instance of ScalarHandler.
- *
- * @param columnName The name of the column to retrieve from the
- * <code>ResultSet</code>.
- */
- public ScalarHandler(String columnName) {
- this(1, columnName);
- }
-
- /** Helper constructor
- * @param columnIndex The index of the column to retrieve from the
- * <code>ResultSet</code>.
- * @param columnName The name of the column to retrieve from the
- * <code>ResultSet</code>.
- */
- private ScalarHandler(int columnIndex, String columnName) {
- this.columnIndex = columnIndex;
- this.columnName = columnName;
- }
-
- /**
- * Returns one <code>ResultSet</code> column as an object via the
- * <code>ResultSet.getObject()</code> method that performs type
- * conversions.
- * @param rs <code>ResultSet</code> to process.
- * @return The column or <code>null</code> if there are no rows in
- * the <code>ResultSet</code>.
- *
- * @throws SQLException if a database access error occurs
- * @throws ClassCastException if the class datatype does not match the column type
- *
- * @see org.apache.commons.dbutils.ResultSetHandler#handle(java.sql.ResultSet)
- */
- // We assume that the user has picked the correct type to match the column
- // so getObject will return the appropriate type and the cast will succeed.
- @SuppressWarnings("unchecked")
- @Override
- public T handle(ResultSet rs) throws SQLException {
-
- if (rs.next()) {
- if (this.columnName == null) {
- return (T) rs.getObject(this.columnIndex);
- }
- return (T) rs.getObject(this.columnName);
- }
- return null;
- }
-}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/main/java/org/apache/commons/dbutils/handlers/package-info.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils/handlers/package-info.java b/src/main/java/org/apache/commons/dbutils/handlers/package-info.java
deleted file mode 100644
index 5a3b16a..0000000
--- a/src/main/java/org/apache/commons/dbutils/handlers/package-info.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Implementations of the org.apache.commons.dbutils.ResultSetHandler interface.
- */
-package org.apache.commons.dbutils.handlers;
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/main/java/org/apache/commons/dbutils/package-info.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils/package-info.java b/src/main/java/org/apache/commons/dbutils/package-info.java
deleted file mode 100644
index ad08013..0000000
--- a/src/main/java/org/apache/commons/dbutils/package-info.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * DbUtils is a small set of classes designed to make working with JDBC easier. JDBC resource cleanup code is mundane,
- * error prone work so these classes abstract out all of the cleanup tasks from your code leaving you with what you
- * really wanted to do with JDBC in the first place: query and update data.
- *
- * This package contains the core classes and interfaces - DbUtils, QueryRunner and the ResultSetHandler interface
- * should be your first items of interest.
- */
-package org.apache.commons.dbutils;
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/main/java/org/apache/commons/dbutils/wrappers/SqlNullCheckedResultSet.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils/wrappers/SqlNullCheckedResultSet.java b/src/main/java/org/apache/commons/dbutils/wrappers/SqlNullCheckedResultSet.java
deleted file mode 100644
index a83735c..0000000
--- a/src/main/java/org/apache/commons/dbutils/wrappers/SqlNullCheckedResultSet.java
+++ /dev/null
@@ -1,608 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.dbutils.wrappers;
-
-import java.io.InputStream;
-import java.io.Reader;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.math.BigDecimal;
-import java.net.URL;
-import java.sql.Blob;
-import java.sql.Clob;
-import java.sql.Date;
-import java.sql.Ref;
-import java.sql.ResultSet;
-import java.sql.Time;
-import java.sql.Timestamp;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.commons.dbutils.ProxyFactory;
-
-/**
- * Decorates a <code>ResultSet</code> with checks for a SQL NULL value on each
- * <code>getXXX</code> method. If a column value obtained by a
- * <code>getXXX</code> method is not SQL NULL, the column value is returned. If
- * the column value is SQL null, an alternate value is returned. The alternate
- * value defaults to the Java <code>null</code> value, which can be overridden
- * for instances of the class.
- *
- * <p>
- * Usage example:
- * <blockquote>
- * <pre>
- * Connection conn = // somehow get a connection
- * Statement stmt = conn.createStatement();
- * ResultSet rs = stmt.executeQuery("SELECT col1, col2 FROM table1");
- *
- * // Wrap the result set for SQL NULL checking
- * SqlNullCheckedResultSet wrapper = new SqlNullCheckedResultSet(rs);
- * wrapper.setNullString("---N/A---"); // Set null string
- * wrapper.setNullInt(-999); // Set null integer
- * rs = ProxyFactory.instance().createResultSet(wrapper);
- *
- * while (rs.next()) {
- * // If col1 is SQL NULL, value returned will be "---N/A---"
- * String col1 = rs.getString("col1");
- * // If col2 is SQL NULL, value returned will be -999
- * int col2 = rs.getInt("col2");
- * }
- * rs.close();
- * </pre>
- * </blockquote>
- * </p>
- * <p>Unlike some other classes in DbUtils, this class is NOT thread-safe.</p>
- */
-public class SqlNullCheckedResultSet implements InvocationHandler {
-
- /**
- * Maps normal method names (ie. "getBigDecimal") to the corresponding null
- * Method object (ie. getNullBigDecimal).
- */
- private static final Map<String, Method> nullMethods = new HashMap<String, Method>();
-
- /**
- * The {@code getNull} string prefix.
- * @since 1.4
- */
- private static final String GET_NULL_PREFIX = "getNull";
-
- static {
- Method[] methods = SqlNullCheckedResultSet.class.getMethods();
- for (int i = 0; i < methods.length; i++) {
- String methodName = methods[i].getName();
-
- if (methodName.startsWith(GET_NULL_PREFIX)) {
- String normalName = "get" + methodName.substring(GET_NULL_PREFIX.length());
- nullMethods.put(normalName, methods[i]);
- }
- }
- }
-
- /**
- * The factory to create proxies with.
- */
- private static final ProxyFactory factory = ProxyFactory.instance();
-
- /**
- * Wraps the <code>ResultSet</code> in an instance of this class. This is
- * equivalent to:
- * <pre>
- * ProxyFactory.instance().createResultSet(new SqlNullCheckedResultSet(rs));
- * </pre>
- *
- * @param rs The <code>ResultSet</code> to wrap.
- * @return wrapped ResultSet
- */
- public static ResultSet wrap(ResultSet rs) {
- return factory.createResultSet(new SqlNullCheckedResultSet(rs));
- }
-
- private InputStream nullAsciiStream = null;
- private BigDecimal nullBigDecimal = null;
- private InputStream nullBinaryStream = null;
- private Blob nullBlob = null;
- private boolean nullBoolean = false;
- private byte nullByte = 0;
- private byte[] nullBytes = null;
- private Reader nullCharacterStream = null;
- private Clob nullClob = null;
- private Date nullDate = null;
- private double nullDouble = 0.0;
- private float nullFloat = 0.0f;
- private int nullInt = 0;
- private long nullLong = 0;
- private Object nullObject = null;
- private Ref nullRef = null;
- private short nullShort = 0;
- private String nullString = null;
- private Time nullTime = null;
- private Timestamp nullTimestamp = null;
- private URL nullURL = null;
-
- /**
- * The wrapped result.
- */
- private final ResultSet rs;
-
- /**
- * Constructs a new instance of
- * <code>SqlNullCheckedResultSet</code>
- * to wrap the specified <code>ResultSet</code>.
- * @param rs ResultSet to wrap
- */
- public SqlNullCheckedResultSet(ResultSet rs) {
- super();
- this.rs = rs;
- }
-
- /**
- * Returns the value when a SQL null is encountered as the result of
- * invoking a <code>getAsciiStream</code> method.
- *
- * @return the value
- */
- public InputStream getNullAsciiStream() {
- return this.nullAsciiStream;
- }
-
- /**
- * Returns the value when a SQL null is encountered as the result of
- * invoking a <code>getBigDecimal</code> method.
- *
- * @return the value
- */
- public BigDecimal getNullBigDecimal() {
- return this.nullBigDecimal;
- }
-
- /**
- * Returns the value when a SQL null is encountered as the result of
- * invoking a <code>getBinaryStream</code> method.
- *
- * @return the value
- */
- public InputStream getNullBinaryStream() {
- return this.nullBinaryStream;
- }
-
- /**
- * Returns the value when a SQL null is encountered as the result of
- * invoking a <code>getBlob</code> method.
- *
- * @return the value
- */
- public Blob getNullBlob() {
- return this.nullBlob;
- }
-
- /**
- * Returns the value when a SQL null is encountered as the result of
- * invoking a <code>getBoolean</code> method.
- *
- * @return the value
- */
- public boolean getNullBoolean() {
- return this.nullBoolean;
- }
-
- /**
- * Returns the value when a SQL null is encountered as the result of
- * invoking a <code>getByte</code> method.
- *
- * @return the value
- */
- public byte getNullByte() {
- return this.nullByte;
- }
-
- /**
- * Returns the value when a SQL null is encountered as the result of
- * invoking a <code>getBytes</code> method.
- *
- * @return the value
- */
- public byte[] getNullBytes() {
- if (this.nullBytes == null) {
- return null;
- }
- byte[] copy = new byte[this.nullBytes.length];
- System.arraycopy(this.nullBytes, 0, copy, 0, this.nullBytes.length);
- return copy;
- }
-
- /**
- * Returns the value when a SQL null is encountered as the result of
- * invoking a <code>getCharacterStream</code> method.
- *
- * @return the value
- */
- public Reader getNullCharacterStream() {
- return this.nullCharacterStream;
- }
-
- /**
- * Returns the value when a SQL null is encountered as the result of
- * invoking a <code>getClob</code> method.
- *
- * @return the value
- */
- public Clob getNullClob() {
- return this.nullClob;
- }
-
- /**
- * Returns the value when a SQL null is encountered as the result of
- * invoking a <code>getDate</code> method.
- *
- * @return the value
- */
- public Date getNullDate() {
- return this.nullDate;
- }
-
- /**
- * Returns the value when a SQL null is encountered as the result of
- * invoking a <code>getDouble</code> method.
- *
- * @return the value
- */
- public double getNullDouble() {
- return this.nullDouble;
- }
-
- /**
- * Returns the value when a SQL null is encountered as the result of
- * invoking a <code>getFloat</code> method.
- *
- * @return the value
- */
- public float getNullFloat() {
- return this.nullFloat;
- }
-
- /**
- * Returns the value when a SQL null is encountered as the result of
- * invoking a <code>getInt</code> method.
- *
- * @return the value
- */
- public int getNullInt() {
- return this.nullInt;
- }
-
- /**
- * Returns the value when a SQL null is encountered as the result of
- * invoking a <code>getLong</code> method.
- *
- * @return the value
- */
- public long getNullLong() {
- return this.nullLong;
- }
-
- /**
- * Returns the value when a SQL null is encountered as the result of
- * invoking a <code>getObject</code> method.
- *
- * @return the value
- */
- public Object getNullObject() {
- return this.nullObject;
- }
-
- /**
- * Returns the value when a SQL null is encountered as the result of
- * invoking a <code>getRef</code> method.
- *
- * @return the value
- */
- public Ref getNullRef() {
- return this.nullRef;
- }
-
- /**
- * Returns the value when a SQL null is encountered as the result of
- * invoking a <code>getShort</code> method.
- *
- * @return the value
- */
- public short getNullShort() {
- return this.nullShort;
- }
-
- /**
- * Returns the value when a SQL null is encountered as the result of
- * invoking a <code>getString</code> method.
- *
- * @return the value
- */
- public String getNullString() {
- return this.nullString;
- }
-
- /**
- * Returns the value when a SQL null is encountered as the result of
- * invoking a <code>getTime</code> method.
- *
- * @return the value
- */
- public Time getNullTime() {
- return this.nullTime;
- }
-
- /**
- * Returns the value when a SQL null is encountered as the result of
- * invoking a <code>getTimestamp</code> method.
- *
- * @return the value
- */
- public Timestamp getNullTimestamp() {
- return this.nullTimestamp;
- }
-
- /**
- * Returns the value when a SQL null is encountered as the result of
- * invoking a <code>getURL</code> method.
- *
- * @return the value
- */
- public URL getNullURL() {
- return this.nullURL;
- }
-
- /**
- * Intercepts calls to <code>get*</code> methods and calls the appropriate
- * <code>getNull*</code> method if the <code>ResultSet</code> returned
- * <code>null</code>.
- *
- * @see java.lang.reflect.InvocationHandler#invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
- * @param proxy Not used; all method calls go to the internal result set
- * @param method The method to invoke on the result set
- * @param args The arguments to pass to the result set
- * @return null checked result
- * @throws Throwable error
- */
- @Override
- public Object invoke(Object proxy, Method method, Object[] args)
- throws Throwable {
-
- Object result = method.invoke(this.rs, args);
-
- Method nullMethod = nullMethods.get(method.getName());
-
- // Check nullMethod != null first so that we don't call wasNull()
- // before a true getter method was invoked on the ResultSet.
- return (nullMethod != null && this.rs.wasNull())
- ? nullMethod.invoke(this, (Object[]) null)
- : result;
- }
-
- /**
- * Sets the value to return when a SQL null is encountered as the result of
- * invoking a <code>getAsciiStream</code> method.
- *
- * @param nullAsciiStream the value
- */
- public void setNullAsciiStream(InputStream nullAsciiStream) {
- this.nullAsciiStream = nullAsciiStream;
- }
-
- /**
- * Sets the value to return when a SQL null is encountered as the result of
- * invoking a <code>getBigDecimal</code> method.
- *
- * @param nullBigDecimal the value
- */
- public void setNullBigDecimal(BigDecimal nullBigDecimal) {
- this.nullBigDecimal = nullBigDecimal;
- }
-
- /**
- * Sets the value to return when a SQL null is encountered as the result of
- * invoking a <code>getBinaryStream</code> method.
- *
- * @param nullBinaryStream the value
- */
- public void setNullBinaryStream(InputStream nullBinaryStream) {
- this.nullBinaryStream = nullBinaryStream;
- }
-
- /**
- * Sets the value to return when a SQL null is encountered as the result of
- * invoking a <code>getBlob</code> method.
- *
- * @param nullBlob the value
- */
- public void setNullBlob(Blob nullBlob) {
- this.nullBlob = nullBlob;
- }
-
- /**
- * Sets the value to return when a SQL null is encountered as the result of
- * invoking a <code>getBoolean</code> method.
- *
- * @param nullBoolean the value
- */
- public void setNullBoolean(boolean nullBoolean) {
- this.nullBoolean = nullBoolean;
- }
-
- /**
- * Sets the value to return when a SQL null is encountered as the result of
- * invoking a <code>getByte</code> method.
- *
- * @param nullByte the value
- */
- public void setNullByte(byte nullByte) {
- this.nullByte = nullByte;
- }
-
- /**
- * Sets the value to return when a SQL null is encountered as the result of
- * invoking a <code>getBytes</code> method.
- *
- * @param nullBytes the value
- */
- public void setNullBytes(byte[] nullBytes) {
- byte[] copy = new byte[nullBytes.length];
- System.arraycopy(nullBytes, 0, copy, 0, nullBytes.length);
- this.nullBytes = copy;
- }
-
- /**
- * Sets the value to return when a SQL null is encountered as the result of
- * invoking a <code>getCharacterStream</code> method.
- *
- * @param nullCharacterStream the value
- */
- public void setNullCharacterStream(Reader nullCharacterStream) {
- this.nullCharacterStream = nullCharacterStream;
- }
-
- /**
- * Sets the value to return when a SQL null is encountered as the result of
- * invoking a <code>getClob</code> method.
- *
- * @param nullClob the value
- */
- public void setNullClob(Clob nullClob) {
- this.nullClob = nullClob;
- }
-
- /**
- * Sets the value to return when a SQL null is encountered as the result of
- * invoking a <code>getDate</code> method.
- *
- * @param nullDate the value
- */
- public void setNullDate(Date nullDate) {
- this.nullDate = nullDate;
- }
-
- /**
- * Sets the value to return when a SQL null is encountered as the result of
- * invoking a <code>getDouble</code> method.
- *
- * @param nullDouble the value
- */
- public void setNullDouble(double nullDouble) {
- this.nullDouble = nullDouble;
- }
-
- /**
- * Sets the value to return when a SQL null is encountered as the result of
- * invoking a <code>getFloat</code> method.
- *
- * @param nullFloat the value
- */
- public void setNullFloat(float nullFloat) {
- this.nullFloat = nullFloat;
- }
-
- /**
- * Sets the value to return when a SQL null is encountered as the result of
- * invoking a <code>getInt</code> method.
- *
- * @param nullInt the value
- */
- public void setNullInt(int nullInt) {
- this.nullInt = nullInt;
- }
-
- /**
- * Sets the value to return when a SQL null is encountered as the result of
- * invoking a <code>getLong</code> method.
- *
- * @param nullLong the value
- */
- public void setNullLong(long nullLong) {
- this.nullLong = nullLong;
- }
-
- /**
- * Sets the value to return when a SQL null is encountered as the result of
- * invoking a <code>getObject</code> method.
- *
- * @param nullObject the value
- */
- public void setNullObject(Object nullObject) {
- this.nullObject = nullObject;
- }
-
- /**
- * Sets the value to return when a SQL null is encountered as the result of
- * invoking a <code>getRef</code> method.
- *
- * @param nullRef the value
- */
- public void setNullRef(Ref nullRef) {
- this.nullRef = nullRef;
- }
-
- /**
- * Sets the value to return when a SQL null is encountered as the result of
- * invoking a <code>getShort</code> method.
- *
- * @param nullShort the value
- */
- public void setNullShort(short nullShort) {
- this.nullShort = nullShort;
- }
-
- /**
- * Sets the value to return when a SQL null is encountered as the result of
- * invoking a <code>getString</code> method.
- *
- * @param nullString the value
- */
- public void setNullString(String nullString) {
- this.nullString = nullString;
- }
-
- /**
- * Sets the value to return when a SQL null is encountered as the result of
- * invoking a <code>getTime</code> method.
- *
- * @param nullTime the value
- */
- public void setNullTime(Time nullTime) {
- this.nullTime = nullTime;
- }
-
- /**
- * Sets the value to return when a SQL null is encountered as the result of
- * invoking a <code>getTimestamp</code> method.
- *
- * @param nullTimestamp the value
- */
- public void setNullTimestamp(Timestamp nullTimestamp) {
- this.nullTimestamp = nullTimestamp;
- }
-
- /**
- * Sets the value to return when a SQL null is encountered as the result of
- * invoking a <code>getURL</code> method.
- *
- * @param nullURL the value
- */
- public void setNullURL(URL nullURL) {
- this.nullURL = nullURL;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/main/java/org/apache/commons/dbutils/wrappers/StringTrimmedResultSet.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils/wrappers/StringTrimmedResultSet.java b/src/main/java/org/apache/commons/dbutils/wrappers/StringTrimmedResultSet.java
deleted file mode 100644
index 830ef72..0000000
--- a/src/main/java/org/apache/commons/dbutils/wrappers/StringTrimmedResultSet.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.dbutils.wrappers;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.sql.ResultSet;
-
-import org.apache.commons.dbutils.ProxyFactory;
-
-/**
- * Wraps a <code>ResultSet</code> to trim strings returned by the
- * <code>getString()</code> and <code>getObject()</code> methods.
- *
- * <p>
- * Usage Example:
- * This example shows how to decorate ResultSets so processing continues as
- * normal but all Strings are trimmed before being returned from the
- * <code>ResultSet</code>.
- * </p>
- *
- * <pre>
- * ResultSet rs = // somehow get a ResultSet;
- *
- * // Substitute wrapped ResultSet with additional behavior for real ResultSet
- * rs = StringTrimmedResultSet.wrap(rs);
- *
- * // Pass wrapped ResultSet to processor
- * List list = new BasicRowProcessor().toBeanList(rs);
- * </pre>
- */
-public class StringTrimmedResultSet implements InvocationHandler {
-
- /**
- * The factory to create proxies with.
- */
- private static final ProxyFactory factory = ProxyFactory.instance();
-
- /**
- * Wraps the <code>ResultSet</code> in an instance of this class. This is
- * equivalent to:
- * <pre>
- * ProxyFactory.instance().createResultSet(new StringTrimmedResultSet(rs));
- * </pre>
- *
- * @param rs The <code>ResultSet</code> to wrap.
- * @return wrapped ResultSet
- */
- public static ResultSet wrap(ResultSet rs) {
- return factory.createResultSet(new StringTrimmedResultSet(rs));
- }
-
- /**
- * The wrapped result.
- */
- private final ResultSet rs;
-
- /**
- * Constructs a new instance of <code>StringTrimmedResultSet</code>
- * to wrap the specified <code>ResultSet</code>.
- * @param rs ResultSet to wrap
- */
- public StringTrimmedResultSet(ResultSet rs) {
- super();
- this.rs = rs;
- }
-
- /**
- * Intercept calls to the <code>getString()</code> and
- * <code>getObject()</code> methods and trim any Strings before they're
- * returned.
- *
- * @see java.lang.reflect.InvocationHandler#invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
- * @param proxy Not used; all method calls go to the internal result set
- * @param method The method to invoke on the result set
- * @param args The arguments to pass to the result set
- * @return string trimmed result
- * @throws Throwable error
- */
- @Override
- public Object invoke(Object proxy, Method method, Object[] args)
- throws Throwable {
-
- Object result = method.invoke(this.rs, args);
-
- if ((method.getName().equals("getObject")
- || method.getName().equals("getString"))
- && result instanceof String) {
- result = ((String) result).trim();
- }
-
- return result;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/main/java/org/apache/commons/dbutils/wrappers/package-info.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils/wrappers/package-info.java b/src/main/java/org/apache/commons/dbutils/wrappers/package-info.java
deleted file mode 100644
index 70ef2aa..0000000
--- a/src/main/java/org/apache/commons/dbutils/wrappers/package-info.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Wrappers that add functionality to java.sql classes.
- */
-package org.apache.commons.dbutils.wrappers;
[27/58] [abbrv] commons-dbutils git commit: Changed QueryExecutor to
be public and ArrayHandler to be generic
Posted by th...@apache.org.
Changed QueryExecutor to be public and ArrayHandler to be generic
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/dbutils/branches/2_0@1481176 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/commons-dbutils/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-dbutils/commit/9784827b
Tree: http://git-wip-us.apache.org/repos/asf/commons-dbutils/tree/9784827b
Diff: http://git-wip-us.apache.org/repos/asf/commons-dbutils/diff/9784827b
Branch: refs/heads/2_0
Commit: 9784827b6a72701d84cb037ac1cae95c90729292
Parents: 3f4dcc9
Author: Bill Speirs <ws...@apache.org>
Authored: Fri May 10 20:17:24 2013 +0000
Committer: Bill Speirs <ws...@apache.org>
Committed: Fri May 10 20:17:24 2013 +0000
----------------------------------------------------------------------
.../java/org/apache/commons/dbutils2/QueryExecutor.java | 2 +-
.../apache/commons/dbutils2/handlers/ArrayHandler.java | 12 ++++++------
2 files changed, 7 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/9784827b/src/main/java/org/apache/commons/dbutils2/QueryExecutor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/QueryExecutor.java b/src/main/java/org/apache/commons/dbutils2/QueryExecutor.java
index fe59db1..5fc5c25 100644
--- a/src/main/java/org/apache/commons/dbutils2/QueryExecutor.java
+++ b/src/main/java/org/apache/commons/dbutils2/QueryExecutor.java
@@ -25,7 +25,7 @@ import java.sql.SQLException;
*
* @since 2.0
*/
-class QueryExecutor extends AbstractExecutor<QueryExecutor> {
+public class QueryExecutor extends AbstractExecutor<QueryExecutor> {
private final boolean closeConn;
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/9784827b/src/main/java/org/apache/commons/dbutils2/handlers/ArrayHandler.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils2/handlers/ArrayHandler.java b/src/main/java/org/apache/commons/dbutils2/handlers/ArrayHandler.java
index 0863894..ddac362 100644
--- a/src/main/java/org/apache/commons/dbutils2/handlers/ArrayHandler.java
+++ b/src/main/java/org/apache/commons/dbutils2/handlers/ArrayHandler.java
@@ -25,12 +25,12 @@ import org.apache.commons.dbutils2.RowProcessor;
/**
* <code>ResultSetHandler</code> implementation that converts a
- * <code>ResultSet</code> into an <code>Object[]</code>. This class is
+ * <code>ResultSet</code> into an <code>T[]</code>. This class is
* thread safe.
*
* @see org.apache.commons.dbutils2.ResultSetHandler
*/
-public class ArrayHandler implements ResultSetHandler<Object[]> {
+public class ArrayHandler<T> implements ResultSetHandler<T[]> {
/**
* Singleton processor instance that handlers share to save memory. Notice
@@ -65,17 +65,17 @@ public class ArrayHandler implements ResultSetHandler<Object[]> {
}
/**
- * Places the column values from the first row in an <code>Object[]</code>.
+ * Places the column values from the first row in an <code>T[]</code>.
* @param rs <code>ResultSet</code> to process.
- * @return An Object[] or <code>null</code> if there are no rows in the
+ * @return An T[] or <code>null</code> if there are no rows in the
* <code>ResultSet</code>.
*
* @throws SQLException if a database access error occurs
* @see org.apache.commons.dbutils2.ResultSetHandler#handle(java.sql.ResultSet)
*/
@Override
- public Object[] handle(ResultSet rs) throws SQLException {
- return rs.next() ? this.convert.toArray(rs) : null;
+ public T[] handle(ResultSet rs) throws SQLException {
+ return (T[]) (rs.next() ? this.convert.toArray(rs) : null);
}
}