Results 1 to 8 of 8

Thread: Download a file...

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 2001
    Posts
    37

    Download a file...

    I need to download a database off a server that is currently being used. Meaning the database's state is always changing from people using the website.

    My question is: If I were to download the database file from the server using an InputStream, then reading the InputStream and writing it to a OutputStream file would i have corruption problems? Since the database is always constantly being updated.

    I am will be downloading an Access database, so does Access have some kind of safety mechanism?

  2. #2
    Fanatic Member
    Join Date
    Apr 2001
    Posts
    843
    why dont you modified the database directly... not downloading a copy
    "The difference between mad and genius is the success"

  3. #3

    Thread Starter
    Member
    Join Date
    Sep 2001
    Posts
    37
    I'm going to be running a different application, so I need the info from the database that is being used by the website. And there's no way of accessing the database because it will be on the hosting service.

  4. #4
    Addicted Member
    Join Date
    Nov 2001
    Location
    Yewston, Texis
    Posts
    240
    I don't think there's any way to guarantee that the database will remain static from one read to the next, so I'd bet that you would have corruption problems.

    You might have slightly better luck with BufferedInputStream, but still, I think it's risky.

    I don't know if FTP would do it either...maybe. Is there any way to schedule your updates to your local system, i.e. once nightly?

    Depending on the complexity of your database this suggestion might be a real pain to implement, but could you set up two identical databases on the host? Then when you need to update your local system, a process copies each record from the active to the mirrored database. Once that's completed, you can copy the mirrored database to your local system without worry, since it's not actively being hit.

    cudabean

  5. #5

    Thread Starter
    Member
    Join Date
    Sep 2001
    Posts
    37
    That's pretty good idea Cubabean!
    I was also thinking of implementing RMI.
    But I don't know which would be more of a pain.

    RMI would promise automation, without having to develope a Administrative part to the website that i would have to log-in and set off the process. Or would I?

    I could set up a timer process on the website to automate the procedure. I wonder if I could implement something like that in ASP? To fire the procedure at a given time, would that reduce the performance of the website?

  6. #6
    Addicted Member
    Join Date
    Nov 2001
    Location
    Yewston, Texis
    Posts
    240
    I haven't done RMI so correct me if I'm wrong, but I think the problem with it is that it has to have a listener on the server, i.e., the server needs to listen on a port # that the RMI relationship establishes. Would you be able to do that?

    Another similar approach that could be accomplished with ASP would simply be to write a program to dump the database. Have it write the results to a text file on the server (like a comma separated file or an easy-to-deal-with file containing SQL commands like insert and update statements), then you can schedule your local computer to invoke a servlet or ASP on the remote server to dump the database. To streamline this, you could also put a timestamp on each table, for each record so that you could dump only those records that had been updated, created or deleted since the last time you dumped (deleted records could be marked for deletion, but not really deleted). Then when the dumping process is completed, your local server could download the text file and apply it to the local database.

    When designing these things, especially when they start getting complicated like this, it's always good to step back and reevaluate and see if there's a simpler way of accomplishing the same task. Initially the idea was to simply copy a file, but now it's getting quite twisted. I can, however, think of an much simpler way of accomplishing this, but I've run out of time. I'll post the idea in about three hours from now.

    cudabean

  7. #7
    Addicted Member
    Join Date
    Nov 2001
    Location
    Yewston, Texis
    Posts
    240
    Here's another approach. Don't know if it's much simpler, but here goes:

    Change your program so that you have a method or subroutine that handles all writes to the database. In the subroutine provide a mechanism so that it can detect "NORMAL MODE" or "DOWNLOADING". For "NORMAL MODE" set it up so that instead of writing to just one database, write to two databases identically. That way, you've got your database plus a mirror. Now, when you want to copy the database to your local, you set your mechanism for "DOWNLOADING". When your subroutine detects "DOWNLOADING", it no longer writes to the mirror database, it writes its updates to a temporary file as a sequence of SQL commands. This allows you to copy the static Mirror database directly. Once that is complete, the temporary file can then be "posted" to the mirror database and the system is once again set for "NORMAL MODE".

    cudabean

  8. #8

    Thread Starter
    Member
    Join Date
    Sep 2001
    Posts
    37
    Thanks for the advice CubaBean! I'm going to take a couple of steps back and re-evaluate the problem. Try not to make things so complicated.

    But I think I'm going to go with your first idea, and invoke the process in java throught the URL(www.website.com?Action=Start). That way I don't have to recode the modules in Website.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width