aspose file tools*
The moose likes JDBC and the fly likes How to get RSSItem/any String with a Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "How to get RSSItem/any String with a " or Watch "How to get RSSItem/any String with a " or New topic
Author

How to get RSSItem/any String with a " or ' charchter into DB?

Itay Cohen
Greenhorn

Joined: May 27, 2012
Posts: 2
Dear All,
I am trying to write an application that will write RSS Items into a (Postgre SQL) DB.
However, while I succeeded in getting a list of sources from one table, and reading all their Items - (displaying them on screen)
I failed to write them into a table. I am trying now to enter just 2 rows. Yet I get this message

org.postgresql.util.PSQLException: ERROR: unterminated quoted string at or near "')"
Position: 87

I tried to deal with the ` char. At one point I have succeeded, yet I had problem with any " char at my Item strings (at title, exc.)

So I also have no idea how to change the " char. While changing the ' char is by using " ' " I cannot write 3*", can I??

(I CANNOT WRITE ri.getRss_title().replaceAll("'",""" ===that is 3*").



***********************************************************************************
P.s My method for writing the Item to a List is this:




Thank you very very much!
Martin Vajsar
Sheriff

Joined: Aug 22, 2010
Posts: 3436
    
  47

Welcome to the Ranch!

You need to use a PreparedStatement. This way you don't have to escape the string being processed in any way. We have a page on it here, and you might want to read the relevant parts of JDBC Tutorial too (or even better, the whole tutorial).

Also, next time please use the code tags when posting a code, it will make it much more readable. I've added them to your post myself this time.
Itay Cohen
Greenhorn

Joined: May 27, 2012
Posts: 2
Thank you SO much! You're wonderful.
Also - sorry I did not use the right tools (code tags). I'm new here..
Hope to contribute to this community.

Martin Vajsar
Sheriff

Joined: Aug 22, 2010
Posts: 3436
    
  47

You're welcome
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to get RSSItem/any String with a " or ' charchter into DB?
 
Similar Threads
How to define a DTD in java
how to display database values in a table
parse content:encode
Quick Search Results page cant put multiple results into a table
I want to change the app code value 10.