Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

MySqlText to String conversion

 
kranthi devarapalem
Greenhorn
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());
engArticle.setNewsDescription(descString);

Thanks a lot in advance.


Regards
Kranthi.
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • 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



and



Or better yet



The first example will not render as you expect in HTML. The second 2 examples will.
 
kranthi devarapalem
Greenhorn
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic