This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC and the fly likes How i store enter key and space in MySql database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "How i store enter key and space in MySql database" Watch "How i store enter key and space in MySql database" New topic
Author

How i store enter key and space in MySql database

Vinod suryawanshi
Ranch Hand

Joined: Aug 08, 2012
Posts: 50
Hi friends,
I am taking values from user in textfield of jsp, user enter values with spaces and enter keys (in particular format). I want to save that values as it is in table.

I created table advertise, having column adid-INT and adcontent-TEXT,
user enter data in adcontent field from GUI(which is in jsp) following format.

" We have openings... for
-Developer
-Marketing
-Accounts"
latter i store this values in table column adcontent.

But when i retrieve values table and display them, it will look like,
" We have openings... for -Developer -Marketing -Accounts"
In one row.

so its possible to store and retrieve above statement as it is enter by user in mysql database tables.
harshvardhan ojha
Ranch Hand

Joined: Jul 26, 2007
Posts: 157
    
    1

Hi Vinod, you can save \n in mysql db for every enter pressed, similarly you can keep other signs which which give you back the same indentation in java after retrieval.
Vinod suryawanshi
Ranch Hand

Joined: Aug 08, 2012
Posts: 50
Thanks for your replay harshvardhan ojha,
but i am not entering value in database, user enter value in form(which is part of GUI). which i want to save into database as it is. from your answer i got one clue, that if i take value from user and add necessary '\n' and ' ' according to user enter values & Then i enter them into database. May be this will work, i have to check.
But still if you have any other easy solution then please reply....
And one more time, thankss
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

When you say you "display" those things, you mean you display them in HTML, right?

And perhaps you didn't remember that HTML normally converts blocks of white-space to a single space character? So for example a series of three space characters would be displayed as just one space, and a new-line character (what you called "enter key") is also displayed as just one space.

In other words your problem has nothing to do with the database and everything to do with how HTML works.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How i store enter key and space in MySql database
 
Similar Threads
Store char[] as column type
mysql enum to java string
mysql enum to java string
Retrieve binary file from database and send to user via web browser
retrieve blob data from mysql using jsp