stevieaj99
asked on
JDBC - ODBC getBinaryStream returns only 255 characters from MS Access Memo field
Hi,
I am trying to get a memo field value from MS Access using a getBinaryStream. At the moment it will only return 255 characters - no more than a standard getString.
The memo field value has 260 characters. Basically, the code returns the first 255 then returns -1.
I am using JDK1.3 with Jbuilder7. MS Access 2000 database format. The JDBC to ODBC driver. Windows XP Pro. Latest ODBC as per MS site.
The code is ...
try{
InputStream dbin = rs3.getBinaryStream("Detai ledAlertDe scription" );
for( int xread; ( xread = dbin.read() ) != -1; )
{
String C = String.valueOf(xread);
LogSession.OutputLog_Messa ge( C );
}
}catch(Exception e) {e.toString(); };
Help...
I am trying to get a memo field value from MS Access using a getBinaryStream. At the moment it will only return 255 characters - no more than a standard getString.
The memo field value has 260 characters. Basically, the code returns the first 255 then returns -1.
I am using JDK1.3 with Jbuilder7. MS Access 2000 database format. The JDBC to ODBC driver. Windows XP Pro. Latest ODBC as per MS site.
The code is ...
try{
InputStream dbin = rs3.getBinaryStream("Detai
for( int xread; ( xread = dbin.read() ) != -1; )
{
String C = String.valueOf(xread);
LogSession.OutputLog_Messa
}
}catch(Exception e) {e.toString(); };
Help...
ASKER
The real length of data I want to store in this memo field is > 4K. The Test data was set to 260 to prove it would not work. getString according to the JDBC spec will only return < 255 characters.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
OK - tried the code. Had to change getChracterStream line to
Reader in = rs3.getCharacterStream("De tailedAler tDescripti on");
And the same thing happens. Only 254 characters are returned from the memo field (this has 260).
?
Reader in = rs3.getCharacterStream("De
And the same thing happens. Only 254 characters are returned from the memo field (this has 260).
?
Are you *certain* that it's a memo field and not a normal string?
ASKER
I have just double checked. It is a memo field. It has 260 characters in the first record.
Just to humour me, please post
System.out.println(rs3.get MetaData() .getColumn TypeName(n );
(where 'n' is the 1-indexed index of "DetailedAlertDescription" )
System.out.println(rs3.get
(where 'n' is the 1-indexed index of "DetailedAlertDescription"
ASKER
OK.
This is the query for the result set.
QueryAlertDesc = "SELECT DISTINCT SITEALERTS.SiteID, SITEALERTS.AlertCode, SITEALERTS.AlertSubCode, ALERTS.AlertDescription, ALERTS.DetailedAlertDescri ption, SITEALERTS.LocalAlertDescr iption, SITEALERTS.DetailedLocalAl ertDescrip tion, ALERTS.PhraseNo FROM ALERTS INNER JOIN SITEALERTS ON (ALERTS.AlertSubCode = SITEALERTS.AlertSubCode) AND (ALERTS.AlertCode = SITEALERTS.AlertCode) WHERE (((SITEALERTS.AlertCode)=' " + AlertCode + "') AND ((SITEALERTS.AlertSubCode) ='" + AlertSubCode + "') AND ((SITEALERTS.SiteID)='" + SiteID + "'));";
The metadata values returned are ...
VARCHAR = SiteID
VARCHAR = AlertCode
VARCHAR = AlertSubCode
VARCHAR = AlertDescription
LONGCHAR = DetailedAlertDescription
VARCHAR = LocalAlertDescription
LONGCHAR = DetailedLocalAlertDescript ion
This is the query for the result set.
QueryAlertDesc = "SELECT DISTINCT SITEALERTS.SiteID, SITEALERTS.AlertCode, SITEALERTS.AlertSubCode, ALERTS.AlertDescription, ALERTS.DetailedAlertDescri
The metadata values returned are ...
VARCHAR = SiteID
VARCHAR = AlertCode
VARCHAR = AlertSubCode
VARCHAR = AlertDescription
LONGCHAR = DetailedAlertDescription
VARCHAR = LocalAlertDescription
LONGCHAR = DetailedLocalAlertDescript
I'lll have to think about this ..;-)
Try using getAsciiStream()
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
OK this is what I did.
Tried getAsciiStream first and it didn't work.
Simplified query and I was able to use a getString to get all the data.
I was also able to use the getAsciiStream, getCharacterStream and getBinaryStream!
Does any one know why?
Tried getAsciiStream first and it didn't work.
Simplified query and I was able to use a getString to get all the data.
I was also able to use the getAsciiStream, getCharacterStream and getBinaryStream!
Does any one know why?
The problems with Access by the sounds, and its not handling the query correctly.
Try slowly building up your query until you find what specificqalluy is causing the problem.
Try slowly building up your query until you find what specificqalluy is causing the problem.
Do you get any indications of anything amiss when you try this outside Java?
ASKER
I have broken this down into a complex query without DISTINCT and JOIN - still doesn't work.
I have removed DISTINCT and the JOIN on their own - still doesn't work.
In order words keep it simple stupid is the overall principle (thats aimed at me not you).
Tried this in access and its ok as a complex query - no surprise there.
Not tried it in VS 2003/2005 under VB.NET or C#.Net. Next step would be a proper JDBC type 3 driver as the app is growing by the day and its time I upgraded - just need to find a good one in the next week or so.
I have removed DISTINCT and the JOIN on their own - still doesn't work.
In order words keep it simple stupid is the overall principle (thats aimed at me not you).
Tried this in access and its ok as a complex query - no surprise there.
Not tried it in VS 2003/2005 under VB.NET or C#.Net. Next step would be a proper JDBC type 3 driver as the app is growing by the day and its time I upgraded - just need to find a good one in the next week or so.
>>. Next step would be a proper JDBC type 3 driver
That would be interesting
That would be interesting
Or use a decent db :)
using a type 3 driver would very likely fix the problem, but there aren't many around for access.
ASKER
Yep...been putting off upgrading to SQL and a good JDBC but I need to face the facts.
8-)
Glad I could help you find the cause of your problem :)
Let me know if you need any further help.
Let me know if you need any further help.
?