Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PreparedStatement

Status
Not open for further replies.

Khanjan

Programmer
Feb 24, 2004
41
0
0
NL
Is it possible to get data from database with PreparedStatement instead of inserting?

My probleem is when i store an aricle into the database with some "layout"( like free space between two paragraphs), by retrieving it, the "layout" is gone. The two paragraph is attached to each other withoud any free space between them

How can i solve this?

thanx in advance
 
How do you display the content from database? via a web page? If so, the "layout" is considered as HTML, any line feed will be ignored, thus appending the paragraphs together.

solution would be

1. content itself are layouted in HTML, if they are only show via a web page.

or

2. before they are display, you have to have some kind of logic to transform your layout into HTML. e.g. changing line feed into a <br /> tag, etc...
 
Code:
PreparedStatement pstmt = con.prepareStatement("select * from some_table where some_field = ?");
pstmt.setString(1, "some_constraint");
ResultSet rs = pstmt.executeQuery();
while (rs.next()) {
 ...
}
 
I thought that PreparedStatement would help to solve my probleem, but it didnt.

I have a content management systeem(CMS) where i can put my text in a textarea. In mysql the "layout" is preserved.

But when i retriev the text and show it in my website the layout is gone.

I can not set <br> or <p> tags in my text, because it is a content management Systeem.
 
You really need to give an example of your problem - just saying that the *layout* is not right tells us nothing ...

What is your precise problem ? Your post title says you wanted to know about PreparedStatement but from what you say now, this sounds like it is not the problem ... what is the real problem ? Examples would you help (please only post relevant code, nobody here wants to look through 500 lines of irrelevant code) ...
 
<rant>

Also (pet gripe) is that you have posted lots of questions, which is fine (that is why we are here, to help others) but its annoying that when something is not working, you post back saying why, but if our solutions/replies do work, we never know because you never seem to reply saying that our answers have helped you.

This is annoying for two reasons, firstly, we feel that our help has been of no use, but more importantly, other people searching tek-tips for help may not know if a particular suggestion worked for a particular problem- so it does not help other people (which is why we are here). At the end of the day, we are not getting paid to help you, and it feels like an insult when someone posts lots of questions and never acknowledges help.

</rant>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top