aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTim McCune <javajedi@users.sf.net>2005-07-22 03:31:10 +0000
committerTim McCune <javajedi@users.sf.net>2005-07-22 03:31:10 +0000
commit468b7748b3df1870bd477d5e46b2f310859534b6 (patch)
tree7350588cfe3c59dae280fa9f566e2b35fd11cf58
parent26026108354c884426085eb33c86208c299ccc7a (diff)
downloadjackcess-468b7748b3df1870bd477d5e46b2f310859534b6.tar.gz
jackcess-468b7748b3df1870bd477d5e46b2f310859534b6.zip
Applied Mitchell Friedman's patch for support of additional JDBC data types.
Added CREDITS.txt. git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@18 f203690c-595d-4dc9-a70b-905162fa7fd2
-rw-r--r--CREDITS.txt3
-rw-r--r--src/java/com/healthmarketscience/jackcess/Column.java13
-rw-r--r--src/java/com/healthmarketscience/jackcess/DataType.java8
-rw-r--r--src/java/com/healthmarketscience/jackcess/Database.java20
-rw-r--r--xdocs/faq.fml14
5 files changed, 47 insertions, 11 deletions
diff --git a/CREDITS.txt b/CREDITS.txt
new file mode 100644
index 0000000..f78ece8
--- /dev/null
+++ b/CREDITS.txt
@@ -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
diff --git a/src/java/com/healthmarketscience/jackcess/Column.java b/src/java/com/healthmarketscience/jackcess/Column.java
index cb0b64d..54602cc 100644
--- a/src/java/com/healthmarketscience/jackcess/Column.java
+++ b/src/java/com/healthmarketscience/jackcess/Column.java
@@ -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);
diff --git a/src/java/com/healthmarketscience/jackcess/DataType.java b/src/java/com/healthmarketscience/jackcess/DataType.java
index ce23c25..e7747c6 100644
--- a/src/java/com/healthmarketscience/jackcess/DataType.java
+++ b/src/java/com/healthmarketscience/jackcess/DataType.java
@@ -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>();
diff --git a/src/java/com/healthmarketscience/jackcess/Database.java b/src/java/com/healthmarketscience/jackcess/Database.java
index 4aaf508..5447dd2 100644
--- a/src/java/com/healthmarketscience/jackcess/Database.java
+++ b/src/java/com/healthmarketscience/jackcess/Database.java
@@ -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;
}
diff --git a/xdocs/faq.fml b/xdocs/faq.fml
index ce2e1b3..93c05f4 100644
--- a/xdocs/faq.fml
+++ b/xdocs/faq.fml
@@ -110,6 +110,20 @@
</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>