This week's book giveaway is in the Open Source Projects forum.
We're giving away four copies of Spark in Action and have Jean-Georges Perrin on-line!
See this thread for details.
Win a copy of Spark in Action this week in the Open Source Projects forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

MySqlText to String conversion

Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all

I came across a requirement where i have to store paragraphs of data (not huge maximum of 5 paragraphs) in database, i have kept the column as TEXT. while insertion every thing is going fine it is storing as paragraphs(saw that in database). but while retrieving it is trimming all the spaces between the paragraph's and giving it as a single string. i read somewhere that we have to get the text as CLOB i tried that but it is also not working. below is the code.

Clob descClob = rs.getClob(2);
String descString = descClob.getSubString(1, (int)descClob.length());

Thanks a lot in advance.

Ranch Hand
Posts: 15304
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What character is being used to distinguish a paragraph? Also, where are you seeing it with the "paragraphs" removed? As a hint to move you in the right direction, possibly...

If you're storing the text in the database with a new line character and then trying to display that text on a web page, HTML doesn't know anything about new line characters unless they are in HTML format. The difference between


Or better yet

The first example will not render as you expect in HTML. The second 2 examples will.
kranthi devarapalem
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Great! its Working !. Sorry for not giving the exact information but you have guessed what i need. Thanks A Lot.
The fastest and most reliable components of any system are those that are not there. Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic