Using java.sql.Preparedstatement
implies the escaping of characters will be done while parsing the queries, this does happen also when I have single quotes in my data but when I have single quotes in my table name itself the query does not work (I am using Oracle 11g).
Here's my code:
Class.forName("oracle.jdbc.OracleDriver");
con = DriverManager.getConnection(
"jdbc:oracle:thin:client/adept@ind-db-02:1521:ind02");
PreparedStatement preparedStatement = con.prepareStatement(
"SELECT * FROM (?) where rownum=1");
preparedStatement.setString(1,"CLIENT."SR'tab"");
ResultSet rs3=preparedStatement.executeQuery();
Is there any way of escaping single quotes from the table name using a prepared statement?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…