import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
public class ExecuteBathDemo01 {
/**
* @param args
*/
public static final String DBDRIVER="org.gjt.mm.mysql.Driver";
public static final String DBURL="jdbc:mysql://localhost:3306/gongxifacai";
public static final String DBUSER="root";
public static final String DBCODE="wqvckwhi";
public static void main(String[] args) throws Exception{
// TODO Auto-generated method stub
Connection conn=null;
PreparedStatement ps=null;
InputData input=new InputData();
String sql="DELETE FROM gongximyteble WHERE id=?";
Class.forName(DBDRIVER);
conn=DriverManager.getConnection(DBURL,DBUSER,DBCODE);
ps=conn.prepareStatement(sql);
for(int i=0;i<3;i++){
ps.setInt(1,i+3);
ps.addBatch();
}
ps.executeBatch();
ps.close();
conn.close();
}
}
运行时提示错误
Exception in thread "main" java.sql.BatchUpdateException: Table 'gongxifacai.gongximyteble' doesn't exist
at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:1103)
at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:853)
at ExecuteBathDemo01.main(ExecuteBathDemo01.java:34)
不知道什么问题啊~~批处理添加没问题~为什么删除就不行哪~~求解~~~~~~~
------解决方案--------------------
表不存在