I have a (for me complex) problem, but wil try to address only 1 issue in this thread.
I have a java application that has a MySQL database in the backend.
I want to be able to deliver the application along with the database preferebly via an installer (this is also a part I have not currently a solution).
Anyway the problem for now, is that my preference is that MySQL should not be installed as a service.
My reason is that I would prefer not to modify the machine, that my application will be deployed.
I prefer to deliver a "self-contained" application.
So if MySQL is not installed as a service, then it must be started somehow.
I know that I can start MySQL as a standalone using:
mysqld --standalone --console
In this case a new command line window opens and MySQL runs (I used it so far during development/code testing).
I don't know though how I can achieve the same effect once the application is deployed (and start MySQL via code at runtime).
I thought of using the Runtime and do something like:
Runtime rt = Runtime.getRuntime();
Process pr = rt.exec("PATH\\mysqld --standalone --console"); //PATH is of course the appropriate path to MySQL installation
But this does not seem to do anything. It just remains hunging.
Ideally I would like to start MySQL and also not have a concole open.
Is there a solution to my problem?
Why do you want to make your life hard? Don't use MySQL, instead use an Embedded Database, such as:
H2
HyperSQL
Apache Derby
Check MySQL Connector/MXJ. You can download it from here.It gives complete control over start and stop of database.Once you download and extract the zip, check ConnectorMXJObjectTestExample.java under 'src' folder. It will give you complete idea.
Related
I created a java project that uses a database to retrieve, edit, and save data. I finished the project using Netbeans and now I want to create an installation out of the project. To do so, I want to include the database to be installed along with the project. The code I am using to connect to the database is:
Class.forName("org.h2.Driver");
Connection con = DriverManager.getConnection("jdbc:h2:~/localhost/gallerie", "root", "123");
The application is working fine on my pc, but I need it to be installed as an executable on other pcs.
What is the best way to do so?
One way to do this is with the setup packager from stardust software. You will also need to include some script or some Java code to create the database and the database user. You don't need to do that with the installer. Instead, create some file or store something using the Preferences API so the program knows when it is running for the first time. When your program runs for the first time it needs to call some function to create the database user and the database.
Alternatively, you could also package the database files with your application as described by this stack overflow question.
I want to produce an "auto updating" application thats running within the tomcat server. Heres a better explanation:
A Play Framework 1.2x application war (exploded) running on windows (sadly..)
Tomcat check for a new version from http://www.somewebsource.com/app.zip (or whatever extension)
Tomcat checks the server every day at 1am and if there is a new version, tomcat will download the file (undeploy the old one?) and autodeploy.
I've searched the web for this, but i couldnt find what "keywords" i should look at.
My application is running on several machines and i want them to be updated without any human interaction. Is it possible?
Write a cronjob and deploy. With a few line of script code you'll be done.
I'm having a problem runnig Java class run through a Python script, that is in turn executed by an Apache web server.
I have the following file, accesible via an Apache webserver
script.cgi
#!/usr/bin/python
os.system("java HelloWorld")
sys.stdout.flush()
The I run the script from the shell, it runs properly. However, when I access it via a web browser, the os.system("java ...") returns exit status 1536.
Any idea why this is happening?
This is running on Linux Mint 13. Please let me know what extra information I can provide.
Thank you
When running the script from your command line you probably have different enviroment variables set and you have a different security content.
Make sure that your webserver finds the files (E.g. try using full path names) and check if everyone has the execute permission for java and read to the folder and file(For security reasons I'm not sure if that is a good idea tough).
I am trying for a while to make executable JAVA application having embedded DB (derby DB), but facing some problems, and need your valuable help.
Namely, I am using Eclipse as environment.
I export Java app to RUNNABLE JAR file, and it works fine on my desktop machine.
The idea is to make EXE doubleclick icon and send it to another machine which have no JAVA background/environment....so point is to send it to another user who will just get exe file, double click it and work with it.
The DB is not only readable, since application is inserting data in tables.
So, it works fine on my machine, but when I send the same JAR file to another machine, I get error:
"Schema TEST does not exist"
I can see application but without any data, like there is no connection with DB. So, it is useless.
Even I use JSmooth, Install4j.... to convert JAR to exe file, I get the same error.
So, first I have to make JAR file working on another machine.
Seems to me, I am doing something wrong with DB files.
Please let me know what info u need more from my side, and let me know how I can do this.
If the application intends to read AND WRITE data when it is running, then it can't be entirely contained in a JAR file, because you can't put an updatable Derby database in a JAR file. You'll need to have some "installation procedure", perhaps some logic that you run the first time your application is double-clicked by the user, that (a) finds a suitable location for the Derby database on the user's machine, (b) creates the database and defines all the tables, views, etc, (c) loads any initial data.
Then, on subsequent runs of the application, it will be able to re-open the database and continue using it.
Short Version: I need to store some data between runs of a java program.The data will be of the form of a table.Is there anything that can let do something like a sql query in java??THE SOLUTION MUST BE ABLE TO RUN ON AN OFFLINE COMPUTER.
Long Version: The user will be entering some data daily and i want something like a sql table in java. The program will run on a computer that is NOT CONNECTED TO THE INTERNET and so i need a truly local way to store data(Lots of it).Also preferably the data should be stored in such a way that it is not easily accessible to the end user(as in ,he should not be able to double click the file and simply read its contents)
Major Constraint: On searching online i found many people were using localhost to solve similar problems but that facility is not available to me as i CANNOT INSTALL ANYTHING on the target computer.
If a simple data file is not good enough, how about using SQLite with a JDBC backend? It will allow you to have an SQL database stored in a regular file with no dependency on any kind of server. Alternatively, there are many other embedded DB engines that you could use, depending on your needs.
EDIT:
By the way, most (if not all) DB engines that I know of do not obfuscate the data before storing them in the filesystem. The data will be fragmented, but parts of it will be visible if you force an editor to open the file (e.g. using "Open with..." in Windows).
There is also nothing to stop your user from accessing the data using the command line utility of the selected DB engine. If you want to obfuscate the data you have to do it in your code. Keep in mind that this will not stop a determined person - if your application can read it offline, so can everyone else.
Use an embedded database (like Apache Derby, HSQLDB, H2) so that you don't have to run a database server on the machine. The data will be stored locally on the target machine and it won't be human readable.
You have several options:
Store it in an xml-file
Store it in an local installed database
You can install a database like mysql or use a in memory database like sqlite or hbase or apache derby, which is included in java 6