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]
# 1
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...
deriderj at 2007-7-5 22:55:24 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 2
Yoou can use resultSet.getObject(...) and cast it to a String
plucien at 2007-7-5 22:55:24 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 3
....hmmmm, i thought i tried this.....but ok, i'll do it again!thanx a lot for your response,andi
BCBCBC at 2007-7-5 22:55:24 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 4
Thanks for the information, I am definetly going to try this! Joel
deriderj at 2007-7-5 22:55:24 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 5

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);

pedro.garcia at 2007-7-5 22:55:24 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 6

> 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?

zeon77 at 2007-7-5 22:55:24 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 7

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

smhumayun at 2007-7-5 22:55:24 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 8
I tried this approach on my application and it still only pulls in a limited amount of data. I am using a Lotus Notes JDBC driver that simulates a JDBC-ODBC bridge. Is the limitation in the driver or is there something that I can do?
cflor at 2007-7-5 22:55:24 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 9
what is a memo field?
srimca at 2007-7-5 22:55:24 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...