Retrieve CSV file through java.


try
        {
           Class.forName("com.mysql.jdbc.Driver");
           java.sql.Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3305/supplimentry","root","root");
           String sql="LOAD DATA LOCAL INFILE 'h://inventory.csv'\n" +
            "INTO TABLE inventory\n" +
            "FIELDS TERMINATED BY ','\n" +
            "OPTIONALLY ENCLOSED BY '\"'\n" +
            "LINES TERMINATED BY '\n'";
           java.sql.PreparedStatement pst1=con.prepareStatement(sql);
           pst1.executeUpdate();
           con.close();
           pst1.close();
           JOptionPane.showMessageDialog(null,"Restore Successfully!!!!");
        }
        catch(Exception e)
        {
            System.out.println(e);
        }

Popular posts from this blog

Simple Sign up design. Android.

Cart page design in android.

Set Date on jDateChooser and retrieve record from database.