Database linked with Java program without server - java

I have this java program that reads values from a database, and uses those values in each table for creating a schedule.
I do not have a server accessible, so the database will have to be moved around from computer to computer when the program is moved. It will have about 200 tables, each one with a time, number, title, and description.
I have tried using Microsoft Access, but Java 8 just changed some setting so that the program cannot link the Access database, even though there used to be a simple way to do this.
I know about Java DB, but to my knowledge it needs a server to host the database on, same with SQL, and I do not have one to use.
My question is, which program can I use to create a client-side database that can be linked with a java program, without breaking off an arm and a leg.
Thank You for any suggestions.

Related

Could I generate a UID based on system specifications in Java?

I am working on a MMORPG game built in java, with this the end user runs a java executable (client) on their system that connects to our game (server).
Sometimes you get some players that are less than nice, and require a ban, some people are however really persistant which require an IP ban, and then there is the third type of people that have above average knowledge of computers and know how to change (or mask using vpn/proxies) their IP.
To combat these last kinds of people, we used to generate a UID file somewhere in their AppData folder with a unique key generated when the client launches (if no file is found it will generate one for them, but the flaw here is that if someone finds this file, they could easily just remove it and on the next start it would recreate a new and different one for them)
A while back I read somewhere that Microsoft generates a "fingerprint" based on several system specifications which is pretty much unique for each system, but on regeneration will result the same key, this is why you can reinstall Windows 10 without ever having to use any serial key. Would a system like this be possible in pure java?
To summarize, we need a unique key for every machine it is being run on (or atleast a very very small chance of a duplicate key being generated), but should the generation code be run again it needs to generate the same key

Synchronize embedded DB with remote DB

At the moment, I have a little JavaFX app that generates reports and statistics from the data on a remote MySQL-Server. I use EclipseLink for persistence. Since the access is read-only and the data doesn´t always need to be fresh, I thought I could speed things up by using an embedded DB (H2) that can be synchronized to the remote server when and if the user wishes to. The problem is, I don´t have a clue how to go about it.
What I came up with so far, is to execute mysqldump, make a dump of the remote server and execute the resulting SQL script locally. This is surely far from elegant, so: Is there a patent solution for this task?
Well, 50 tables possible have a considerable amount of relations, this can be tricky... As far as I know there is nothing that automate this for you or something like that. Very possible that you will have to create your own logic to that. When I did something like what are you trying to do I used the logic of "last update", like, the local data have the timestamp of the time it was last synced with the remote, and the remote data have the timestamp of the last time the data was updated there (himself on the table, or even a relation to it like a One-To-One). Having that data, every time the local user enter a part of the system that can be outdated, the client connect to the server and check if the last update timestamp is bigger that the local synced timestamp, if so, it updates the full object and relation. I consumed some time to develop but at the end worked like a charm. There may be some other way to do it, but this was the way I found at the time. Hope it helps you with your problem.

Bit confused with SQL and Tomcat

I have a huge confusion with SQL and Tomcat. You see Ive an assignment where Ive to create a WebApp (JSP) using a java class. I already did this, its a Matrix calculator that is working perfectly fine. Now I need to make a Database to store the users that log in, the type of Matrix operation they used (Sum, Substract etc), make new accounts for this users and also have a admin user. I really don't know where to start, how to connect the Database to Tomcat or is it to the Java class or the JSP? Where can I do this, use Netbeans? I read something about a driver to install but like I really don't know what it means to install it, like where and to what program.
I'm using Linux as this is what I was told to use, I'm sorry if this is too much to ask. But really my teacher just gave us an example of how to write the tables of the Database as well as the types of variables and how to edit the tables. But the rest for me is unknown. Main question is where do I start?
At first you need a database.
Maybe you want to start with MySQL: http://www.vogella.com/tutorials/MySQL/article.html
After you created a database you can connect to this database via java: http://www.vogella.com/tutorials/MySQLJava/article.html

Android App Connecting to Database Remotely

I'm not new to Java or databases, but I am new to Android app development. I have an app idea and have started to put it together. It's a very simple game that I would eventually like to have multiplayer capabilities.
The part of this process that I am pretty clueless about is the backend portion of the application. I need a database that will store things like usernames and passwords, scores, and things of that sort. I will also need to store things that I will need for the game in here. The application will rely very much on the database and it is important that any device has access to it and they are all looking at the same data.
If I've done my research right, this means that a simple SQL Lite database on the device itself isn't going to help me. Ideally, I would use SQL Server and create the database, as that's what I use for other projects... but I have no idea if this is possible or ideal.
I really just need somebody to steer me in the right direction here. I want something simple that can be accessed easily by any device at any time.
You'll want to write a server application which the various clients connect to. This server would be responsible for processing information given to it by clients and returning appropriate data back.
Exposing the database directly would be unwise; it would allow inventive players to cheat your system (or worse!) because they would have unfettered access to anything your application does. Your own server application can ensure that only reasonable access to the data store is permitted.
As for how you implement it, there are any number of choices. Web services are popular these days (in which case ASP.NET is the likely fit with SQL Server), but you can implement your own, non-HTTP, game protocol if you'd like.
You could access remote SQL database from Adnroid app using JDBC.
I've provided example here: How to save image files to mysql with sql code and how to display them with java?
The only difference I've encountered using JDBC in desktop and android apps that in Android You have to perform JDBC operations in a separate thread, like any other network operation in Android.

Backup and Restore MS SQL Server database through Java Program

I have developed an Java Swing Application with MS-SQL Server database and now i want to provide backup and restore option in my java swing application that is on click of a button it should backup the database and restore the database any possibilities of how can i do it through java. please help
Two ways to do that. Backup and restore are just sql commands so you'd do them just the same as as you'd do any other bit of sql, e.g. a sql insert statement, unfortunately you need to know a fair bit about the the system to just do them, and you'll get no progress indicator. Using SQLSMO is another possibility, not sure about hitting a .net dll from java though. You could use SQLDMO (pre.net), but you'll need to install the backwards compatibility tools, and you'll give yourself an upgrade headache as DMO (while it seems to work) is not supported from SQL2012. Both have an event you can tick a progress bar on, course if the back up is fairly quick you could get away with not bothering with that.
However, some more to think about. You can backup while the system is running, but then you'd don't have a clear point where the system was at when you did.
Restore requires exclusive access and a high level of privilege, so it's not something you hand out and you need to get everybody off the databases.
And last but far from least it would be very bad, if you inadvertently restored a version of the database that no longer matched the application....
Personally I'd say the people who were authorised to do this should be able to do it without your tool. Dumbing it down, means a lot of code to make sure they don't restore a sql2000 back up from the trial you put out eight versions ago.
We did something similar back up restore code is a bout 2% of the application. For instance we do a pre-backup check, using dbcc et al, to make sure they aren't successfully backing up a corrupt db...
You can write a simple script to backup your database and invoke it from java.
You really need to put a little effort in here.
Since you can connect to the database server already and send it SQL commands, read this for backing up using TSQL.
For database restore, read this.
You need to have the appropriate permissions and access to the hardware for this to work.

Categories