Bit confused with SQL and Tomcat - java

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

Related

JavaFx application with database executable

So, i've just finished a small javafX application, with database and stuff... I used Netbeans and SQl developer, now i want to export my project so i can use it anywhere i want; any computer, So, i've tried some programs like Launch4j or something... but the main problem is, even if i make the .exe file, what's gonna happen with the database? it's located in my PC, so if somebody try to use my application, he can't access to the database, so the application won't work...
In other words...What is the solution that i can use to like "Combine" the database with the application, if it is possible? or create the .exe file with the database... I hope that my problem is clear, and thank you for your answers .
as per my understanding you can do two things.
You can deploy or host your database to any online server and create some web services to fetch and insert data to your application.
You can create one startup class to create database but here you need to use lite version of database like sql-lite.
if you need more information about sql lite then click here

How to allow other people to use desktop application that relies on database?

So I've created a java desktop application using Swing. It stores data entered into the application in a MySQL database (localhost). Now how would someone else be able to use the application ? Would they require a MySQL database as well ? What are the best practices for doing this. I do eventually hope to submit the entire project folder to github.
I guess I would have to ask first whether this program is a demo or classroom project or if it's a real application, because the answer would be different.
For a demo project, it would be fine to post your code to github, and also dump the database to a .sql file and commit that as well. MySQL ships with a handy tool called mysqldump that will do just that - export the entire contents of your database. Then a person can clone your github repo, install MySQL locally, and run your sql script to get a copy of your database. Once they follow those steps, they should be able to run a copy of your swing app on their machine just like you can. One caveat here though is it's best practice to avoid putting very large files (especially binary files) in git. I'm not sure what you need, but if you can put a small sql file out there that's definitely preferred.
That's a segue into the other answer which is hosting your MySQL database somewhere. For a real application, making copies just won't do. Then what you need to do is host your database centrally using a service like this one and allow your users to connect to it. You can still use mysqldump to get your database out there on the web after creating it on localhost. If you go this route though, you'll definitely want to avoid putting your database connection strings on github. Again, this scenario is really only useful if your app is intended to be used for real - don't bother with hosting if you don't need it.
Hope this helps!
Firstly, you should install mysql with a public ip, then alter the connection to mysql with the ip,the example follows below
String url = "jdbc:mysql://ip:3306/db";
Connection conn = DriverManager.getConnection(url, user, password);
if you want to run java program like exe file, package the java program to a jar file with jre

How do you send NetBeans Java Project with Database to .exe?

[I know this question has been asked here and here, but I don't quite understand the answers, and I didn't want to ask questions on old threads.]
Problem:
I have a project that I created in NetBeans (7.01), and I created a database to go with it using Java DB. I would like to have a .exe file that I can run on any computer, so that when someone clicks it, the program runs like it should (establish the connection with the db, run the rest of the Java code).
What I know:
After a little reading, I see that if I didn't have the DB, the executable that I am looking for would really just be the .jar file. I also found that I needed to create an embedded db which in part means that I need to change the URL from jdbc:derby://localhost... to something different (but I'm not sure what something should be. Just a path to the source code files perhaps with the db information?).
Question:
I have a bunch of pieces (not sure if they're all right), but I am not sure how to put them all together. Could someone let me know how to create an embedded DB and send that, and the rest of the program, to an .exe?
Thanks in advance!

Database linked with Java program without server

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.

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.

Categories