PDA

View Full Version : would like to parse java file into php/mysql


wolfdogg
09-29-2008, 03:25 PM
i would like to parse a file from a java program and insert it into a remote mysql db using php with an automatic daily check.

the idea is;
each java program (situated at various locations) takes in user info(data entry) daily when its used and will be re-configured to copy this info into a new file for a php program to retrieve a daily update to a php/mysql db with the info thats on this file.

the objective is to consolidate all the info on the seperate java based programs into one database, so that when a person is using the java based program, they will have an aid to pull up a browser and do a search on this php/mysql database to look up the entries from all the other remote java program users.

i want to program the php app to connect to all the registered java apps out there and see if theres a new file for the day, and if so, then parse it and insert it into the mysql db.

-is there a good module for parsing java into php already out there?
-should i just use a file-open function and get-contents this way?
-what file type should i have the java program save as (the java programmer suggested ascii text file, as this is the easiest for him)?
(i would like to avoid xml as the intermediary)
-the data will be sensitive

wolfdogg
10-05-2008, 04:39 PM
am i asking this question wrong, or is java a bad way to go? hehe.

i have a programmer buddy who built the program in java, i just want to communicate with it using php, my language of choice.

should i just be getting contents of a file or is there another way to go to get info from a java program and insert it into a MYSQL database using PHP?

paul_norman_81
10-06-2008, 04:01 AM
Your best bet is likely to get the Java programs writing directly to the database.

If this isn't possible you'll have to think about security quite a bit more ($_GET password hashing or something could be enough depending on the level of data sensitivity). You will have to generate flat files (.txt or whatever) and then remotely access them using cURL (or again whatever) and then parse them into PHP code and do what you will with them from there.

Format wise I would go with xml (parsers for both Java and PHP), but that's just me. And only retrive/output the data if the password validates. If this is not an option you could make up your own format (whatever you like) or use csv, ini etc depending on what your parsing preference is.

If possible I would go with writing straight to your DB or a staging DB... hope this helps.

wolfdogg
11-03-2008, 12:56 PM
yeah, i dont program java, and the java programmer probably doesnt know how or isnt willing..

do you suggest $_GET an md5($password) for example?

im not familiar with cURL, yet, is there someting else i may be familiar with like this?

do you think a .txt would be ok if its in a secure location?
i could put a password on the first line for example, then md5 verify this. i cant be sure how i would get the valid password in the first place to md5 verify it either in that case. unless we use the same (pre-determined) password for all files if thats what your suggesting. i can see how that would work.

If the password passes, then scrape the data using what? something like file_get_contents()? or how would i read this info?

scoutt
11-18-2008, 08:44 PM
forgive me if I am wrong but isn't most java compile jar files? what is the file that you think you can parse with php? I bet you can't parse a java file, at least I haven't seen it done.