Oguz Baktir wrote:

> Have a nice day!
>
> I have 2 problems. I thin some of you may have already faced with these, if
> so I need your help. Here they are:
>
> I have a form from which I want to send text data to a database via a
> servlet. The problem is: When there is single quote or double quote
> somewhere in the to-be-input text, I get a JDBC,... error. I understand that
> JDBC confuses with these quotes? How can I overcome this problem?
>

Most databases have some sort of an escape syntax that lets you embed single
quotes.  The problem is that they are not consistent in how they deal with it.

To get around this in a DB-independent way, use a PreparedStatement instead:

    Connection conn = ...
    String name = "My name's got a single quote in it";
    double value = 3.14159;
    PreparedStatement stmt = conn.prepareStatement("insert into my_table
(my_name, my_value) values (?, ?)");
    stmt.setString(1, name);
    stmt.setDouble(2, value);
    stmt.executeUpdate();

This makes the JDBC driver take care of the embedded single quote, which it
will do in whatever manner is appropriate for the database you are running on.

>
> Second, as using MsAccess I observed that I could a max of 256 characters
> into a text type field? What should I do to increase this limit? Is there
> another way to store text data in a database? Which type should I use?
>

I'm not a heavy duty Access user, but I imagine there is some sort of Memo
field that can hold more characters than 256.

>
> Have a nice work,
>  I am looking for the answers of these questions, and  some others also...
> My senior project deadline is May 10. I need urgent help. Thanks for
> everything.
> Regards,
> Oguz
>

Craig McClanahan

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to