I am a struggling rookie on jdbc and sql. I have a project in which i am trying to store filepaths to images located in a folder on
the following location K:\francine\src\resources\images\. I am using netbeans for this project. My question is how do i store data
with slashes in a mysql table column? I have tried it with the sql below but it's not working and i am clearly missing something
When i execute the above insert query in mysql with a command line tool all i see is underscore characters instead of
Further on i wan't to store filepaths selected from a JFileChooser in the table mediatype_tbl so i am curious about this problem
and i am very thankful for any kind of helpful reply or hint.
The backslash is the standard escape character in MySQL; I suggest you read 9.1.1 String Literals for complete information about how that works and how to deal with it.
However you referred to the \ character in your post variously as "slashes" and "forward slashes". The character \ is referred to as "backslash" by computer programmers and / is "forward slash". It helps if you make a clear distinction here.
And in your proposed Java code where you get a path from a JFileChooser, I believe you don't need to worry about this issue. Every JDBC driver is designed to understand how to deal with its variety of SQL and its features, such as escape characters. Using a PreparedStatement to run the INSERT statements you described would automatically take care of escaping things which need to be escaped.
Those are not "slash" characters. A slash, also known as a virgule, solidus or stroke faces the other direction, thus: /
The slash has a long and honorable history, having been used as punctuation and as a currency symbol in historical English coinage, where it indicated shillings.
The backslash appears to be a recent invention, not in common use until it was made part of the ASCII character set in 1961.
Pedantry aside, the backslash is a "magic" character, used as a graphical escape indicator. For example, "\n" is compiled into the non-printable "newline" character (ASCII and Unicode hex value 0x0A). To switch off its meaning, you have to double up like this: "\\", which compiles to a single backslash, and that is what you would have to do for your data.
You should be aware that Java supports a normalized filename convention, and will happily accept the alternative syntax of "K:/francine/src/resources/images/icon_bluray.jpg". This also works for Windows in some cases, although I haven't seen a simple rule that explains where. Note that this format does not compile into DOS/Windows format, though. It's exactly as coded, so apps that aren't written in Java may not accept them.
Beyond that, I would avoid storing too much of the path information in a database. If you later want to move the files to some other directory or make them visible from some other source, the full path might not work. So as a rule, keep the root parts of the patch separate from the sub-directory structure of the files themselves.
"privilege" comes from the Latin words for "private" and "law" (legal) and dates to feudal times. To "claim privilege" meant that you were above the laws that applied to the common people.
Do Re Mi Fa So La Tiny Ad
Devious Experiments for a Truly Passive Greenhouse!