export function with netbeans from mysql to excel

861 views Asked by At

so i need to make a function which will take all datas from a table in my mysql. i've found the query (and it's working), but the problem is how to do it in java?

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+'");

i've try putting some quotation marks but still errors with "unclosed character literal" at line 7. any solutions? thanks before

1

There are 1 answers

0
redrider On

check you codes .. there are missing (")

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+'")";