0

i'm trying to creat a setup for my java application which contain a data base m problem is after i creat the setup and try to install in on another pc the app doesn't work i figured that the database does not export whith the project when i creat the .exe

i used install4j and i used a bundle and i imported the database file and the JRE but it sill not working , when i did my research about it i found that i have to go to services in netbeans ( i'm working with netbeans) and creat the database in java DB with using java embedded but its not connecting to !

so please can someone discribe how should it be or can figure the problem ( i creat the data base in mysql and i used the connection normaly)

Filburt
  • 17,626
  • 12
  • 64
  • 115
  • What does not work? Do you get any error messages? Is the application supposed to contain the database already? If so, how does the MySQL server come into play? – Thilo Jul 11 '19 at 08:38
  • when i run the setup on another pc the data doesnt load ,and what do you mean by the application contain the data base already ?i ll show you the code that access the data base which i created independetly in mysql : – Fatiha IMOUSSAINE Jul 11 '19 at 08:42
  • public class Connecter { public Connection con; public Connecter(){ try { Class.forName("com.mysql.jdbc.Driver"); } catch(ClassNotFoundException e) { System.out.println(e);} try { con=DriverManager.getConnection("jdbc:mysql://localhost:3306/cabinetmedicale","root","latitude");} catch(SQLException e){System.out.println(e);} } public Connection getConnextion(){return con;} – Fatiha IMOUSSAINE Jul 11 '19 at 08:44
  • So it prints out an error about not being able to connect to the database? Did you create the MySQL database also on the second PC? Or is it supposed to connect to the database running on your first PC? Then you cannot say `localhost`. – Thilo Jul 11 '19 at 08:48
  • it doesnt print an error msg actually (just doesnt run the .exe ) , and i m not supposed to creat the database on the second pc (but when i did it, the app works ) ,i m supposed to creat a setup which run on any pc whatever it contain a java and mysql or not – Fatiha IMOUSSAINE Jul 11 '19 at 08:58
  • Well, it is going to need to connect to MySQL somehow. If it is not running locally, you have to go over the network (which is starting to sound like a bad idea, you don't want to expose database servers over a normal network). – Thilo Jul 11 '19 at 09:00
  • you said you cant use localhost , so what sould i use is there any way to integrate the data base with java classes as i said i found a way is to creat a data base in services in javaDB BUT IT COULDNT COMPLETE THE TUTO I DONT KNOW WHAT I M DOING WRONG – Fatiha IMOUSSAINE Jul 11 '19 at 09:06
  • You need to either create the MySQL database on the second computer as well (then it can connect using "localhost"), or find out how to connect from that second computer to the first computer (and then change the connection string to include the hostname or IP address of the first computer). You will also need to configure the MySQL on the first computer to allow connections over the network (which really, is not the best idea). https://stackoverflow.com/questions/30190116/connect-to-mysql-database-on-local-network?noredirect=1&lq=1 – Thilo Jul 11 '19 at 09:13
  • 1
    thank you for answering it was a big help – Fatiha IMOUSSAINE Jul 11 '19 at 09:37

0 Answers0