简体   繁体   中英

How to Select From Mysql table With Escapable Characters

i am trying to select tables from my mysql database , and the tables names may be any thing unsafe, since users choose them, i have tried to do it like this :

String table = "*jjs> o";
PreparedStatement stmt = conn.PrepareStatement("SELECT * FROM ? ");
stmt.setString(1,table);
stmt.executeQuery();

but seems it to throw exception due to unacceptable command, can some one help me how can i achieve that please? thanks

在表名中添加反勾号(`)

select * from `*jjs> o`

可以使用BackTicks很好,就像没有声明的select * from `*jjs> o`一样。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM