使用Java在mysql中使用\\插入文件的路径 [英] Insert Path of a file with \\ in mysql using java
问题描述
我正在使用Java创建一个独立的应用程序,因此我需要插入用户从文件选择器中选择的图像的路径.
我正在获取文件的路径,但是当我将其存储在数据库(mysql)中时,它不存储\
,因此当我检索该路径时,文件不会显示.
I am making a standalone application using java,and in that i need to insert the path of the image that user chooses from file chooser.
I am getting the path of the file but when i store it in the database(mysql) it doesn't stores the \
,so when i retrieve that path,the file doesn't show up.
如何使用\\
存储文件的路径,以便使用Java代码进行转义?
How to store the path of file with \\
so that one gets escaped using java code?
我尝试使用replaceall方法,但给出了非法字符集错误.
i tried using replaceall method but its giving an error of illegal character set.
filename.replaceall("\","\\");
但这没有解决.
推荐答案
Use Prepared statement to store path containing \
.PreparedStatement
doesn't escape anything
这篇关于使用Java在mysql中使用\\插入文件的路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!