Running Java program on multiple servers [closed] - java

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I wrote a Java program to populate a Database. Currently I run the program on the server and populate the database on the server.
Now I need to run the program locally, and populate the databases in multiple servers. (It is the same database on all servers).
How would I approach this, and does java allow me to connect to a server to run the code then disconnect then repeat with another server?
For example is there a way to connect via via ssh, then disconnect and connect to another server via ssh and repeat the run of the program?

Given you connect to the database using JDCB, you likely use a connection string comparable to this one:
jdbc:mysql://localhost:3306/dbname
Probably you don't specify localhost or the port number, in which case your connection string would look like this:
jdbc:mysql://dbname
In such a case, the default host (being localist) and default port would be used.
To connect to a database on a different server, you would specify the IP address or the server's host name in the connection string:
jdbc:mysql://123.123.123.123:3306/dbname
jdbc:mysql://my-db-server.com:3306/dbname

You could create multiple instances of java.sql.Connection, one for each database you want to connect to.
http://docs.oracle.com/javase/tutorial/jdbc/basics/connecting.html

Related

Connecting java to a mysql domain server [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I've created a java application for our POS project and tried using heliohost.org as my domain server to sync all the data from different branches and uploaded my MySQL database in it. I've successfully connected it, and my application can access the database without any problem. However, when using the domain server there is additional latency -- when I add a product or login to my application it takes a couple of seconds before it carries out the action.
Any tips or other method to sync data from other branches to just 1 database?
Location, Resources and Load concerning the DNS server; this are the
factors that increases or decrease the performance of your DNS server.
Try to optimize this factor.
If you want full speed use your IP itself to connect to the DB server,
this will eliminate the DNS resolution time.
You can also use cloudflare or similar DNS service; they are both
fast and secure (I think it is free also).

How can I find all servers on the local network? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I want to design a software in java. I have a client program in my personal computer which is located in a LAN. In other pcs of this LAN server application has been installed. So the image of my system is like this:
Ok, in this system servers have not same port , because some ports may close in each system, these servers just listen to a connection after finding an open port , as well Client doesn't know their IP, but as I mentioned all of these servers and client program are located in a LAN, picture of client program is some thing like this:
When I click the Scan NetWork Button , Client should find all of the listener servers in network , what should I do in this case? Is it possible to find all listener servers with a client in a network with cause I'm new to networking.
What you probably want is some kind of zero-configuration networking instead, like Bonjour/Zeroconf or SSDP. There are several Java implementations for both, as well as lots of native implementations on almost all OS.
They both solve your problem of finding the servers without knowing their IPs or ports.

What Is Faster One Port Per User, Or All Users On One port [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
What would be faster for a realtime game server, one port per user on the server in which each user is passed a thread and receives a port assignment, or one port per user in which each thread is handed the socket after being established on the main thread?
It's not a question of 'faster'. Once a connection is established it doesn't matter. The real issue is that your first alternative is not implementable without a lot of extra code which in itself will slow things down in the connect phase. A TCP server socket listens on a single fixed port which the clients know about, and they all connect to that port. If you then want to move them to another port you then have to open it, tell them what port it is, and accept another connection. It's all pointless.

How to get ip address of client producing TCP half open connections? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
There is a server listening incoming connections to a given port. Suppose server is 172.16.5.26 and port is 4099. When I scanned this as
nmap 172.16.5.26 -p 4099
I'm able to get the ip address of client. But when TCP half open connection is requested as
nmap -sS 172.16.5.26 -p 4099
I'm unable to get the IP address of client. I'm looking for a method in java to do this task. If there is no such inbuilt method in java library, is there any way to accomplish the task ?
Socket.getRemoteAddess() and friends. But these assume the connection is to your JVM and that this is the corresponding socket. If you're looking for a Java method to find arbitrary half open connections anywhere in the host there isn't one.
What's the motivation here? Why do you need this?

How can I check if RMI is connected/can be connected? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I want to know if my RMI port is available or if busy. While I know that an exception will be thrown if it cannot connect, I would like to have that under control - to show a message "Connection Failed" and stop the process. (I am working with Eclipse). How can that be done?
Generally you cannot control ports, its sort of a first come first served. If you want to listen at a port say 3306, just try and open a server socket on it, if the process of binding fails its because its already in use.
RMI runs at a specific port, and so perhaps your question is about client side sockets in which case you only need to make sure that the RMI service is running?
Assuming u want to find out if RMI is running, u cud try establishing an RMI service at that port, if it fails because of a "Refused to connect" Exception, then RMI is not running

Categories

Resources