aspose file tools*
The moose likes JDBC and the fly likes How Can I add a data in my backend that contains a single quote? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "How Can I add a data in my backend that contains a single quote?" Watch "How Can I add a data in my backend that contains a single quote?" New topic
Author

How Can I add a data in my backend that contains a single quote?

Sanjay Bahrani
Ranch Hand

Joined: Apr 17, 2001
Posts: 38
Hi Guys,
How Can I add a data in my backend that contains a single quote, cauze single quotes signifies the end of a string data in sql query.
for eg.
I want to insert the data "How're you" how can i do this.
I have tried with PreparedStatement but it doesn't work for me. If you know something about this plz post the reply....
Thankz...
Raajesh Chandran
Ranch Hand

Joined: May 04, 2001
Posts: 103
Hi!!
If U use Oracle try like this
insert into trial values('how''re u');
Like this put douuble single Quotes in where u need a single quotes within a string.Like this try in prepared stat.If not get it let me know.
Sorry i don't know SQLSERVER
BestWishes,
chandran

chandran..
prabhat kumar
Ranch Hand

Joined: Apr 11, 2001
Posts: 114
if u r using 'Statement' to execute ur queries then it wont insert ur queries...if it containd special characters..
for that u will need to use ..
PreparedStatement class and use the various set methods in this class ..
hope it will solve ur problem..
Sanjay Bahrani
Ranch Hand

Joined: Apr 17, 2001
Posts: 38
Hi Guys,
Thankz for replying me.....
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How Can I add a data in my backend that contains a single quote?