2015-06-09 85 views
1

所以我需要做一個函數,它將從我的mysql中的表中獲取所有數據。我發現了查詢(它工作),但問題是如何在Java中做到這一點?從netbeans導出函數從mysql到excel

public void Print() { 
    Database db = new Database(); 
    ResultSet rs = null; 
    rs = db.getData("SELECT * FROM my_table" 
      + "INTO OUTFILE 'E:\\kurtcobain.csv'" 
      + "FIELDS TERMINATED BY ','" 
      + "ENCLOSED BY '"' 
      + "LINES TERMINATED BY '+\n+'"); 

我嘗試把一些引號,但仍然有錯誤「未閉合的字符文字」在行7.任何解決方案?由於之前

回答

1

檢查你的代碼。有缺失(「)

public void Print() { 
 
    Database db = new Database(); 
 
    ResultSet rs = null; 
 
    rs = db.getData("SELECT * FROM my_table" 
 
      + "INTO OUTFILE 'E:\\kurtcobain.csv'" 
 
      + "FIELDS TERMINATED BY ','" 
 
      + "ENCLOSED BY '"'" 
 
      + "LINES TERMINATED BY '+\n+'")";