Connecting to mySQL database in different PCs - java

I successfully installed mySQL in my laptop. I created a database, table and inserted rows into it. I ran my program and got the desired output,i.e., the data from the database. Now, I created a jar file of my program with the driver. The jar is working fine in my PC. But when I ran the jar in another PC, I get the error:-
Excecom.mysql.exceptions.jdbc4.CommunicationsException : Communication Link Failure ...
The driver has not received any packets from the server.
Now this is obvious, as the database was not copied. Now, WILL I HAVE TO INSTALL mySQL in each computer I run my .jar??. Then many other questions also arise that, what user shall I use in all the computers? and how do I create a database along with the jar.. Please solve my dilemma.

I think you should be more clear in what you are asking, but to answer your questions :
WILL I HAVE TO INSTALL mySQL in each computer I run my .jar??.
No
what user shall I use in all the computers?
This depends on the level of security you require, but if configured to access from any host you can use the same user/pass on all the computers.

Well mySQL is not appropriate for programs that you need to distribute. SQLite is best file-based database and I am happily shifting to it. Thanks SO for the guidance.

Related

Make java setup for clients

I made software in java Netbeans. I have use small database that is in ms access database.
Now I want to make it for client. So, please help me for make setup that is embed with database.
If it is possible to make jar with database included then tell me how it can be done.
If it is possible to make exe that is included with database so please help me to make setup. One more thing I want to connect database for client without configure with ODBC connectivity. So Please help me for that.
use embedded-databases instead of ms-access :
hsqldb
derby
...

Java app with embedded DERBY DB

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.

Store data between Program Runs Java

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

Using an external HD to write to and store a mysql Database

I have set up mysql database to run with java and eclipse on my Mac, it is running great, but now I will generate aprox 4.3billion rows of data which will take up approx 64gbs of data, I'm storing a large about of keys and encrypted values, I have a 1TB external i would like to use as a storage location, i first thought i could reinstall mysql onto the external but it no luck as it obviously isnt running mac osx, Is there anyway i Can point mysql to store a database on the external, i have done some searching but have not come across an answer yet.
I am running Java to build and query the databse and Table if this comes into play.
Thanks.
Find your mysql config file (typically called my.cnf). Change the database path.
http://dev.mysql.com/tech-resources/articles/mysql_intro.html#SECTION0001500000
Don't reinstall mysql. You should use both the hdd and the external hard to store the data (rows/tables..) for mysql server.
Maybe by changing the path, but I haven't tried that.

Can Paradox 4.5 be set up on a server?

I have established a link using Netbeans and Paradox driver and can query the database. Can Paradox 4.5 (Borland) be set up on a server so that the database can be queried remotely? Please point me in the right direction.
Thanks!
I used paradox pretty long ago, so I hope I remember well.
Paradox is not a server based database, but it is file based. That means you do not need paradox at all to use a paradox database. You just need the proper drivers.
In the configuration you specify a network control directory. You have to use the same location for all computers accessing a database. It is the best if you also use the same driveletter.
The database itself should also have the same driveletter and path from all workstations. You can use the same drive which you use for the network control directory.
If you cannot access the database any more, disconnect all workstations from the database, remove *.net (like pdoxusrs.net) and *.lck in the network control directory, and where the table is located. Then try again.

Categories

Resources