Java Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Try It Free
Go Back   Dev Shed ForumsProgramming LanguagesJava Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
1200+ fellow developers rate and compare features of the top IDEs, like Visual Studio, Eclipse, RAD, Delphi and others, across 13 categories. Enjoy this FREE Download of the IDE User Satisfaction Study by Evans Data Corporation. Download Now!
  #1  
Old August 21st, 2002, 01:30 PM
socrates73 socrates73 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2002
Posts: 0 socrates73 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
extracting and displaying text from a database

Hello, I was curious if there is a certain method for extracting information of type Text from a database? The problem that I am having is that when I retrieve the data none of the newlines are being printed... For example, if I insert the following text into the database:

The First Line
The Second Line


What gets outputed is:
The First Line The Second Line


Anyone know how to fix this?

Reply With Quote
  #2  
Old August 23rd, 2002, 03:56 PM
tron's Avatar
tron tron is offline
SwollenMember
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2000
Location: the master control
Posts: 234 tron User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 44 m 46 sec
Reputation Power: 9
maybe use a newline char (\n)?

Reply With Quote
  #3  
Old August 23rd, 2002, 10:52 PM
bricker42 bricker42 is offline
Moderator =(8^(|)
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Feb 2002
Location: Sacramento, CA
Posts: 1,710 bricker42 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 38 sec
Reputation Power: 8
Send a message via AIM to bricker42
This sounds like an html issue. Newlines don't display in your browser, you have to replace them with <br>. Try something like:

dboutput = Pattern.compile( "/\n/" ).matcher( dboutput ).replaceAll( "<br>\n" ).toString();

Reply With Quote
  #4  
Old August 24th, 2002, 04:04 PM
CharlesBell CharlesBell is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Location: Vicksburg, MS
Posts: 7 CharlesBell User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
In java, the result from a jdbc sql query is a result set which is read and processed something in a program like the one at:
http://www.quantumhyperspace.com/So...ExecuteSQL.java

(The source code was too long to post here)

The following example illustrates adding a new line character to each line read from a Buffered Reader which might work in your problem :

/* Example.java
*/
import java.io.*;

public class Example{

public static void main(String[] args){
Example example = new Example();
example.test();
}

public void test(){
String someString = "la la la la la la la\rla la la la la la la\rla la la la la la la\r";
String string = processLongString(someString);
System.out.println(string);
}

public String processLongString(String s){
String processedText = "";
try{
StringReader sr = new StringReader(s);
BufferedReader br = new BufferedReader(sr);
String nextLine = "";
while ((nextLine = br.readLine()) != null){
processedText = processedText + nextLine + "\n";
}
}catch(IOException ioe){
System.err.println("IOException: " + ioe.getMessage());
}
return processedText;
}
}

Reply With Quote
  #5  
Old August 26th, 2002, 09:56 AM
tron's Avatar
tron tron is offline
SwollenMember
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2000
Location: the master control
Posts: 234 tron User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 44 m 46 sec
Reputation Power: 9
Quote:
This sounds like an html issue. Newlines don't display in your browser, you have to replace them with <br>.


funny...i never saw any hint of html in the post...yet your point about "<br>" is correct.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > extracting and displaying text from a database


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway