需要一个动态从oracle数据库读取sql,sql放在xml文件中,现在生成图片的已经实现了,怎么才能定时启动这个,把图片的读取的是这个时间的5天前的数据
public class ImageGeneratorUtil{
private final static Logger log = Logger.getLogger(ImageGeneratorUtil.class);
private static final long serialVersionUID = -3938318741402322164L;
private static BufferedImage image;
public static BufferedImage genaralImage(String columnamessql, String columsql) {
try {
String columnNames[] =ImageDataUtil.dataColumnames(columnamessql);
String[][] rowData =ImageDataUtil.dataColum(columsql);
DefaultTableModel model = new DefaultTableModel(rowData, columnNames) {
public boolean isCellEditable(int row, int column) {
return false;
}
};
DefaultTableCellRenderer tcr = new DefaultTableCellRenderer() {
public Component getTableCellRendererComponent(JTable table,
Object value, boolean isSelected, boolean hasFocus,
int row, int column) {
if(row == 2 || row == 8)
{
setBackground(Color.gray);
setHorizontalAlignment(JLabel.CENTER);
}
else if (value != null && value.toString().trim().length() != 0 && column != 0) {
//setBackground(Color.red);
setHorizontalAlignment(JLabel.RIGHT);
} else {
setBackground(Color.white);
setHorizontalAlignment(JLabel.LEFT);
}
return super.getTableCellRendererComponent(table, value,
isSelected, hasFocus, row, column);
}
};
//Jtable大小
int table_width = 400;
int table_hight = 380;
//图片生成后再压缩后大小
int image_width = 480;
int image_hight = 480;
JTable table = new JTable(model);
table.setPreferredSize(new Dimension(table_width, table_hight));
//设置列表现器------------------------//
for (int i = 0; i < columnNames.length; i++) {
table.getColumn(columnNames[i]).setCellRenderer(tcr);
}
int width = 180;
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
TableColumn firsetColumn = table.getColumnModel().getColumn(0);
firsetColumn.setPreferredWidth(width);
firsetColumn.setMinWidth(width);
firsetColumn.setMinWidth(width);
JFrame f = new JFrame();
JScrollPane scrollPane = new JScrollPane(table);
scrollPane.setAutoscrolls(false);
f.getContentPane().add(scrollPane);
f.setSize(table_width, table_hight);