Export mysql data for Excel using Apache POI
I have a class MysqlToXls
copied here:
http://mikescode.wordpress.com/2008/02/16/exporting-a-mysql-table-to-excel-xls-in-java/
I edited a class that creates a constructor that doesn't need any parameter like this:
public MysqlToXls()
throws ClassNotFoundException, SQLException {
// Create MySQL database connection
Class.forName("com.mysql.jdbc.Driver");
String url = "jdbc:mysql://localhost/Spinning?user=root&useUnicode=true&characterEncoding=utf8";
connection = DriverManager.getConnection(url);
}
There is no tutorial yet, I am trying to do it myself and I cannot.
MysqlToXls m=new MysqlToXls();
m.generateXls("utente", "utenti.xls");
But there are no errors and the utenti.xls file remains empty. Does anyone know where the problem is?
+3
source to share
2 answers