Results 1 to 12 of 12

Thread: FTP access via Java

  1. #1
    Senior Member Kezzer's Avatar
    Join Date
    Sep 2003
    Posts
    4,863
    Thanks
    12
    Thanked
    5 times in 5 posts

    FTP access via Java

    Ok, i was going to post in the other thread and move on from the argument but obviously i can't now so here's a nice new one

    The reason why i can't use JDBC is because many hosting options don't allow non-localhostusers to access the database for obvious reasons. Yes you could configure it but many of them don't allow you to and i need something which will work no matter what. So, the only other option to accessing and modifying a database is uploading php files, executing them and then deleting them.

    I've been given links to pre-made packages for FTP access but i want to write my own class. I've had a thorough search and can't seem to find any class which has anything related to FTP access. I must be wrong as there's programs written completely in Java primarily for FTP access.

    Any ideas on the class name as i'm completely clueless to this area?

    Cheers guys

    (p.s. you know i love you, no harm intended )

  2. #2
    Goat Boy
    Join Date
    Jul 2003
    Location
    Alexandra Park, London
    Posts
    2,428
    Thanks
    0
    Thanked
    0 times in 0 posts
    Why not user HSQLDB?

    http://hsqldb.sourceforge.net/
    "All our beliefs are being challenged now, and rightfully so, they're stupid." - Bill Hicks

  3. #3
    Senior Member Kezzer's Avatar
    Join Date
    Sep 2003
    Posts
    4,863
    Thanks
    12
    Thanked
    5 times in 5 posts
    Hehe, i really should explain things more clearly *slaps self*

    The project we're working on is designed to keep two databases up to date (although we may change this in the future).

    Basically two databases will be in "sync" as so to speak. You'll modify entries in an application on the client side, you'll then be able to press a button and it'll update a local database and then update the remote database so they stay in sync most of the time. This means we need to be able to access the remote database easily with non-localhost user access (which is disabled with many hosting companies) which renders users unable to connect to their databases.

  4. #4
    bored out of my tiny mind malfunction's Avatar
    Join Date
    Jul 2003
    Location
    Lurking
    Posts
    3,923
    Thanks
    191
    Thanked
    187 times in 163 posts
    • malfunction's system
      • Motherboard:
      • Gigabyte G1.Sniper (with daft heatsinks and annoying Killer NIC)
      • CPU:
      • Xeon X5670 (6 core LGA 1366) @ 4.4GHz
      • Memory:
      • 48GB DDR3 1600 (6 * 8GB)
      • Storage:
      • 1TB 840 Evo + 1TB 850 Evo
      • Graphics card(s):
      • 290X
      • PSU:
      • Antec True Power New 750W
      • Case:
      • Cooltek W2
      • Operating System:
      • Windows 10
      • Monitor(s):
      • Dell U2715H
    What's the server capable of doing? You say no remote access to the database but if you can run scripts on the server and they can access the database then you can knock up a simple protocol to post updates to the server (in fact you could do the same so that you can read the data out of the database for the client instead of keeping a local copy)... That way all the data can stay in the database on the server and the client can access the database via a custom protocol on top of HTTP...

  5. #5
    Senior Member Kezzer's Avatar
    Join Date
    Sep 2003
    Posts
    4,863
    Thanks
    12
    Thanked
    5 times in 5 posts
    Hehe, i'm missing points again

    I'll go deeper. There are reasons for having two copies of the database which again, may be changed:
    a) to keep a backup of the current database
    b) to have an "offline" mode where you can make changes and then in a click of a button make multiple changes in one go

    We have considered having one database but having an option to "backup" the database to a current copy or a dated copy.

  6. #6
    bored out of my tiny mind malfunction's Avatar
    Join Date
    Jul 2003
    Location
    Lurking
    Posts
    3,923
    Thanks
    191
    Thanked
    187 times in 163 posts
    • malfunction's system
      • Motherboard:
      • Gigabyte G1.Sniper (with daft heatsinks and annoying Killer NIC)
      • CPU:
      • Xeon X5670 (6 core LGA 1366) @ 4.4GHz
      • Memory:
      • 48GB DDR3 1600 (6 * 8GB)
      • Storage:
      • 1TB 840 Evo + 1TB 850 Evo
      • Graphics card(s):
      • 290X
      • PSU:
      • Antec True Power New 750W
      • Case:
      • Cooltek W2
      • Operating System:
      • Windows 10
      • Monitor(s):
      • Dell U2715H
    Well... If you have to sync them, as opposed to taking a backup of the master, it will be a PITA if you allow more than one person to have an offline copy that they can edit... i.e.

    Person A syncs the local copy of the database and makes changes to it offline
    Person B does the same
    Person A finishes and updates the master database
    Person B finished and updates the master database... How do you cope with that if they've both changed the same tables / data? Even if they were working on separate items (both created new records for example) on the same tables... They could both be trying to upload records with the same primary key (for autonumber type keys)

    If you implement some kind of protocol over HTTP to be able to update the database remotely (and fetch data out of it remotely too) then it wouldn't be much of a stretch to expand the update and read portions to be able to backup the entire database and to restore the entire database. Whatever you do though... Be careful what you let the protocol do... Don't transfer plain SQL commands around... If you get hacked you'll be FUBAR... Restrict what is allowed and validate / verify identity / origin of the files if at all possible (usernames, passwords, hash / checksums, etc). And if you can do it all over HTTPS not plain HTTP.

    You really are reinventing the wheel though. No chance of persuading the host to allow SSH access to the database?

    Are we still talking about the CMS style system?

  7. #7
    Senior Member Kezzer's Avatar
    Join Date
    Sep 2003
    Posts
    4,863
    Thanks
    12
    Thanked
    5 times in 5 posts
    Yup, the CMS is the part which is being incorporated. It's just a CMS but you interact with the database remotely from an application on the client side.

    SSH access would be nice, but again we're aiming for this to apply to many people so we need to use a protocol which is available to the majority of users. We want to go from the ground up so HTTP/HTTPS would be a start and then we'd have extra options for SSH if their hosting option supports it.

    I get what you mean with multiple users, basically we'd do checks before we make any changes, but for now it'll be single user mode only

  8. #8
    bored out of my tiny mind malfunction's Avatar
    Join Date
    Jul 2003
    Location
    Lurking
    Posts
    3,923
    Thanks
    191
    Thanked
    187 times in 163 posts
    • malfunction's system
      • Motherboard:
      • Gigabyte G1.Sniper (with daft heatsinks and annoying Killer NIC)
      • CPU:
      • Xeon X5670 (6 core LGA 1366) @ 4.4GHz
      • Memory:
      • 48GB DDR3 1600 (6 * 8GB)
      • Storage:
      • 1TB 840 Evo + 1TB 850 Evo
      • Graphics card(s):
      • 290X
      • PSU:
      • Antec True Power New 750W
      • Case:
      • Cooltek W2
      • Operating System:
      • Windows 10
      • Monitor(s):
      • Dell U2715H
    Why don't you model it like a version control system? Where a user checks in and checks out items? That way you'd only specify existing record ids if the items were being updated as opposed to being new. For new items the server side would allocate a new id as required...

    In fact as you're using autonumbers for the primary keys on your tables (IIRC) you can (almost) literally leave it out of the insert statement...

    E.g.

    "MYTAB"
    "ID" int primary key auto number
    "DESC" varchar(255)

    insert into mytab values (, 'blah blah blah')

    instead of:

    insert into mytab values (1, 'blah blah blah)

  9. #9
    Senior Member Kezzer's Avatar
    Join Date
    Sep 2003
    Posts
    4,863
    Thanks
    12
    Thanked
    5 times in 5 posts
    Yup, a version control system would be a good idea. Basically the "last_modified" field could be configured to include closer times so we could say if the entry has been modified since the user opened the program then prompt the user that the entry has been edited beforehand perhaps?

    I'm mainly concentrating on HTTP/HTTPS/FTP access via Java though. I just want to get that out of the way so i can upload the scripts first of all

  10. #10
    bored out of my tiny mind malfunction's Avatar
    Join Date
    Jul 2003
    Location
    Lurking
    Posts
    3,923
    Thanks
    191
    Thanked
    187 times in 163 posts
    • malfunction's system
      • Motherboard:
      • Gigabyte G1.Sniper (with daft heatsinks and annoying Killer NIC)
      • CPU:
      • Xeon X5670 (6 core LGA 1366) @ 4.4GHz
      • Memory:
      • 48GB DDR3 1600 (6 * 8GB)
      • Storage:
      • 1TB 840 Evo + 1TB 850 Evo
      • Graphics card(s):
      • 290X
      • PSU:
      • Antec True Power New 750W
      • Case:
      • Cooltek W2
      • Operating System:
      • Windows 10
      • Monitor(s):
      • Dell U2715H
    Fair enough. For HTTPS start here:

    http://java.sun.com/j2se/1.5.0/docs/...onnection.html

    (and see the parent class for simple HTTP which is what I'd start out with for development and testing purposes)

    In terms of FTP there's nothing built in AFAIK... FTP is a fairly simple protocol though - basically if you want / have to do it yourself you need to read up on the protocol as well as active and passive FTP (and you may need to support both)... Then read up on the Socket class (and ServerSocket):

    http://java.sun.com/j2se/1.5.0/docs/...et/Socket.html
    http://java.sun.com/j2se/1.5.0/docs/...verSocket.html

  11. #11
    Senior Member Kezzer's Avatar
    Join Date
    Sep 2003
    Posts
    4,863
    Thanks
    12
    Thanked
    5 times in 5 posts
    Is HTTPS connection-oriented? Also, can you upload files via HTTPS?

  12. #12
    bored out of my tiny mind malfunction's Avatar
    Join Date
    Jul 2003
    Location
    Lurking
    Posts
    3,923
    Thanks
    191
    Thanked
    187 times in 163 posts
    • malfunction's system
      • Motherboard:
      • Gigabyte G1.Sniper (with daft heatsinks and annoying Killer NIC)
      • CPU:
      • Xeon X5670 (6 core LGA 1366) @ 4.4GHz
      • Memory:
      • 48GB DDR3 1600 (6 * 8GB)
      • Storage:
      • 1TB 840 Evo + 1TB 850 Evo
      • Graphics card(s):
      • 290X
      • PSU:
      • Antec True Power New 750W
      • Case:
      • Cooltek W2
      • Operating System:
      • Windows 10
      • Monitor(s):
      • Dell U2715H
    You can POST any data you want to a web server using HTTP or HTTPS...

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Best book to learn JAVA 2?
    By Taz in forum Software
    Replies: 16
    Last Post: 27-08-2005, 08:54 PM
  2. Replies: 7
    Last Post: 05-02-2005, 03:53 PM
  3. Using the ftp command in unix
    By PanzerKnight in forum Software
    Replies: 2
    Last Post: 19-03-2004, 04:03 PM
  4. Access Reports - help....
    By Lead_Head in forum Software
    Replies: 5
    Last Post: 22-10-2003, 12:19 PM
  5. NT4 Domain - A: drive access
    By joshwa in forum Software
    Replies: 1
    Last Post: 27-08-2003, 09:07 AM

Posting Permissions

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