Tolong pilih kategori sesuai, jenis posting (pertanyaan atau bukan) dan sertakan tag/topik yang sesuai misal komputer, php, mysql, dll.
Promosi atau posting tidak pada tempatnya akan kami hapus.
Mencantumkan kode program di posting Anda, tolong ikuti aturan yang sesuai, baca http://diskusiweb.com/discussion/39204/aturan-cara-menyisipkan-kode-program-di-diskusiweb

Baca cara posting gambar/image di post Anda: http://www.diskusiweb.com/discussion/47345/cara-menyisipkan-menyertakan-image-pada-posting/p1

OPEN File JAVA

gan mau tanya masalah open file. kan saya pakai perintah sql queri seperti dibawah ini

JFileChooser fileChooser = new JFileChooser();
fileChooser.setCurrentDirectory(new File(System.getProperty("user.home")emoticon-Wink);
int result = fileChooser.showOpenDialog(this);
if (result == JFileChooser.APPROVE_OPTION) {
try {
File selectedFile = fileChooser.getSelectedFile();
System.out.println("Selected file: " + selectedFile.getAbsolutePath());

// TODO add your handling code here:

String sql = "load data infile "+selectedFile.getAbsolutePath()+" into table tb_indonesia fields\n" +
"terminated by ';' optionally enclosed by '' escaped by ''\n" +
"lines starting by '' terminated by '\n' ignore 1 lines \n";
Connection Konek = new koneksi_mysql().getConnection();
Statement stat = Konek.createStatement();

long start;
long end;

start = System.currentTimeMillis();
for (int i = 0; i <=2; i++) {
System.out.println ("ke " + i);
stat.execute(sql);
}
end = System.currentTimeMillis();
System.out.println("\nWaktu yang diperlukan selama proses adalah " + ((end - start) / 1000.0) + " detik");
} catch (SQLException ex) {
Logger.getLogger(NewJFrame.class.getName()).log(Level.SEVERE, null, ex);
}
}

tp pas saya running terus open data error katanya syntaq sql salah. mungkin yg bisa koreksi gan minta bantuannya
tulisan errornya seperti ini gan
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'C:\xampp\mysql\data.txt into table tb_indonesia fields
terminated by ';' optiona' at line 1

saya pakai mariadb dan netbeans 8.0
Sign In or Register to comment.