我正在尝试将多个数据库表写入单个csv文件。
我该怎么做呢?
这是我使用OPEN CSV写入CSV的当前代码。
try {
ResultSet query_set1 = stmt2.executeQuery("SELECT * FROM ARTIFACT_VERSION T1 INNER JOIN ( SELECT ARTIFACTNAME , MAX(DEPLOYMENT_TIME) AS DEPLOYMENT_TIME FROM ARTIFACT_VERSION GROUP by ARTIFACTNAME) T2 ON T1.ARTIFACTNAME = T2.ARTIFACTNAME AND T1.DEPLOYMENT_TIME = T2.DEPLOYMENT_TIME"); //fetch all the rows from the department table
try {
FileWriter my_csv=new FileWriter(filePath+"/artifact_"+username+".csv");
CSVWriter my_csv_output=new CSVWriter(my_csv); //Create a writer object
boolean includecolumnnames=true;
my_csv_output.writeAll(query_set1,includecolumnnames); //write output by directly reading the Resultset, include column names in report
my_csv_output.close();
System.out.println("created");
}
finally {
try { query_set1.close(); } catch (Exception ignore) {}
}
}
finally {
try { stmt2.close(); } catch (Exception ignore) {}
}
}
finally {
try { connection1.close(); } catch (Exception ignore) {}
}
我有一段时间过得很愉快。
你应该提高你的班级间/课程间/研讨会间/无论什么之间的交流。看到
或者至少试着搜索一下