0

I am developing a Java-FX application that uses MySQL database locally, but however it needs a local connection, what should I do to make it run properly on the customer computer ? should I ask him to install MySQL their ?

modification : If I install the server on his computer, how can I make the app connect to the database while it need first to be created by some queries ?

Andrew Meleka
  • 93
  • 1
  • 10

2 Answers2

1

There is a way :) not the best but can solve your problem.

simply use "sqlite" . sqlite doesn't need a server.

so first you have to save sql of your database, and with an sqlite-browser create a database and import your sql. your database is saved as a single file. and you can change localhost by relative path to database.

here is some examples :

Class.forName("org.sqlite.JDBC").newInstance(); c
stat = con.createStatement();
stat.executeUpdate("create table if not exists user(Name varchar(50),Email varchar(50));");




data = FXCollections.observableArrayList();
            ResultSet rs = con.createStatement().executeQuery("select * from user");
            while (rs.next()) {
                data.add(new UserData(rs.getString("Name"), rs.getString("Email")));
            }

source : http://www.javafxapps.in/tutorial/Persisting-TableView-datas-in-Database.html

Mimouni
  • 3,564
  • 3
  • 28
  • 37
  • Unfortunately, my app contains many tables and so I need to use MySQL, also sq-lite syntax is just like hell, all i need to know is how to allow the customer use the MySQL. – Andrew Meleka Jul 15 '16 at 10:49
  • @andrew: perhaps you can make your application in a packaging with installshield including the setup of mysql : https://shieldmaster.wordpress.com/2009/04/26/tutorial-adding-setup-prerequisites-to-installshield-package/ – Mimouni Jul 15 '16 at 10:54
  • yup, that what i was gonna do, but the question is how to connect to the database ? I need to write some queries in order to create it, but of course i won't do that on the customer's pc, so how can i achieve this ? – Andrew Meleka Jul 15 '16 at 11:00
0

MySQL needs a server. What the server is, is your decision.

Your edit still doesnt make perfect sense. How can you query something without an engine to do so. You cant learn how to run as a baby, before you are even born. Which is how Im reading this '

  1. Install MYSQL Server, using set configs (install mysql on ubuntu without password prompt)
  2. Run SQL Queries to provision needed tables
  3. Have app use a pretedermined config
  4. Connect to it however you need to
Community
  • 1
  • 1
Nick
  • 1,208
  • 11
  • 26