Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. public FileInformation getFileInformationByPath(String path, int accountID){
  2. String sqlCommand = "SELECT * FROM [FileInformation] WHERE accountId = ?"
  3. + " and absolutePath = ?";
  4. Connection conn = null;
  5. PreparedStatement ps = null;
  6. ResultSet rs = null;
  7. FileInformation fileInformation = null;
  8.  
  9. try {
  10. conn = db.getConnection();
  11. ps = conn.prepareStatement(sqlCommand);
  12. ps.setInt(1, accountID);
  13. ps.setString(2, path);
  14. rs = ps.executeQuery();
  15.  
  16. if (rs.next()){
  17. int id = rs.getInt("id");
  18. String absolutePath = rs.getString("absolutePath");
  19. boolean directory = rs.getBoolean("isDirectory");
  20. String remoteFileId = rs.getString("remoteFileId");
  21. boolean root = rs.getBoolean("isRoot");
  22. int status = rs.getInt("status");
  23. Date lastModifiedTime = new Date(rs.getTimestamp("lastModifiedTime").getTime());
  24. int accountId = rs.getInt("accountId");
  25.  
  26. fileInformation = new FileInformation(id, absolutePath, directory,
  27. remoteFileId, root, status,
  28. lastModifiedTime, accountId);
  29. }
  30.  
  31. } catch (Exception ex) {
  32. Logger.getLogger(FileInformationDAO.class.getName()).log(Level.SEVERE, null, ex);
  33. } finally {
  34. close.closeResultSet(rs);
  35. close.closePreparedStatement(ps);
  36. close.closeConnection(conn);
  37. }
  38. return fileInformation;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement