Interactive Data between php and java

Source: Internet
Author: User
Tags php database
My problem is: 1. java has its own database a, and php also has its own database B. 2. The database table structure of java and php is different. 3. Now, php needs to obtain the data in java Database a and write it into its own database B. 4. If the java library and php library are not on the same server or in the same... my problem is:
1. java has its own database a and php also has its own database B.
2. The database table structures of java and php are different.
3. Now, php needs to obtain data from java Database a and write it to its own database B.
4. If the java and php libraries are not on the same server or on the same server (how can this problem be solved ?)
5. (a new piece of data in java is written to the php database at the same time, and two pieces of data are written.) or (do not write data from time to time for 2 hours or 5 hours) I do not know whether my problem description is clear or not. Please help me. Thank you.

Reply content:

My problem is:
1. java has its own database a and php also has its own database B.
2. The database table structures of java and php are different.
3. Now, php needs to obtain data from java Database a and write it to its own database B.
4. If the java and php libraries are not on the same server or on the same server (how can this problem be solved ?)
5. (a new piece of data in java is written to the php database at the same time, and two pieces of data are written.) or (do not write data from time to time for 2 hours or 5 hours) I do not know whether my problem description is clear or not. Please help me. Thank you.

When new data is inserted in JAVA, a piece of information is pushed to PHP, and PHP receives the insert...

My recent project is also connected to a JAVA mall. The implementation method uses HTTP to transmit JSON-format data ..
JAVA has data modification or addition ---> calling PHP external interface (verifying IP address, verifying data validity, etc ........)
PHP is also ................

Because I didn't want to use a java program to trigger php in the past, I am not very clear about how to solve it. So I used the following method to handle similar problems, if you do not have high requirements on Data Synchronization time.

  1. Java inserts a message in the status that is not called by database B.
  2. Php regularly accesses a java rest api, and java calls out state-marked data (not called data josn) and sends it to php
  3. After successful php insertion, send the json string of the Data id back to the java api
  4. Java marks the status of these IDs as called, and then verifies whether the IDS sent and received are consistent. If there are any discrepancies, the data that has not been successfully inserted will be sent back to php, or success. End

In the middle, we should take vaildation into account. It would be safer if all the APIs are in the intranet.

Php cannot connect to a first, disconnect a after obtaining the data, then connect B, and then update the data? It seems that there is 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 ..

Databases do not have language boundaries. They communicate through network protocols. Both java and php can connect to database a and database B, and can also be connected. If java interacts with php, you can use the thrift RPC framework for interaction.

It is recommended that you do not directly connect to the database through interfaces. errors may cause debugging difficulties. The cross-language RPC framework can be used for interaction. Thrift is also a good choice.

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.