Make java setup for clients - java

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
...

Related

Accessing Connected Database DB in Eclipse with Java Code

I successfully connected to a DB in eclipse through the Database Development perspective and am able to run queries in the SQL File Editor. However, I would like to write java code to automatically run a query and then extract the data to a flat file. What is the easiest way to do this? Since I am already connected to the database, can I bypass the java code that involves connecting to the database.
No, the Java JVM also needs to be able to connect to the database. There are many examples of JDBC connections on the internet, including this one.
Once you have got the data you needed, you should make use of FileWriter in order to write the information to file.

Connecting to mySQL database in different PCs

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.

Concurrency embedded Java Database for simple Application

I am trying to build a simple GUI in which you can write some Integers. These Integers are supposed to be written into a Database, which I am looking for.
So far so good. The data in the Database should then be used for another stand-alone application, which already exists.
I tried it with SQLite already but I received a lot of "Database locked" Errors. I searched Google. The key answer I often read about was to switch to a database which supports concurrent processes.
I went further on and had a look at H2 and HSQLDB. Both of them seem to be legit but much more complicated.
So I wonder:
I would like to have the GUI to be portable in a .jar file (or a folder only) combined with the Database, so when I switch computers I do not have to install the DB in a certain folder like the home-directory or something. With SQLite all you do is this:
Connection con = DriverManager.getConnection("jdbc:sqlite:test.db");
As you can see, no Path-infortmation is necessary. How can I do this with H2 or HSQLDB?
I am really looking forward to your suggestions. But only open source please.
Kindest regards and thank you very much!
Stefan
With H2 and HSQLDB you can do the same.
With H2, a database URL of the form jdbc:h2:test will create a file called test.h2.db in the current working directory of your application. If this is what you want, then that's fine. Please note I usually don't suggest to do that, because many people run into the problem that they sometimes start the application in a different directory (which will then create a new database). Because of that, I suggest to use jdbc:h2:~/test, which means the database file is stored relative to the current user home directory.
Handling the creation of an embedded db file should not be a big issue - but if you really dislike this stick with SQLite: it should handle concurrency well enough for basic usage - 'database locked' sounds more like an application level problem

how to add mysql db to my project?

I write a program with netbeans.
I connect my program to mysql an use from db that I made in mysql and it work correct.
Now I create .jar file from my project and it works but didn't connect to mysql and don't show any data but I am sure that I have information in my database.
What is problem?
You need to do more debugging. Make sure you are catching and logging or printing out exceptions. They should indicate a more specific problem. Make sure you have all the needed drivers and depended libraries in the class path of the .jar you are trying to run.
May be you missed to pack MySql jar in your jar.
What error do you get? Its hard to say proper solution with the information you have provided.

How do i read from database with J2ME?

I am busy with a project that requires me to read from a database and display certain results on mobile(J2ME). For example: I must list all customers in the database (SELECT * FROM CUSTOMERS) and i must display that results on mobile(J2ME). So some how i need to connect the mobile to the database.
How do i go about doing this? I really need help. I'm using Netbeans 6.5 and Postgres database.
Thanks in advance.
You cannot directly - JDBC is not supported on J2ME.
The common way is to expose your database via web services (SOAP, REST, etc.) and connect to those from the J2ME application. BTW, netbeans has a neat tool that generates proxy and j2me client library to j2me devices (arrives with the mobility pack)
You need to use JDBC + PostgreSQL Driver. There is a good tutorial here.
Here here and here are articles about JDBC for J2ME. To be frank, I've never use JDBC on J2ME. I just used them separately. So try it yourself.
I gotta go to work now so good luck. :D

Categories

Resources