我也想过设置一个成功标志TABLEXIST,如果表存在,则TABLEXITST=1;不存在则TABLEXIST=0,但是好像JSP里面的变量不能和SQL的变量通用,比如我在JSP里定义TABLEXIST=0,就无法在SQL语句里对TABLEXIST进行操作stm3.executeQuery("if exists (select * from sysobjects where name ='"+T2001+"'"+ TABLEXIST+"='1'");
调试欢乐多
//判断表是否存在
int table = 0;
ResultSet rt=stm3.executeQuery("select * from sysobjects where name ='"+T2001+"'");
if(history_trace_rt.next())
{
table = 1;
}
如果TABLE=1,则进行以下的查询,否则就不操作。我最开始是被IF EXISTS给误导了,后来才想到直接使用select * from sysobjects where name ='T2001'也会返回一个结果集。