Databases sync through webservice - java

I Do not know much about it, but I have a question and I hope you can help me if it is possible.
I need to synchronize two databases, one is a mobile database (SQL Server Compact) and the other a MySQL database. Both have exactly the same tables.
Then, is it possible to synchronize the records via a webservice?
I accept any ideas, suggestions or help.
Many greetings and thanks.
pd: sorry about my english... :)

Have a look at SymmetricDS. It runs as a webservice (tomcat6) and is able to do both one and two way synchronization. It also supports the concept of a single root node and several client nodes.
SymmetridDS is database "transparent", meaning that it can synchronize between databases independent of database type.
It's quick, stable and reliable. The learning curve might be a bit steep when you first dive into it, but it is quite a piece of software once you get the hang of it!

yes.
you need to create a piece of code that can connect to both databases at the same time.
you need to then read them and decide what is different between the two,
then you need to apply changes that make one look more like the other (non-trivial).
You will need to decide which one should be the master, or if both should modify the other somehow.

Related

A system using Java + SQL Server 2014 (How to write a clean and manageable system)

I'm currently working on a small project for a tuition centre.
So, I'm actually taking this chance to learn how to write clean and manageable codes as well.
I've setup my database using the SQL Server 2014 and have decided to use Stored Procedures for my operation calls.
What I wish to know are about the Java codes.
What are the best practices to be applied in writing them? How to actually separate the business layers / views / etc. so that I can partition the codes and perform my maintenance in an easier manner?
I need some inputs from a technical perspective.
Thank you very much :)
Have a nice day guys!
Modularize, object oriented design, service oriented architecture, onion architecture, APIs... There is a huge list of best-practices/architectures/designs which can help with this. There is no one-size-fits-all solution. This question is too broad to even start giving you a specific architectural solution.
Stored procedures do NOT solve these issues, stored procedures are a very specific technology that is appropriate for very specific use cases. If you do not understand EXACTLY why you need to use stored procedures, you should not be using them. Parameterize your queries, use prepared statements, use a layered architecture, and use an ORM if you are not a strong SQL developer (maybe even if you are strong)...

Data management in MMORPG

I'm planning to write in JAVA simple, but easy to develop in future MMORPG. I know more or less how it should looks like, but I have some questions:
Which kind of data should have client? I know that, for example, server informs client if "that field" is free or not, but what about loading map? Client contains sprites etc., but should they also have map files or server should tell client where is the grass and where is water etc...
How to keep data by server? Players should be represented as files in one folder where server have to find right file, open it, get data and send it back for many players? Maybe database server + database + sql would be better idea?
Any ideas/knowledge about MMORPG structure?
Is Java a good choice for 2D MMORPG?
MMO's are not easy programs to develop. It sometimes takes experienced teams years to develop one, and the questions you ask here don't seem to indicate you are a very experienced programmer. Having said that, I would suggest taking a look here:
http://slick.ninjacave.com/
http://www.13thmonkey.org/~boris/jgame/
These resources might be good starting points and get you up to speed quickly, but I'd suggest looking for a good tutorial on how to sync client/server data, en get a bit up to speed on programming Java in general.
I developed Browsergames in the past. Usually it is a good idea to put "static" data (data that doesn't change very often, like map layouts) into the client, so that you don't need to resend it every time.
I would definitly prefer a database (some sql or nosql) to file-based storage. If you wan't to improve you coding skills and make them more marketable than definitly go for a database.
If you really want to release a simple game, than I would go for html5 as frontend. The graphic capabilities of JAVA a pretty limited. Also nearly nobody would download your game prior to playing it.

Distributed synchronized execution

I'm trying to accomplish something that in terms of concept is very simple to understand. I want to synchronize a block of java code between different machines. There are two instances of a programa running in different machines that cannot run at the same time.
I've heard of zookeeper, jgroups and akka too, but while reading the documentation it seemed to me a bit overkill for what I'm trying to do. Does anyone have any idea if there's anything more straight forward to use?
Thanks in advance,
Rui
I think Hazelcast's Distributed Lock ( http://docs.hazelcast.org/docs/3.6/manual/html-single/index.html#lock ) may be helpful. Hazelcast is relatively lightweight so should hopefully not be overkill.
If all the technologies you mentioned (also take a look at Terracotta) are too sophisticated for your needs, maybe simple database locking?
SELECT FOR UPDATE statement will lock given database record, making other clients running this query to block. Simple, yet safe and reliable.
A very very basic solution would be using RMI.
Decide to use one machine as master which has a method which uses a mutex lock to allow only one mthod caller passing.
This special method you have to call via RMI from all other slave instances before you run your special java code block.

Where to store data gathered by applet?

I am writing my first real applet and I need to store some data. I've never really messed with putting and maintaining code on the internet, so please bear with me if I'm a little slow to catch on.
I'm building a Calendar applet for work (just a student worker) and I'm not sure how to store necessary information such as the schedules for certain days and login name and password information. I assume I have access to a server and such, but I don't know exactly what I would traditionally need or what I would need to do with what I need.
In the worst case scenario, I could simply put the information into text files and read them on every start-up where the applet is stored, but that definitely seems like a very wrong way of doing things. Can you guys educate me on a few practical ways people accomplish this in the real world. Any ideas would be greatly appreciated. Options that are free/open source would be best.
Thanks a lot for your help.
For this sort of small application, I would go for SQLite.
How about a relational database such as SQL Server ? Maybe access?

Learning Algorithm and Saving Data in Software

I'm coming from a web-development background and I am wondering how I would make a learning algorithm in Java/C++. Not so much the algorithm part, but making the program "remember" what it learned from the previous day. I would think something like saving a file, but I suspect their might be an easier way. Apologies if this question is just over the top stupid. Thanks.
I think that would depend a bit on the problem domain. You might want to store learned "facts" or "relationships" in a DB so that they can be easily searched. If you are training a neural network, then you'd probably just dump the network state to a file. In general, I think once you have a mechanism that does the learning, the appropriate storage representation will be relatively apparent.
Maybe if you can flesh out your plan on what kind of learning you'd like to implement, people can provide more guidance on what the implementation should look like, including the state storage.
Not stupid, but a little ill-formed maybe.
What you're going to do as your program "learns" something is update the state of some data structure. If you want to retain that state, you need to persist the data structure to some external store. That means translating the data structure to some external formal that you can read back in without loss.
Java provides a straightforward way to do this via the Serializable interface; you Serialize the data by sending Serializable ojects out through an ObjectStream; the same ObjectStream will reload them later.
If you want to access and save large amounts of data maybe a database would work well. This would allow you to structure the data and look it up in an easier manner. I'm not too well versed on the subject but I think for remembering and recalling things a database would be vastly superior to a file system.
A robust/flexible solution in Java (C++ too, but I wouldn't know how) would be using a database. Java 1.6 comes with the Apache derby database which can be embedded in your apps. Using JPA (Java Persistence API) makes it easy to interface with any database you can find drivers for.
You should look into Neural Network software development. Here's a collection of nice Neural Network libraries for different languages. I am not sure if this is the easy way but once accomplished would be very handy.

Categories