How to execute a .jar using java jdbc on another machine

0

I am a beginner in the java area, I made an application using the netbeans native database. I generate the file jar , and on the machine I made the application the jar executes normally, but when I put this jar on another machine it just opens, more when it arrives at the part that makes the connection in the bank. button to register, not to register, nor list) it simply does not open.

I would like to know how I do to run on another machine, like it was done on windows 10, and I want to run on windows 7.

    
asked by anonymous 17.02.2016 / 14:07

1 answer

0

In the scenario you are reporting, the machine you want to run your jar must be on the same network as the machine that contains the database.

Then, at the location where you used localhost in your connection configuration, the IP of the machine containing the database will be passed.

An example:

  • Machine 1 (database): IP: 10.3.1.100
  • Machine 2 (jar): IP: 10.3.1.102

In order for machine 2 to communicate with machine 1, in its persistence.xml , it is necessary to configure the property responsible for the url as follows:

<property name="javax.persistence.jdbc.url" value="jdbc:meu_sgbd://ip_maquina_1/minha_base_de_dados" />

Note: Do not forget to inform the port used by the DBMS.

    
18.02.2016 / 02:11