aspose file tools*
The moose likes JDBC and the fly likes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark ""Comma is Missing"" Watch ""Comma is Missing"" New topic
Author

"Comma is Missing"

Gangadhara Thippaiah
Greenhorn

Joined: Sep 16, 2000
Posts: 7
Hi,
I have created a table with varchar2(30) as a column in database.
When I tried to send a value which is containing ' in it, I am
getting an error message "comma is missing". I think it is because
after ' it is considering as end of the value & expects a comma
after it.
For example, in database table I have so many columns with address
column one of them. I want to store address from frontend as
"55, 5th lane, next to Gandhi's statue, Washington", SQL ends the
value at ....gandhi & expects a comma after '.
How to overcome this problem?
Any other details required?
Gangadhara
Chris Klu
Greenhorn

Joined: Jan 03, 2001
Posts: 18
Please post the SQL statement you are using.
Ipsita Naravane
Greenhorn

Joined: Dec 27, 2000
Posts: 29
Gangadhar, to be able to insert single quote as a part of you text, the quote must be preceded with a quote so
to insert
"55, 5th lane, next to Gandhi's statue, Washington" in your database,
try entering :
"55, 5th lane, next to Gandhi''s statue, Washington",
Shilpa
Gangadhara Thippaiah
Greenhorn

Joined: Sep 16, 2000
Posts: 7
Shilpa, If I develop a website & user may use ' because he don't know the proble.
Then this will be a bug.
Gangadhara
Peter Tran
Bartender

Joined: Jan 02, 2001
Posts: 783
Gangadhara,
That's why company's pay you the big buckaroos...As an application programmer, you need to anticipate these things and code your GUI accordingly. Don't assume smart users, rather think that you're a smart programmer. Code your text box to capture the ' and insert that into your SQL statement when you generate it.
-Peter
Ipsita Naravane
Greenhorn

Joined: Dec 27, 2000
Posts: 29
Peter,
my sentiments exactly:-)
Gangadhara Thippaiah
Greenhorn

Joined: Sep 16, 2000
Posts: 7
Chris,
I am using
insert into nam values('raju','55, 5th lane, next to Gandhi's
statue, Washington');
ERROR at SQL Plus:
ORA-01756: quoted string not properly terminated
ERROR at javawebserver:
ora-00917: missing comma
Table Description(table name:nam):
Name Null? Type
------------------------------- -------- ----
NAME VARCHAR2(20)
ADDRESS VARCHAR2(100)
I think this is sufficient. Please help.
Gangadhara

Chris Klu
Greenhorn

Joined: Jan 03, 2001
Posts: 18
Gangadhara,
Here's a solution. It's not very elegant. Java needs some regex. You reminded me I need to fix my code. I didn't antipate someone using a comma.

[This message has been edited by Chris Klu (edited January 10, 2001).]
I just realized that the method should be called apostropheReplace(). Oops.

[This message has been edited by Chris Klu (edited January 10, 2001).]
Gangadhara Thippaiah
Greenhorn

Joined: Sep 16, 2000
Posts: 7
Thanks to Chris, Peter & Shilpa. Stuff by Chris is really fantastic.
Gangadhara
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: "Comma is Missing"