我将下面的代码发布到 Sun 开发者论坛,因为我认为它是错误的(真正的错误是在此代码被命中之前)。我得到的答复之一说它不起作用并把它扔掉。但它实际上是有效的。它可能不是最好的代码(我是 Java 新手),但它本身是否存在“错误”?
==============
代码:
private static void ImportFromCsvToAccessTable(String mdbFilePath, String accessTableName
, String csvDirPath , String csvFileName ) throws ClassNotFoundException, SQLException {
Connection msConn = getDestinationConnection(mdbFilePath);
try{
String strSQL = "SELECT * INTO " + accessTableName + " FROM [Text;HDR=YES;DATABASE=" + csvDirPath + ";].[" + csvFileName + "]";
PreparedStatement selectPrepSt = msConn.prepareStatement(strSQL );
boolean result = selectPrepSt.execute();
System.out.println( "result = " + result );
} catch(Exception e) {
System.out.println(e);
} finally {
msConn.close();
}
}