Hi
I had a problem with the Datatypes when accessing a MSAccess DB.
I changed the method getColumnValueAsString to
Object retObj = resultSet.getObject(columnIndex);
return retObj != null? retObj.toString(): "null";
What was the reason of the typ-checking in this method?
greetings
fred
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
1) Charset handling for CHAR, VARCHAR, LONGVARCHAR. When using Onject.toString() I am not sure how to force Java read byte[] to String in defined charsets. Any hint is welcome!
2) Remaining "case"s but current (version 0.19) "default" (CLOB, BLOB, ARRAY, REF, STRUCT, JAVA OBJECT) switch can be shrinked into Your code.
I had some other private code there, which I removed, but type checking rested.
Stepan
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
which problem do You have with dbsql2xml 0.19 together with MS Access? I use dbsql2xml with MS Access too and I have no problems yet. But definetly I want to change code to be problem free. If You can, I would appreciate small example MDB (small one up to 500 kB or 1 MB) causing Your problem sending to my address "xrybs01@seznam.cz".
Thank You in advance.
Stepan
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I tracked the problem down in my case.
The DataType is -1, in Access the Type is Memo.
It is not my DataBase, so i dont know why memo is used in this case. But if the column is empty i get an exception.
the resultSet.getBytes() method returns null and resultSet.wasNull() throws a NullPointerException
So i changed: if (byteArray == null || resultSet.wasNull())
But apart from that the encoding of the character is not correct. Characters like ,, are converted wrong.
If i use Object.toString it works. Charset is UTF-8
fred
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
> the resultSet.getBytes() method returns null and resultSet.wasNull() throws a NullPointerException
...is strange for me, because AFAIK in case of SQL "NULL" value according do JDK 5.0 documentation
a) resultSet.getBytes() should return null
b) resultSet.wasNull() should return true
but resultSet.wasNull() should be sufficient. There is no problem to add into condition Your proposed code
if (byteArray == null || resultSet.wasNull())
and I am going to add it just now, because it should not cost any overtime due to short circuit operator and should avoid exception in case of MS Access driver.
> But apart from that the encoding of the character is not correct. Characters like ,, are converted wrong.
...I think, that , , are common west European characters used for example in German alphabet and there should not be any problem with leaving encoding void. But for alphabets such is my Czech (East Europe) one, reading data from one encoding, when they are in another, it always results in error, if they are not in any "Unicode".
You wrote, that these characters are converted wrong. Are You sure, that You are using second column from following table?
It should work. I am also not sure, if MS Access MEMO field is binary or character nature. If it is character nature, I guess, taht it can be stored in Unicode like NVARCHAR. But I do not have MS Access now, so I can not try it.
Your feedback or feedback of anyone else about (not only encoding) is welcome. Thank You.
Stepan
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi
I had a problem with the Datatypes when accessing a MSAccess DB.
I changed the method getColumnValueAsString to
Object retObj = resultSet.getObject(columnIndex);
return retObj != null? retObj.toString(): "null";
What was the reason of the typ-checking in this method?
greetings
fred
Hi, Fred!
Reasons? The only one is following the first one:
1) Charset handling for CHAR, VARCHAR, LONGVARCHAR. When using Onject.toString() I am not sure how to force Java read byte[] to String in defined charsets. Any hint is welcome!
2) Remaining "case"s but current (version 0.19) "default" (CLOB, BLOB, ARRAY, REF, STRUCT, JAVA OBJECT) switch can be shrinked into Your code.
I had some other private code there, which I removed, but type checking rested.
Stepan
Fred,
which problem do You have with dbsql2xml 0.19 together with MS Access? I use dbsql2xml with MS Access too and I have no problems yet. But definetly I want to change code to be problem free. If You can, I would appreciate small example MDB (small one up to 500 kB or 1 MB) causing Your problem sending to my address "xrybs01@seznam.cz".
Thank You in advance.
Stepan
I tracked the problem down in my case.
The DataType is -1, in Access the Type is Memo.
It is not my DataBase, so i dont know why memo is used in this case. But if the column is empty i get an exception.
the resultSet.getBytes() method returns null and resultSet.wasNull() throws a NullPointerException
So i changed: if (byteArray == null || resultSet.wasNull())
But apart from that the encoding of the character is not correct. Characters like ,, are converted wrong.
If i use Object.toString it works. Charset is UTF-8
fred
Fred,
> the resultSet.getBytes() method returns null and resultSet.wasNull() throws a NullPointerException
...is strange for me, because AFAIK in case of SQL "NULL" value according do JDK 5.0 documentation
a) resultSet.getBytes() should return null
b) resultSet.wasNull() should return true
but resultSet.wasNull() should be sufficient. There is no problem to add into condition Your proposed code
if (byteArray == null || resultSet.wasNull())
and I am going to add it just now, because it should not cost any overtime due to short circuit operator and should avoid exception in case of MS Access driver.
> But apart from that the encoding of the character is not correct. Characters like ,, are converted wrong.
...I think, that , , are common west European characters used for example in German alphabet and there should not be any problem with leaving encoding void. But for alphabets such is my Czech (East Europe) one, reading data from one encoding, when they are in another, it always results in error, if they are not in any "Unicode".
You wrote, that these characters are converted wrong. Are You sure, that You are using second column from following table?
http://java.sun.com/j2se/1.5.0/docs/guide/intl/encoding.doc.html
It should work. I am also not sure, if MS Access MEMO field is binary or character nature. If it is character nature, I guess, taht it can be stored in Unicode like NVARCHAR. But I do not have MS Access now, so I can not try it.
Your feedback or feedback of anyone else about (not only encoding) is welcome. Thank You.
Stepan