使用jdbc和jxl将数据库中所有记录备份到excel文件中的工具类,废话不多说,直接上代码!
package com.kz.utils;
import java.io.File;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import jxl.Sheet;
import jxl.Workbook;
import jxl.format.UnderlineStyle;
import jxl.write.Label;
import jxl.write.WritableCellFormat;
import jxl.write.WritableFont;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
import jxl.write.WriteException;
import com.mysql.jdbc.PreparedStatement;
public class BackupDatabase {
private Connection con = null; // 定义一个MYSQL链接对象
private String basePath = null;
private String dbName = null;
public