PHP and Java interact with data

Source: Internet
Author: User
Tags php database string back
My question is:
1, Java has its own database a,php also has its own database B.
2, Java and PHP database table structure is not the same
3, now PHP to get the data in Java database A to write to their own database B inside
4, if the Java Library and PHP Library is not on the same server or on the same server (how to solve this problem?). )
5, (Java has a new data to write to the PHP database at the same time, there are two write two) or (do not write at all times, 2 hours, 5 hours so also can) do not know my problem description of the clear unclear, please hero help me see, thank you

Reply content:

My question is:
1, Java has its own database a,php also has its own database B.
2, Java and PHP database table structure is not the same
3, now PHP to get the data in Java database A to write to their own database B inside
4, if the Java Library and PHP Library is not on the same server or on the same server (how to solve this problem?). )
5, (Java has a new data to write to the PHP database at the same time, there are two write two) or (do not write at all times, 2 hours, 5 hours so also can) do not know my problem description of the clear unclear, please hero help me see, thank you

Java has new data inserted to push a message into PHP, PHP receive insert ...

My recent project is also docking a Java mall. Implementation uses HTTP to transmit JSON-formatted data.
Java side has data modification or add---> Invoke PHP external interface (verify IP, verify data legitimacy, etc...)
PHP is also ...... .....

Because previously do not want to use Java program to trigger PHP, mainly not very clear how to do, so I deal with a similar problem is the following method, if you are not very high data synchronization time requirements.

    1. Java inserts a message with a status of not being called by database B
    2. PHP timed access to a Java rest Api,java to bring up data with status tags (not called data josn) sent to PHP
    3. After the PHP insert succeeds, send the data ID JSON string back to the Java API
    4. Java will be labeled as these ID states have been called, and then verify that the two send and receive back the ID number is consistent, if there is no successful insert data sent back to PHP, otherwise it is success. End

The middle of the vaildation are considered clearly, if the API is in the intranet will be more secure

Can PHP not first connect A, get the data, disconnect a, then connect B, then update the data? There seems to be no cross-language problem, even if you use different types of databases such as SQL Server and MySQL, you can also use PDO and other extensions.

The database does not exist language boundaries, all through the network protocol communication, Java or PHP can connect databases A and B, and even can. If you really first interact with Java and PHP, consider using the Thrift RPC Framework for interaction.

It is best not to connect directly to the database through an interface, which can cause debugging difficulties when an error occurs. You can use the cross-language RPC framework to interact, and thrift is a good choice.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.