File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Servlet-JDBC with Access databse Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Servlet-JDBC with Access databse" Watch "Servlet-JDBC with Access databse" New topic
Author

Servlet-JDBC with Access databse

Rajpal Kandhari
Ranch Hand

Joined: Aug 26, 2000
Posts: 126
Hello Friends,
I am working on a form and using servlet to submit data into database. I am using simple JDBC-ODBC bridge and using MS-Access as databse. In my table their is one column with field type "memo" which can hold upto 65,535 chractes. When from my form i am inserting values in this column it is only accepting a string of lenght 256 char and not more. Why is it behaving in such way?
Can any one help me in this. I have posted this query here because lot of user in this forum must be using Servlet-JDBC and i think i will get my answer here.
Am i right?
thanks,
regards,
Raj.


Regards,<P>Raj.<BR>-------------------------<BR>Afforts should be Appriciated.<BR>-------------------------
imran rafi
Greenhorn

Joined: Oct 21, 2000
Posts: 14
i guess u might be using GET method in your form. check for it, n if yes change it to POST. am i rite folks?
Rajpal Kandhari
Ranch Hand

Joined: Aug 26, 2000
Posts: 126
Hello,
No the pb is not with the type of method i have choosen. I am using doPost method. I am getting error when it is inserting data in the database. It is inserting data correctly for all other type of column fields. that is text, number, date/time, autonumber. Only for memo field it is only accepting upto 256 characters and nothing more than that.
It gives me following erroe
java.sql.SQLException String Data, right Truncated (null).
It is a MS-ODBC error.

How to sole it. Any one pls help me?
Regards,
Raj.
Monty Ireland
Ranch Hand

Joined: Oct 03, 2000
Posts: 161
My guess would be that this has nothing to do with servlets...
It has alot to do with your jdbc driver...
Walk thru the following and you might find your problem...
#1 what are the java data types you are using...
#2 what are the sql data types you are using...
#3 what are the db engine datatypes you are using...
My guess is that the jdbc driver being invoked is translating you memo field into a text field... my ms-acces is rusty so bear with me.
Test you code outside of the servlet....
If it works as you expect... Check you CLASSPATH. You are invoking a different jdbc driver....
Otherwise you have just found a limitation of your database driver!
Good-luck you a blazing a trail i will be following next week.

------------------
We learn more from our mistake's than from our success's.
a.k.a. monty6


Multi Platform Database Developer & DBA on E.S.T.
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
Memo fields are wierd in Access. They cause all sorts of problems with the JDBC-ODBC driver unless you use the stream method of accessing them.
To read from a Memo field, use
InputStream in = resultset.getAsciiStream(int column)
or
InputStream in = resultset.getAsciiStream(String colname)
I have never had to write to a memo field, but I assume the process is similar.

Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
I've also moved this to the JDBC forum, where it would be more appropriate.
Rajpal Kandhari
Ranch Hand

Joined: Aug 26, 2000
Posts: 126
Hello Thomas,
Could you pls help me with the above pb. I tried the way suggested by Frank but i could not get the things right....

Could you pls spare some time on this pb and suggest me you're ideas....

Regards,
Raj.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Servlet-JDBC with Access databse
 
Similar Threads
how to use jdbc to connect to MSaccess.?
Servlet-JDBC with Access databse
inserting data of two forms into two tables with same transaction id
retrieving column caption in access
MSACCESS Connection