Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.sql.*;
- class MysqlCon{
- public static void main(String args[]){
- try{
- Class.forName("com.mysql.jdbc.Driver");
- Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/sonoo","root","root");
- Statement stmt=con.createStatement();
- ResultSet rs=stmt.executeQuery("select * from location where timestamp > 'May 1, 2017 00:00:00' and timestamp < 'May 1, 2017 23:59:59' ");
- while(rs.next())
- CSVWriter writer = new CSVWriter(new FileWriter("/tmp/data.csv"), '\t');
- Boolean includeHeaders = true;
- writer.writeAll(rs, includeHeaders);
- writer.close();
- con.close();
- } catch(Exception e){ System.out.println(e);}
- }
- }
Add Comment
Please, Sign In to add comment