How can I allow other computers to access my programm's database? - java

I have a java application that I programmed, and I also created a Wampserver database to store the app's data. When I install the application in another computer, it basically can't do anything because wampserver isn't installed on that computer, and even if it was, the database wouldn't be imported on that same computer.
Can I install the database with the program itself, without making a database server in my computer? (For security reasons)
Sorry if this is a dumb question, im new to programming.

Assuming you are doing this in a Home/office environment. Where your IP Addresses do not change so often. Or you have the power to assign them statically.
You could try using a multi-threaded client server model. Where your wampserver computer(server) will accept a connection from another computer(client), and from there any queries to the database will be handled by that thread. This way, you could get away without installing wampserver on every client.
It would require some networking codes to be added to your java program. There are many examples on multi-threaded client server model -> Multithreading with client server program

You can open your MySQL server to the outside world or to certain IP (comment or edit bind value in your MySQL configuration file).
This can be a security issue. What is your objective? Usually, you'd do an API allowing access to your data from your application.

You are talking about "hosting" your database. You need to either:
Create, develop, and run a hosting service (not trivial), or
Pay to one the myriad of hosting services available, and install your database there (cheap these days). Just a couple of well known examples: Digital Ocean or Amazon Web Services.
In any case, it's a huge security risk to open your database to any client online.
Normally you write a program/application that accesses the database in the same [local] network, and that application serves web pages (or other web service) to the world.

Related

How to make a local test server for an android app?

I basically need to create a test server, something that I can use locally to perform tasks for my application.
So my android app is basically a search engine, however the search queries will be made on the server and the results then fetched from the server on the mobile device as JSON objects.
Is there any way to replicate this functionality locally? I would just like to set up a server, include the Spring framework, the Google Custom Search API and develop it all in Java, then ship it to a live server directly when it's finished. (Most presumably a free tier Amazon AWS server, either EC2 or Lambda, not sure what the difference is).
Not quite sure where or how to get started so any help is appreciated, thank you!
p.s. I may try dabbling in some machine learning at a later date, but I don't know if this will affect anything, this will most likely be after I've got a live server up and running.
EDIT: Sorry, so how would I fetch data from a local server from my mobile device? Do I need special software? Do I need to configure a local server? How can my mobile device fetch data from a second project when its being run on the first?
My app will fetch data from a server, so how can I create a dummy server, for it to fetch data from? Will I need to create a fully functioning online server, or can this just be done through creating a local server of some sort and then simply plugging my android device in and running the code? I have absolutely no idea how to test it without putting it online.
You can run a local installation of Tomcat server on your own machine.
Access the server by visiting "http://localhost:8080/" (or) http://127.0.0.1:8080". You can basically listening to your own local machine / host's 8080 port. Sometimes, it could be port 80 instead of 8080.
Please explore on how to host a Spring or Java application on a local server.
A good starting point would be to learn J2EE or Enterprise Java. You can configure Databases from your local installation.
If you opt for PHP as your language on server side, there is a pre-defined package called WAMP (for Windows), LAMP (for Linux), MAMP (for MAC) and XAMPP.
The above package are nothing but a package which contains a Server, Database and a Server side language usually PHP, if needed Python or Perl.
Please explain in which step you are getting issues so that anyone can help you exactly.

Host MySQL on a shared folder

I am trying to host MySQL Database on the shared location of the organization.
Is there any way through which I can achieve this because I don't have a shared server which will run all the time.
MySQL is a "client-server" database management system (like Microsoft SQL Server, PostgreSQL, Oracle, etc.) so it requires a server on which the centralized database management application (the "database server") can run. The client software for such databases can only "talk to" the application running on the server, and the server application updates the database file(s); the clients cannot update the database file(s) directly.
By contrast, a "peer-to-peer" (sometimes called a "shared-file") database like Microsoft Access does not have a centralized database application. Instead, each client machine has a copy of the database engine that can update the database file(s) directly in a co-operative fashion.
So, you cannot use MySQL without having a MySQL database server running somewhere. As for a peer-to-peer solution, refer to your previous question here.
While I understand what you are doing it is simply a very bad idea and cannot be made to work. Much of the purpose of a DBMS system (like mySQL) is to handle concurrent access to the data responsibly.
The basic idea of the architecture is to talk (in small messages) to a server software stack that can rapidly access its files and grab the data you need and send it back to you. This server software stack does two things:
Negotiates that clients looking at the same data all see a consistent meaningful picture of the data
Does all the searching, sorting, indexing etc on the server without sending all this data back and forth across the network.
So if you are using MySQL shared between different client machines you need to have the mysql server running ONCE on the server (as opposed to running on each client accessing a shared drive as you suggest).

Connecting Access Databases remotely?

Currently I have a Java application which performs all I wanted and the limitation
in it is "It only resides on the Local machine for which it needs to work". I have the Access Databases located on a Remote Server and I install the Java app on the remote server to connect the databases using a connection string jdbc:odbc:DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=D:\\DATA\\DPPI\\DATA\\DPPI\\DPPIPR01.mdb;
It connects to Access Databases and do all the business logic with them.
Enhancements (to be done):
Making the application online - not a big issue.
Connecting the databases remotely - its the only concern.
If I make the Application Online the Access Databases need to be connecting through network (somewhat like IP or some web address).
Problem:
But after going through this Connect to Access database remotely It seems my requirement can not be completed.
Is there any way if I'm able to upload the database to the online web hosting server and access the database from there only? If yes, then how should I do the connectivity since Access Database connects by giving the fully qualified name containing drive letter and all.
But how should I proceed further so that I may be able to connect the mdb Databases remotely?
ADO Solution:
But after going through the link: http://webcheatsheet.com/ASP/access_connection_strings.php, it seems we can perform remote Access Database connectivity.
The solution for the ADO is something like:
connectionString="Provider=MS Remote; Remote Server=http://your_remote_server_ip;" &_
"Remote Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:\your_database_name.mdb"
I'm a tad confused to how Access Database we can connect.
There is one more question in my head.
I'm making use of Type-1 Driver. Should the Type-4 Driver support the remote connectivity?
If your application is a server side application (like a web application) and your server's OS is Windows then theoretically it is possible to use your Access database. In this scenario, the Access database is local to your application. In your connection string you can simply use the path to the Access database inside your server's file system.
But keep in mind, that Access is a desktop database not made to use it as a server database. This can lead to poor performance and maybe system crashes. And it is possible that there are some licencing issues for this use case.
So even it may be possible to use Access with a server application it is strongly recommended to use a real server database like MySQL, MS SQL Server, etc. Even an embedded database like Apache Derby or H2 would be a better fit.
If your application runs at client side like a fat client, then your only chance to use Access is to put it on a network filesystem, so it is visible from every client. But this works only inside a LAN. If you cannot put it on a network filesystem then you have to use a real server database.
Do not use Provider=MS Remote (RDS) for new development. Here is a quote from the MSDN article
Microsoft OLE DB Remoting Provider (ADO Service Provider)
Important
Beginning with Windows 8 and Windows Server 2012, RDS server components are no longer included in the Windows operating system (see Windows 8 and Windows Server 2012 Compatibility Cookbook for more detail). RDS client components will be removed in a future version of Windows. Avoid using this feature in new development work, and plan to modify applications that currently use this feature. Applications that use RDS should migrate to WCF Data Service.
As others have suggested, you should seriously consider using a different back-end database for this particular application.
What if I'm able to call another java application residing on the Server housing the Microsoft Access Databases? Can you please let me know if it can be the solution such that I will have the division of my application into two:
1. The Online java Application performing 2 things: Accepting the requests coming in and waiting for the response to come from another application running on the Server housing the Microsoft Access Databases.
2. The Java application installed on the Server housing the Microsoft Access Databases only responsible for connecting and returning the DTO (Data Transfer Objects) -or some kind of objects in Collections.
So, I would expect a serverside program to handle the communication with the DB and the client application would communicate with the server app.
Please let me know if I should proceed in this manner.
it can be done by marking the traffic and queueing the traffic from the server---to----remote site ---(QOS..quality of service ) .....the two sites will be connected through VPN methods to reduce the unnecessary hops that will improve the latency plus add the security , thus server and remote site will logically act as if they are on the same network (LAN)
regards ,
Ali Rehan

How to access a remote mysql database using java

I have already developed a JAVA SWING Application. I want to install this application in several computers which all have access to internet .
So where should I place my MYSQL Database ? All these computers should have the ability to access the same database via the internet.
It's not very common to allow access to a database directly over the internet for security (authentication authorization, encryption) and performance reasons. In most cases, you would create a web-based server application which can perform database operations, enforcing business, domain, and security rules. The client application makes calls over the internet (using REST calls, AJAX calls, or something proprietary), and gets the results back from the server.
In your case, since your client software is Java, you may want to research Java Servlets and run something lightweight like Tomcat as a serer.
Please see this page and this page for an explanation of client-server relationships.
Put your database in host that is accessable by Internet.
For each of the external ip addresses of each of the Applicaton host create a user on mysql.
GRANT ALL PRIVILEGES TO database.* to `user1`#`APPLICATION_HOST_IP` identified by 'PASSWORD';
Now user1 will have access from APPLICATION_HOST_IP IP.
Well the possibility is limitless.. You can place it on every computer that is accessible by the others. As long as you can acces the database via network it does not really matter where it is. But if the Computers with your client Swing are all connected in LAN, than store the DB on the computer with best Performance.
As a tip use the IP, and port dynamicaly from text or entry, so u do not recompile every time u change the IP.
Chiers!!

Network communication between dedicated web and database server

We're at the juncture (I can even say, right time) that we need to separate our database server apart from our application web server. This we arrived at after careful & thorough monitoring of the server (load average, CPU usage, etc.) itself.
When the database server is separated:
What would be the ideal setup/best practice for network communication path between 2 servers? If it were running on the same server, connectivity between database and application would make use of TCP/IP communication, but how it should be running/setup when it is separated, so that performance is not majorly affected? For example, currently our JDBC URL looks like jdbc:postgresql://localhost:9999/ourproductiondb, probably this localhost would be changed to private IP address of the database server.
In our application, we also allow application users to submit/attach attachments (.txt, .doc, .pdf, .xls, etc.), which are actually stored physically in server disk and only its file path is stored in the database. Which is the ideal place/approach for maintaining/keeping documents physically, either in application web server or in database server?
We're very new into this area of separating database as a separate server and our knowledge on this is very limited. Therefore, any resources, links, documentation, articles, guidelines, suggestion etc. in this regard are highly welcome and really appreciated.
NOTE: Our tools of trade are: RHEL5 64-bit, Apache Tomcat 6.0.10, JDK 1.6, PostgreSQL 8.2.22, pgpool 2.0.1
I received a response for this very same question after posting in serverfault. Here is the answer. Am posting this as an answer here with the hope that this may be useful for other users who might have similar kind of question.

Categories

Resources