Using Prepared Statements to set Table Name

后端 未结 7 1824
生来不讨喜
生来不讨喜 2020-11-22 11:57

I\'m trying to use prepared statements to set a table name to select data from, but I keep getting an error when I execute the query.

The error and sample code is di

7条回答
  •  隐瞒了意图╮
    2020-11-22 12:23

    String table="pass"; 
    
    String st="select * from " + table + " ";
    
    PreparedStatement ps=con.prepareStatement(st);
    
    ResultSet rs = ps.executeQuery();
    

提交回复
热议问题