]> source.dussan.org Git - jackcess.git/commitdiff
Applied Mitchell Friedman's patch for support of additional JDBC data types.
authorTim McCune <javajedi@users.sf.net>
Fri, 22 Jul 2005 03:31:10 +0000 (03:31 +0000)
committerTim McCune <javajedi@users.sf.net>
Fri, 22 Jul 2005 03:31:10 +0000 (03:31 +0000)
Added CREDITS.txt.

git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@18 f203690c-595d-4dc9-a70b-905162fa7fd2

CREDITS.txt [new file with mode: 0644]
src/java/com/healthmarketscience/jackcess/Column.java
src/java/com/healthmarketscience/jackcess/DataType.java
src/java/com/healthmarketscience/jackcess/Database.java
xdocs/faq.fml

diff --git a/CREDITS.txt b/CREDITS.txt
new file mode 100644 (file)
index 0000000..f78ece8
--- /dev/null
@@ -0,0 +1,3 @@
+Tim McCune - Original author and project founder
+Rob DiMarco - Added ability to import delimited text into new tables
+Mitchell J. Friedman - Added support for additional JDBC data types
index cb0b64db0d14c433b4335ae3ae53feaf1f059c5f..54602cca31f49db9d1961d43cca824ce1e9f5190 100644 (file)
@@ -404,18 +404,21 @@ public class Column implements Comparable<Column> {
     }
     ByteBuffer buffer = ByteBuffer.allocate(size);
     buffer.order(order);
+    if (obj instanceof Boolean) {
+      obj = ((Boolean) obj) ? 1 : 0;
+    }
     if (_type == DataType.BOOLEAN) {
       //Do nothing
     } else if (_type == DataType.BYTE) {
-      buffer.put(((Byte) obj).byteValue());
+      buffer.put(((Number) obj).byteValue());
     } else if (_type == DataType.INT) {
-      buffer.putShort(((Short) obj).shortValue());
+      buffer.putShort(((Number) obj).shortValue());
     } else if (_type == DataType.LONG) {
-      buffer.putInt(((Integer) obj).intValue());
+      buffer.putInt(((Number) obj).intValue());
     } else if (_type == DataType.DOUBLE) {
-      buffer.putDouble(((Double) obj).doubleValue());
+      buffer.putDouble(((Number) obj).doubleValue());
     } else if (_type == DataType.FLOAT) {
-      buffer.putFloat(((Float) obj).floatValue());
+      buffer.putFloat(((Number) obj).floatValue());
     } else if (_type == DataType.SHORT_DATE_TIME) {
       Calendar cal = Calendar.getInstance();
       cal.setTime((Date) obj);
index ce23c25fba75cafcd131f16ba86912641ecdf0a5..e7747c640a490091b7af57321eb07b81a9aef147 100644 (file)
@@ -62,6 +62,14 @@ public enum DataType {
         SQL_TYPES.put(type._sqlType, type);
       }
     }
+    SQL_TYPES.put(Types.BIT, BYTE);
+    SQL_TYPES.put(Types.BLOB, OLE);
+    SQL_TYPES.put(Types.BIGINT, LONG);
+    SQL_TYPES.put(Types.CHAR, TEXT);
+    SQL_TYPES.put(Types.DATE, SHORT_DATE_TIME);
+    SQL_TYPES.put(Types.REAL, DOUBLE);
+    SQL_TYPES.put(Types.TIME, SHORT_DATE_TIME);
+    SQL_TYPES.put(Types.VARBINARY, BINARY);
   }
   
   private static Map<Byte, DataType> DATA_TYPES = new HashMap<Byte, DataType>();
index 4aaf50859572a5e550c1955865ae5f39b8f07167..5447dd27002e54bbf1979fdf12565d8b1d635fd5 100644 (file)
@@ -546,16 +546,24 @@ public class Database {
     int textCount = 0;
     int totalSize = 0;
     for (int i = 1; i <= md.getColumnCount(); i++) {
-      switch (md.getColumnType(i)) {
-        case Types.INTEGER:
-        case Types.FLOAT:
+      DataType accessColumnType = DataType.fromSQLType(md.getColumnType(i));
+      switch (accessColumnType) {
+        case BYTE:
+        case INT:
+        case LONG:
+        case MONEY:
+        case FLOAT:
+        case NUMERIC:
           totalSize += 4;
           break;
-        case Types.DOUBLE:
-        case Types.DATE:
+        case DOUBLE:
+        case SHORT_DATE_TIME:
           totalSize += 8;
           break;
-        case Types.VARCHAR:
+        case BINARY:
+        case TEXT:
+        case OLE:
+        case MEMO:
           textCount++;
           break;
       }
index ce2e1b3398d59471852de6d59af17116003c344a..93c05f42ded91f5a4baeaae7ca4f995cc3bfb085 100644 (file)
       </answer>
     </faq>
 
+    <faq id="dependencies">
+      <question>Why do I get a NoClassDefFoundError?</question>
+      <answer>
+        <p>
+          Probably because you're missing a jar that Jackcess depends on from your
+          classpath.  Take a loook at the <a href="http://jackcess.sourceforge.net/dependencies.html">dependencies list</a>.  The first 3 are required for both building and running
+          and can be found either at the <a href="http://jakarta.apache.org/commons/">
+          Jakarta Commons</a> or the <a href="http://www.ibiblio.org/maven">Ibiblio
+          Maven Repository</a>.  The other 3 are only required for building, in which
+          case, Maven will find them for you.
+        </p>
+      </answer>
+    </faq>
+
     <faq id="hms">
       <question>Who is Health Market Science?</question>
       <answer>