Storing & in MySQL

This is a discussion on Storing & in MySQL within the JDBC JAVA forums in Framework and Interface Programming category; 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 ...

Go Back   Application Development Forum > Framework and Interface Programming > JDBC JAVA

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 10-25-2004, 11:21 AM
Jonck
Guest
 
Default Storing & in MySQL

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
Reply With Quote
  #2  
Old 10-25-2004, 02:29 PM
Gregory Toomey
Guest
 
Default Re: Storing & in MySQL

Jonck wrote:

> 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


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

gtoomey
Reply With Quote
  #3  
Old 10-25-2004, 09:34 PM
Jonck
Guest
 
Default Re: Storing & in MySQL

> 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
Reply With Quote
  #4  
Old 10-26-2004, 04:15 AM
_Mario_
Guest
 
Default Re: Storing & in MySQL


"Jonck" <jonck@vanderkogel.net> wrote in message
news:20041025172047789+0200@news.text.chello.nl...
> 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 &amp; 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 &amp; sign is
> 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


Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 07:51 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.