try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection c = DriverManager.getConnection("jdbc:odbc:ClothingSale","sa","");
         Statement s = c.createStatement();
c.close();
s.execute("RESTORE FILELISTONLY FROM DISK = 'D:\\ClothingSale.bak'");
s.execute("RESTORE DATABASE ClothingSale FROM DISK = 'D:\\ClothingSale.bak'"
          +"WITH MOVE 'ClothingSale' TO 'D:\\ClothingSale_Data.mdf',MOVE 'ClothingSale_log' TO 'D:\\ClothingSale.ldf'");
JOptionPane.showMessageDialog(null,"恢复成功");

s.close();
}
catch(Exception ex){
System.out.println(ex.getMessage());
}为什么出现Invalid handle错误?   SQL语句应该怎样写??

解决方案 »

  1.   

        c.close();
    放在
           s.close();
    后面。
    如果还不行,说明你的
      s.execute("RESTORE FILELISTONLY FROM DISK = 'D:\\ClothingSale.bak'");
    里面的语句是command命令,不能使用类似sql一样的语句来执行,应该用Runtime的exec来执行
      

  2.   

    不能放在后面  放在后面就会出现什么排它访问权的错误~~用RUNTIME怎么写?
      

  3.   

    Runtime调用command命令,网上一大堆
      

  4.   

    我用的是SQL2000  求救各位大侠啊!!!
    把s.execute("RESTORE FILELISTONLY FROM DISK = 'D:\\ClothingSale.bak'");这句去掉了也不行