Re: Inserting a backslash
From: Chris (chris2k01_at_hotmail.com)
Date: 07/21/04
- Next message: alexjcasol: "Re: update a date on a MySQL table"
- Previous message: Joe Ray: "Inserting a backslash"
- In reply to: Joe Ray: "Inserting a backslash"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 21 Jul 2004 21:34:02 GMT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Joe Ray wrote:
> I am trying to insert string data into my MySQL database. Some of
> the string data has a backslash as a character. I tried to make a
> simple insert of a backslash into the database using the following
> statement in java. Notice that i used two backslashes.
>
> stmt.executeUpdate("INSERT INTO DICTIONARY VALUES('\\')");
>
> However the database did not accept that I received an SQL
> exception. I am stumped. Any suggestions? Thanx in advance
>
> Joe
Hi,
You want four backslashes, not two. Here's why:
You type: \\\\
1. Java uses \ as an escape character. You need \\ to write a \ in the
actual class file when it's compiled.
MySQL sees: \\
2. MySQL uses \ as an escape character. You need \\ for MySQL to
interpret it as \. Otherwise, you're escaping the quote, which is
definitely not what you want.
Into the database goes: \
Chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
iD8DBQFA/uF0nwjA8LryK2IRAgVYAKDuSW9Z5Pwjhu4MxCmivhFSyFlTLQCg8wsx
8Fx6m4aCaV3tByzeaQSQYrQ=
=7wrn
-----END PGP SIGNATURE-----
- Next message: alexjcasol: "Re: update a date on a MySQL table"
- Previous message: Joe Ray: "Inserting a backslash"
- In reply to: Joe Ray: "Inserting a backslash"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|