Java - mysql - select outfile request - where the file is saved

connecting to mysql database from java using jdbc. request announcement

String query = 
                    "SELECT *"+
                    "FROM tt2"+
                    "INTO OUTFILE 'DataFormatted.csv'"+
                    "FIELDS TERMINATED BY ','"+
                    "ENCLOSED BY '\"'" +
                    "LINES TERMINATED BY '\n'";

query execution using executeQuery (query).

how to change the code above to save DataFormatted.csv to the root directory of drive c

+3
source share
3 answers

where the file is saved.

In the current working directory of the MySQL server. Which one depends on how the MySQL server is executed and configured. It is best to change the location of the CSV file in a fixed location.

how to change the code above to save DataFormatted.csv to the root directory of drive c

Just change 'DataFormatted.csv'to 'C:/DataFormatted.csv'.

, Java-, MySQL , CSV Java. , , , CSV , . FTP'ing CSV .

+4

, SQL- ( ), OUTFILE .
, .
- C:\Program Files\MySQLServer\data\test test.

, , show variables where variable_name = 'datadir'.

OUTFILE, , BalusC.

+2
SELECT ... INTO OUTFILE

uploads data to a file on the MySQL server machine. If you want to create a local file on the Java client, you will need to create it yourself.

0
source

Source: https://habr.com/ru/post/1725393/


All Articles