user3811115
user3811115

Reputation:

Deploying java web apps with databases

I am making java web apps with JSP's and Servlets. I am deploying them on Tomcat7 and using MySql server 5.6. I have made a functioning web app and want to deploy it on a Linux server(a raspberry pi) running tomcat 7. Here is my problem:

I'm developing on windows. Using mysql 5.6 server database, mysql-connector-java-5.1.35 database driver and specific databases on the server. How can I deploy all this on my Linux server server? How do I successfully port a database on my server without any problems?

Thank you for your help!

Upvotes: 2

Views: 1267

Answers (4)

Forketyfork
Forketyfork

Reputation: 7810

Java compiled application code and mysql-connector-java are cross platform, so there shouldn't be any difference in the code or distribution of your Java application.

There are Linux distributions for JDK, Tomcat and MySQL 5.6, but the installation process may vary depending on what Linux distribution you are using. So you should refer to installation instructions:

When you have installed JDK, Tomcat and MySQL 5.6, you will want to transfer the database structure and data from your Windows machine to Linux. You can do this using the mysqldump command which is described here: https://dev.mysql.com/doc/refman/5.6/en/mysqldump.html

This command is also available for Windows and Linux distribution of MySQL 5.6. So on Windows, to create the dump, you do:

mysqldump -u USERNAME -pPASSWORD DATABASE_NAME > dump.sql

And then on Linux, to import the dump, you do:

mysql -u USERNAME -pPASSWORD DATABASE_NAME < dump.sql

Upvotes: 0

Harsh Poddar
Harsh Poddar

Reputation: 2554

First, make sure you have the same java versions and mysql version installed on your raspberry pi. I use oraclejdk instead of openjdk on my pi as I use the same on my windows. Now create a mysql dump on windows and import it on pi. Now just copy the war to the tomcat and you'll be good to go

Upvotes: 1

Saif Kamaal
Saif Kamaal

Reputation: 202

What is the requirement to load the DB along with the application ? Ideally your DB should be installed/placed/kept isolated from the application.

Still if you still wanna do this thing then you need a build tool to first zip the database along with the my sql connector. Then when you application gets uploaded onto the server you have to unzip the DB files at some location. You have to hardcode the IP/Hostname (connection related parameters) in you EntityManager(DatabaseConnector file).etc.. etc....

Upvotes: 1

Erwin de Gier
Erwin de Gier

Reputation: 662

This is not a problem, install Tomcat7 and MySQL on the Linux server, create a dump from the Windows MySQL server and import it in the Linux MySQL server. The war file with you application can be deployed on the Linux Tomcat7.

Upvotes: 1

Related Questions