Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Databases / October 2004

Tip: Looking for answers? Try searching our database.

Storing & in MySQL

Thread view: 
Jonck - 25 Oct 2004 16:20 GMT
Hi everybody,
I'm having a problem where the JDBC driver probably means well but is
not doing what I want.

I need to store data in a database which will at a later time be sent on
to a servlet in XML format. Some characters need to be given their
special XML format, for example if I want to transmit the ampersand (&)
sign, I need to pass along the code & instead of just &.
So what happens is my app parses user input, replaces all special signs
like & with their XML counterparts and then I try to store these in
MySQL. However, when I do the INSERT into MySQL, the & sign is
stored in MySQL as & which then causes me problems when I want to send
this data on to the servlet.

Therefore my question is, how do I get MySQL to store the &
character sequence without it being "intelligent" and changing it to the &
sign?

Thanks very much for your help,
Jonck
P.S. using MySQL 4.0.20-standard and the mysql-connector-java-3.0.14-
production
Gregory Toomey - 25 Oct 2004 19:28 GMT
> Hi everybody,
> I'm having a problem where the JDBC driver probably means well but is
[quoted text clipped - 18 lines]
> P.S. using MySQL 4.0.20-standard and the mysql-connector-java-3.0.14-
> production

What are you on about? Mysql stores '&' as '&' and '&' as '&amp&;' like
all other relational databases.

gtoomey
Jonck - 26 Oct 2004 02:34 GMT
> What are you on about? Mysql stores '&' as '&' and '&' as '&amp&;'
> like all other relational databases.
>
> gtoomey

Sorry, my wrong, the character sequence was being interpreted by an XML
parser and that was what was the cause of the & character (and other
such characters) to get translated to the & sign, it was indeed not the
database that was to blame here.

Thanks for putting me in the right, Jonck
_Mario_ - 26 Oct 2004 09:14 GMT
> Hi everybody,
> I'm having a problem where the JDBC driver probably means well but is
[quoted text clipped - 9 lines]
> stored in MySQL as & which then causes me problems when I want to send
> this data on to the servlet.

...what about doing an enchode URL or a Decode URL?

Mario


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.