HOW CAN I READ MEMO FIELDS WITH JDBC-ODBC ?
hi all,
with getString("...") one can read text fields from an table.
with getInt("...") one can read fields with numbers from an table
....so far so good but:
HOW CAN I READ MEMO FIELDS WITH JDBC-ODBC ?
i have an access db with a text field which contents more than 255 characters ==> access reformates this to a memo field.
any help will be appreciated.
thanx,
andi
[432 byte] By [
BCBCBC] at [2007-9-27 14:55:14]

I don't believe you can read a memo field with the JDBC-ODBC bridge, at least I never found a way. There may be third party drivers for Access that allow it, but I never found a third party driver for access. Sorry...
....hmmmm, i thought i tried this.....but ok, i'll do it again!thanx a lot for your response,andi
You can try to use getAsciiStream or getBinaryStream.
byte[] buffer = new byte[4096];
int size;
StringBuffer buf = new StringBuffer();
InputStream strin =rs.getAsciiStream(i); //The memo field
if(strin != null){
for(;;){
size = strin.read(buffer);
if(size <= 0){
break;
}
buf.append(new String
(buffer,0,size));
}
System.out.println(buf);
> You can try to use getAsciiStream or getBinaryStream.
> >byte[] buffer = new byte[4096];
>int size;
>StringBuffer buf = new StringBuffer();
> InputStream strin =rs.getAsciiStream(i); //The
> //The memo field
>if(strin != null){
>for(;;){
>size = strin.read(buffer);
>if(size <= 0){
>break;
>}
>buf.append(new String
>(buffer,0,size));
>}
>System.out.println(buf);
>
I have a question about your code.
Can you explain me why the size of "byte[] buffer" shoud be 4096?
Hi All,
Yes, you can read MEMO using JDBC-ODBC Bridge.
No, getObject(..) and casting them to String wo'nt work for Memo.
You need to treat MEMO as an InputStream and has to retrieve the data as follows :
--
String temp = "";
try
{
if(is != null)
{
InputStreamReader isr = new InputStreamReader(rs.getAsciiStream(i));
int c = 0;
while(c != -1)
{
c = isr.read();
if(c != -1)
temp += (char)c;
}
}
else
temp = null;
}
catch(IOException e)
{
throw new SQLException("Custom SQLException : Unable to open stream for MEMO field because " + e.toString());
}
return temp;
--
I hope this will help u guys.
regards,
Humayun