需要用到动态SQL语句,具体得看你用哪个数据库了

解决方案 »

  1.   

    sql="select * from "+ x + ""
      

  2.   

    String sql="select * from "+x+"";
      

  3.   

    而且变量也不是这么写的吧,sql="select * from "+X;才符合JAVA语法呀
      

  4.   

    sql="select * from "+ x + ""
      

  5.   

    都试了还是不行啊
    部分代码如下:
    con = DriverManager.getConnection("jdbc:oracle:thin:@192.168.1.168:1521:horac","scott","tiger");
    stmt = con.createStatement();
    String strSql="drop table "+tableName+""; //换成 String strSql="drop table "+ tableName;也是一样
    r = stmt.executeQuery(strSql);
    System.out.println("Table dropped");出现以下错误提示:
    simplesqlserver.java:85: variable tableName might not have been initialized
      

  6.   

    提示的错误是说:tableName没有初始化,你没有给tableName赋值,当然会报错了
      

  7.   

    同意楼上
    variable tableName might not have been initialized
    变量 tableName 
    没有初始化~~
      

  8.   

    同意 baffling(迷茫困惑中)的观点。
    我认为搂主是个高手,居然用ue编写java,
    连个ide也不用。如果用ec或者jb的话可能就不会出现这种问题了。