I don't think there is an API or function to connect to an external database from within a stored procedure.
You could alternatively set up a complete database replication or execute the DML statements from your scripting environment by use of transactions which you rollback if one command fails.
smantscheff
Nearly a Posting Virtuoso
1,233 posts since Oct 2010
Reputation Points: 300
Solved Threads: 254
Yes you can, but only if db1 and db2 share the same connection parameters: are on the same server and have the same user credentials (username, password).
smantscheff
Nearly a Posting Virtuoso
1,233 posts since Oct 2010
Reputation Points: 300
Solved Threads: 254
I cant do this if they are on different servers?
AFAIK, no.If not (which would slow things down alot....), any way I can emulate it in a Java servlet at least?
Slow down how many things? How many transactions per second do you expect? Why can't you use standard mysql replication? And as I said,execute the DML statements from your scripting environment by use of transactions which you rollback if one command fails
If you do it with Java or PHP or whatever, does not matter. You just have two connections to which you feed the same statements.
smantscheff
Nearly a Posting Virtuoso
1,233 posts since Oct 2010
Reputation Points: 300
Solved Threads: 254
If your idea is to replicate the development steps on the production server by paralleling database statements, then I too deem this as highly insecure. Your development path should instead include a routine which runs all necessary database commands against the production database after they have been thoroughly tested in the development environment. Otherwise you wouldn't need a development environment at all and could develop directly on the production server - bugs and downtime included.
Still, to answer your question, you could install the database on the production server as db2 with the same credentials as db1 and then duplicate your transactions.
smantscheff
Nearly a Posting Virtuoso
1,233 posts since Oct 2010
Reputation Points: 300
Solved Threads: 254
Oh, that looks promising. Thanks for sharing.
smantscheff
Nearly a Posting Virtuoso
1,233 posts since Oct 2010
Reputation Points: 300
Solved Threads: 254