import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class BaseDao {
// 增删改方法
public static int commonUpdate(String sql, Object... objs) {
// 获得连接
Connection connection = DbUtils.getConnection();
int n = 0;

try {
// 获得执行者
PreparedStatement preparedStatement = connection.prepareStatement(sql);
// 填入参数
for (int i = 0; i < objs.length; i++) {
Object obj = objs[i];
preparedStatement.setObject(i + 1, obj);
}
// 执行语句
n = preparedStatement.executeUpdate();
} catch (SQLException throwables) {
throwables.printStackTrace();
}
return n;
}
}