Guest User

Untitled

a guest
Nov 20th, 2017
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. try(FileWriter writer = new FileWriter("D:\\Worker.txt", false)){
  2.  
  3.  
  4.  
  5.  
  6. String fileName = "D:\\Worker.txt";
  7. File file = new File(fileName);
  8. FileInputStream fis = new FileInputStream(file);
  9. Class.forName("com.mysql.jdbc.Driver");
  10. Connection conn = DriverManager.getConnection(
  11. "jdbc:mysql://localhost:1234/sklad","root","1234");
  12.  
  13. String pstmt = ("select * from EmployeeInfo");
  14. Statement s = conn.createStatement();
  15. s.executeQuery (pstmt);
  16. ResultSet rs;
  17. rs = s.getResultSet();
  18. while (rs.next ()){
  19.  
  20. writer.write(resultSetToTableModel(rs));
  21.  
  22. writer.append('\n');
  23. writer.append('E');
  24.  
  25. writer.flush();
  26. }
  27. rs.close ();
  28. s.close ();
  29.  
  30. }catch(Exception e1){
  31. System.out.println(e1.getMessage());
  32. }
  33. }
  34. });
Add Comment
Please, Sign In to add comment