aspose file tools*
The moose likes Servlets and the fly likes MySqlText to String conversion Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "MySqlText to String conversion" Watch "MySqlText to String conversion" New topic
Author

MySqlText to String conversion

kranthi devarapalem
Greenhorn

Joined: Sep 10, 2012
Posts: 14
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

Joined: Jul 11, 2001
Posts: 15299
    
    6

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.

GenRocket - Experts at Building Test Data
kranthi devarapalem
Greenhorn

Joined: Sep 10, 2012
Posts: 14
Great! its Working !. Sorry for not giving the exact information but you have guessed what i need. Thanks A Lot.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: MySqlText to String conversion