Connecting your application with database - java

I'm pretty beginner with AndroidStudio and java, I know the basics and some additional stuff and how generally java works but.
...creating applications from nothing in java is hard ._.
What I would like to do is :
-I have created a database on my personal computer with the data I need (id, logins and passwords)
I would like to make a very simple app in AndroidStudio, that's important, that would check login and password and display success on login and fail if fail.
I have already created a php script and put it into a simple html website, everything works perfectly but when it comes to an application....oof.
tl;dr
I would need help how to make a simple login system in AndroidStudio and would use the app to log in to my database on my pc (both connected to same network)
Thanks for reading.

an easy begginer approach will be to first add apache dependency in your app:module file then make http requests. Check this sample. https://www.learn2crack.com/2016/04/android-login-registration-php-mysql-client.html

Related

How to store or any way to connect to mysql database with java

I have have a BIG problem in the past few days. I'm developing an application for a customer and I have an external database in the web. In the program there are a login and some modules. At the time I store the data for access to the DB hardcoded in the Java code. Of course this is not a way to store those data.
Then I was searching so much to find out a way to connect to the database.
Store the password in a properties (.xml) file on the PC
Encrypt the password
etc.
But all of this is not really secure. Then I found something good. "Three-Tier Application Server" sounds really good and a possible way that I don't have to save the data on the PC. But I read everytime how a Three-Tier server works, but nowhere how to develop something like this in java. And is there a possibility that a hacker write an application that connects to this server too and get all of the data, because he decompile the application and get the access data?
Thanks for help
There are indeed many ways you can go about this.
The best way is to have the authentication checks spread throughout your code to where it would be very hard to remove them.
Have the authentication with SHA256/512 and or MD5 and have the user send a login request to the server.
Only authenticate the user if the server responds that it is registered.
Do not store any information other than the users info on the client end.
All the checks should be made and validated on the server side.
You also most definitely want to obfuscate your client sided code as well.

Error connecting from GAppEngine servlet to GoogleCloud MySQL only at first try

Description:
Greetings, I have a Google App Engine standard web service deployed from Eclipse Oxygen that consists of a servlet connecting to a MySQL database with the same project id in the Google Cloud using hibernate. It is a simple event managing website where you (as an invitee) enter your email and a given code (don't worry about security at least here, please) and you confirm or cancel your assistance to a given event.
Error:
The error is the following, at localhost, the tested project will perform correctly on every connection and transference of data. But as soon as I deploy it, when I test it from the user side, on the first try (wether you confirm, cancel or enter invalid data) it will fail to connect to the database. If you redo the operation, it will work.
Information to take into account:
I did not use the JDBC GoogleDriver (as I couldn't find a way to make it work [ClassNotFoundException...]). I use "com.mysql.jdbc.Driver".
The database allows the IP 0.0.0.0/0 (everyone) to connect to it (I know, security issues).
The servlet access the database with root + password (more security issues...).
When the user confirms/cancels the servlet will ask the Business class instance to retrieve the user data to check if it pairs it's invitation code.
Notice:
I have no idea how is this happening. Please, ask me for the details you need, and I will edit this question with them, because I don't know where to start. I'm pretty sure this first-try-only pattern must be easily identifiable to anyone who had experienced this. Thank you very much.
When thing is running correctly on localhost then obviously Google Cloud has specific issue. Google Cloud's 0.0.0.0/0 is not really "whole earth". You have to add subnet from which you'll connect. That much I know.
Better you can test on some PaaS like Bluemix. Bluemix has own big Q&A - developer.ibm.com/answers/ plus StackOverflow.
Of course you can use VPS as other option than PaaS. Essentially you need to run an application NOT fight with some platform.

Access SQLite datatabase remotely through java app

Im working with a SQLite database right now, and I've made a javaFX application (I will call it the client) that allows me to work with it, but I need to work with it remotely as well. From what I've read SQLite does not support remote acces, so I have 2 choices:
Creating another application in the server that receives input from the client through a socket, and it modifies the SQLite database. (The problem with this, is that the server is a webserver and I dont have SSH access, so I can upload the server side application on the server, but I cant start it...)
(I dont know if this works) Create a java application that runs on the server, and you load it through a browser such as chrome or firefox. From what I've seen java webstart allows you that, but I don't if the app runs on the server or on your computer (meaning that you won't have acces to the SQLite database as well).
If someone here has some knowledge on this pls share, I need to know if I can make this work, and if not, what other options I have.
I don't think SQLite is designed for that. If you use SQLite because it's small and easy, why don't you try JavaDB (derby), it is included in your JDK distribution and you can use it embedded in your app or as a database server (not both of course).

Java creating server that is ran as one file with database?

I have a program that I've created that is meant to poll an html internal page with different IPs that update and then will run a telnet session to those IPs to see if the device still has a connection... I'm attempting to challenge myself in creating something further with a dynamic webpage instead of my program spitting out console output...
My Issue:
I dont know what technologies / libraries Java has to execute such things
I want:
A Local Server, to upload a page LOCALLY only (no security is needed as this will be strictly intranet)
My program to implement: A database of sorts to save "logs" essentially that a certain IP / device has had successful connections
in the past....maybe stored to an external file is fine i presume (my
program currently has to re-poll everytime i run it.. i want some kind
of "remembering"..
Is it possible this can all be done in one file? so if i want my computer to run this as soon as it starts up... it will run... grab
its current state of the database of IPs... poll them (periodically)
and then persist and save and update the HTML page dynamically....
I hope i'm being as descriptive as possible... Its a bit of an abstract.. I really just want some introduction to different libraries ... a friend recommended stuff like MongoDB or something but I want to stay strictly to Java programming

Android APP + SQL

I've already read, that there is not so simple, to connect directly from Android APP (Java code) to some SQL on the server (for example MySQL etc.) on the Internet.
I would be very happy, that some one could explain to me that question. Maybe simpler way, it would be create only some web page (on JSF, ASP.NET etc.)... although I would prefer native APP. There should be login in, and then, only after correctly login, instering (INSERT INTO...) data and downloading (SELECT...) data.
Try how-to-connect-android-with-php-mysql and also android-login-and-registration-with-php-mysql-and-sqlite.

Categories