Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlet-JDBC with Access databse

 
Rajpal Kandhari
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
imran rafi
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 161
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've also moved this to the JDBC forum, where it would be more appropriate.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic