• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

problem while loading data from excel to mysql

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
my code
try{ Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/stock","root","root");
Statement st=con.createStatement();
String filename1="C:\\cm01MAR2002bhav.csv";

st.executeQuery("LOAD DATA INFILE '"+filename1+"' INTO TABLE stock.stockdata FIELDS TERMINATED BY ','LINES TERMINATED BY '\n'(SYMBOL,SERIES,OPEN,HIGH,LOW,CLOSE,LAST,PREVCLOSE,TOTTRDQTY,TOTTRDVAL,TIMESTAMP)");
}catch(Exception e){System.out.println(e);}


error
java.sql.SQLException: File 'C:\ProgramData\MySQL\MySQL Server 5.5\Data\stock\cm01MAR2002bhav.csv' not found (Errcode: 2)
 
Ranch Hand
Posts: 68
Netbeans IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your SQL statement is a "LOAD DATA INFILE" statement in which data is read from a text file by the server. If you want it to be read by the client it should be "LOAD DATA LOCAL INFILE". Using a server side statement like that requires a few things: the file must exists on the server and you need FILE privileges on the server. The client side statement is slower because it needs to send the data to the server but it does not require FILE privileges and the file only has to be on the client.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic