Database Link in DB2 - db2

How to interconnect two different DB2 database hosted on two different IPs?
I mean I want to know is there anything in DB2 which is equivalent to Oracle's DBLink?
I am sitting on a DB2 Test environment and want to copy few rows for testing from production DB2 environment. Is there any easy way to do that?

There is something like that in DB2, called "three part names". I wrote a small overview article for my blog that has an example and all the interesting links to documentation.
The steps involve creating a DRDA wrapper (DRDA is the communication protocol for DB2), then providing the connection details on how to connect to the remote database server. After that you can query the remote tables without any additional setup and address them by server/schema/table - hence the "three part name". Note that you might need to use CATALOG TCPIP NODE first to make a remote server known by its IP address. Something like catalog tcpip node yourserver remote 192.0.32.67 server db2inst1

Related

Transfering data between two managed instance PostgreSQL Servers

I have two remote PostgreSQL servers on managed instances with no local OS that I can access. I want to copy a table from one to the other.
I have DBeaver on a laptop that allows me to set up connections to both servers. When I initiate a transfer job between them, I can see from ethernet traffic that the data is coming from the source remote server down to my laptop 'through' DBeaver and then back up to the target remote server. Two internet trips for the data.
Is there a way to avoid this double trip across the net for my data? Maybe some way of initiating a direct link between the two machines when I have no access to the OS or filesystem of either?
Thanks
Thanks to a-horse-with-no-name for this solution.
As he says in the comments, use a foreign data wrapper.
This link helped me:
https://thoughtbot.com/blog/postgres-foreign-data-wrapper

Incremental data from Postgresql

I have a number of identical local postgreSql databases (identical in structure - not data) on several laptops that have intermittant access to internet. Records are being added to each DB daily. So Branch A,B,C each with a local Postgresql database. I would like all records from A,B,C in each table in a cloud Database.Also A,B,C data is separate - there is no overlap - A doesnt change B, or C etc. There are no duplicated unique keys.
NEED: I would like to collect all this data on a cloud based database by adding daily incremental data to a single cloud databse - so I can query the whole consolidated data using SQL and pull reports as needed.
Please can anyone point me in the right direction?
Thanks
It sounds like you want logical replication from each laptop to the cloud server. The problem there might be that contact must be made by the replica to each of the masters, so when your laptops are online, they would need to have predictable IP addresses so that they can be reached.
Maybe the best way around this is with a reverse SSH tunnel. On the central replica, you would tell it to subscribe to a publication hosted on some non-standard port on localhost. With a different port reserved for each laptop. So, for example, 9997, 9998, and 9999.
Then when each laptop has connectivity, it could run something like:
ssh rajb#1centralserver.example.com -R9999:localhost:5432 -f -N -T
This establishes an ssh connection to the central server (requiring a password, or private key, or however you have ssh set up) and sends instructions to the central server that whenever someone connects to port 9999 on the central server it should really send that connection back over ssh tunnel and hook it up to port 5432 (the default postgres server port) of the laptop.
For initially setting things up and debugging, you might want to omit the -f -N -T. That way, in addition to setting up the tunnel, you also get an interactive ssh session you can use for monitoring things.
Once the central service notices the connection is available, it will start downloading changes since the last time it could connect. When there is no connection, you will get a lot of nuisance messages to the log file as it checks each server every ~5 seconds to see if it is available.
From each laptop's perspective, the connection is coming from within, so the replication connection will use whatever authentication is set up or 127.0.0.1 or ::1, not the authentication set up for the actual remote IP.

How to get the local port of a jdbc connection?

As far as I know when one establishes multiple Connection objects via JDBC to one database then each connection occupies a separate port on the machine where the Connection is established (they all connect to one port on the server where the DBMS is running).
I tried to extract the port that corresponds to the Connection objects. Unfortunately I did not find any way to do so.
Background: I'm doing performance analysis where I setup multiple clients which issue queries on the db. I'm logging the execution time of queries on the database server. In the resulting log I have - among others - information about the connection who initiated the query e.g. localhost.localdomain:44760 I hope it is possible to use this information to map each query to the client or more precisely the Connection object who initiated the query (which is my ultimate goal and serves analysis purposes).
Just run this select through the JDBC connection:
select inet_client_port()
More functions like that are in the manual:
http://www.postgresql.org/docs/current/static/functions-info.html

how to setup web server,application server,db server on multiple vm?

I would like to do my study practice.
To install the multiservers seperating on multiple vm -web server in first vm ,app server in second and db server in the last vm .then,I will create my own webpage to test about accessing data in db .Each of vm is based on VMware in my computer and just do it on localhost environment.not need to connect internet.
How can I do this or Where can I find any Tutorial .Plese give me some suggestion to finish my project ^^"
Thank u very muchh
Just like what you do in physical machines. And IMHO, your question is too general and has nothing to do with virtual machines. I think what you are looking for is how to setup a web server and how to use a database. Why not check the sites such as nginx or apache and mysql or postgresql ?
First of all you need to run all the machines and connected with each other.
By doing this you'll get IP addresses of those machines..
Now simply replace your IP addresses with localhost according to server
Note that every machine must have an appropriate server

how access mysql remote database

i m creating inapp purchage subscription module,
in this app i want to access remote database but problem is that how i connect
my objective-c code with the mysql on the server,
i am not found any sufficient refrence please help me if any refrence or solution is there.
In mySQL, all access from your application to the database server is already remote access. Local access is simply one case of remote access.
If you're working locally, you may be using "localhost" or "127.0.0.1" as the hostname for your data base, and 3306 as the port number. You're using the data base name you set up on your local server, perhaps "arunsdata" or some such thing
You need to find out the hostname and port number of the remote data base server. (The port number is probably 3306.) Then you need to modify your application code to specify that hostname and port number.
Before you do that you will need to have a username and password, and create your data base ("arunsdata" or whatever) on the remote data base and create your tables and other schema items. The administrator of the remote database server can probably help you with this.
Good luck! I remember how confusing this was the first time I faced it. It's simpler than it seems.
You should probably create a web service to access the remote mySQL server database. You can then send a request to the service using NSMutableURLRequest. If you need to return data back, return json since its more light weight than XML.