Deploying java web apps with databases - java

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!

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.

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....

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

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:
for JDK 8: http://docs.oracle.com/javase/8/docs/technotes/guides/install/linux_jdk.html
for Apache Tomcat 7: http://tomcat.apache.org/tomcat-7.0-doc/setup.html
for MySQL 5.6: https://dev.mysql.com/doc/refman/5.6/en/linux-installation.html
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

Related

WebLogic on Virtual Machine/Eclipse Runtime Environment

I have a virtual machine that I successfully installed WebLogic on. My idea is to create a Dynamic Web application in Eclipse, export it to a .war file and transfer it to the virtual machine(Win. Server 2019) that is running WebLogic. The problem I have encountered is that because of the fact I don't have WebLogic on my host, I can't create a runtime environment in Eclipse for it. If I have a runtime environment that isn't WebLogic will it matter if I'm simply converting it to a .war file? Or should I not be lazy and download and configure WebLogic on my host.
P.S. My application connects to a MySQL database, will it be able to access that database when moved over to the Windows Server 2019 virtual machine in Virtual Box.
Do you really need to use WebLogic for this? If you're building a conventional war-file based application, it's much more effective to just use Tomcat for this, which you would have no trouble running on your host.

Remote Apache Tomcat Configuration on IntelliJ Idea

I'M Using DigitalOcean Server with Debian 9, in this server, I installed Apache tomcat, JVM, PostgreSQL
I developed one project on my own machine (Macbook Air) and it is run on the IntelliJ Idea,
I just want to try it by using Remote Debian 9 Server. not on my own machine.
Remote machine is allows to using SFTP, i added it and tested so connection is okay. But Apache Tomcat Configuration is not.
Apache Tomcat Error:
https://ibb.co/60nPLyf
SFTP Configuration:
https://ibb.co/G7kBT53
SFTP Test is Okay:
https://ibb.co/j4mmvHQ
And also same thing is happens to Remote PostgreSQL connection,
Default user, database and I'm sure for password because i changed it, Again it says failed.
PostgreSQL error case : https://ibb.co/Fskr1mR

JDBC Connector for MySQL not working in JMeter

As per the problems this person was having;
JDBC Connector not working
I'm running Debian 9.1
I installed Java via the package manager
I added Java to the path in /etc/config & added JAVA_HOME to the path in /etc/environment
I then installed jmeter via the package manager
I then downloaded the mysql-connector-java-5.1.44-bin.jar and copied this to /usr/share/jmeter/lib
But after all this, I still dont get the JDBC connection option under Add->Config Element within JMeter, nor do i get any options for JDBC within JMeter.
Can anyone help me as to what im doing wrong?
While I am new to JMeter, I have successfully run simple "Hello World" HTTP requests queried from a PHP Script & a NodeJS script so far.
Update
Added JMeter log by request
Jmeter log
I have no idea what the problem was with Jmeter on my Debian machine... (as prior to this I was trying to use it on Ubuntu Server, and it had the same issue as Debian);
But anyway, I just installed the Oracle JDK & JMeter for Windows, on my old Windows 7 laptop, dropped in the JDBC connector to the lib directory - & immediately it had the option for 'JDBC Connection', which never appeared on either the Ubuntu or Debian installs.
So if anyone else runs into this issue on Ubuntu or Debian ~ I might suggest trying a Windows 7 VM for running it.
Note here
This was the JMeter I installed on Windows (I didn't get it from Apache):
JMeter for Windows
For some reason I cannot find JMeter JDBC components either in Debian or in Ubuntu repositories, maybe it wasn't included by maintainers.
So instead of installing JMeter using package manager you can just download the latest JMeter version (which is JMeter 3.2 as of now while in repositories you have much older versions, 2.11/2.13) from the official website. JMeter is pure Java-based application so all you will need to do in order to be able to use it is to install Java 8 or above.
Alternative option would be downloading jmeter-jdbc JAR appropriate to your JMeter version and dropping it under /usr/share/jmeter/lib/ext folder (super-user privileges might be required), this way you will get JDBC test elements.

How to embedd sql in Java application?

I have created an application in Java using eclipse and MySQL using Xampp.I have used a connector.jar to link the same.
How can I create an exe that contains the database(without having to install xampp) and run it on a system where there is no java or sql installed?
You can use Excelsior JET compiler.
Also MySQL is not need to install on client, just include connector jar in exe. Client should able to connect server with firewall on necessary port.

Installing Oracle REST Data Services (ORDS) on Tomcat

I have installed JDK and Tomcat 8 on the server. Now I need to install ORDS and connect it to Tomcat. I went through various documentation and downloaded ORDS on the server. Now I have a couple of questions as all this stuff is new to me and documentation is not very clear most of the time.
There is java.exe in the directory to which I installed JDK and there is java.exe in the directory where all the ORDS files are unzipped. Does it matter which one I use to run the installation?
java -jar ords.war standalone --port 8090
Now my second question is do I run standalone ORDS installation and specify port 8090 and then copy ords.war file into Tomcat diirectory Tomcat/webapp and make sure Tomcat is running and it will install ords on its own? That's where I am confused...
My third question is how do I check if ORDS has been installed correctly? Would going to http://localhost:8090/ords suffice?
P.S. Oracle database installed on another server, I have all the passwords, hostname, port, and service name. APEX is also installed on another server.
Appex is the old name for ORDS. After the ORDS version 3.x you don't need to install apex.
ORDS 3.0 is able to deploy WITHOUT Application Express. It has its own database schema now.
Answers for your questions:
It doesn't matter. But make sure it is java 7+. You can instead install java globally and just run: java -jar ords.war command. You can follow this tutorial to install java on your machine: https://docs.oracle.com/javase/8/docs/technotes/guides/install/install_overview.html
When you run java -jar ords.war command then at this stage it starts installation of ORDS on your system. Before installation it asks for the oracle server hostname, oracle port, SID, and sysdba username and password to connect. Once you provide all the details and the type of installation you want, then it starts installation to the specific database server. Your tomcat/WLS/glassfish server will act as a rest endpoint between the database server and the clients.
Once installed ORDS on your database, if you right click on your connection in SQL Developer then you can see the Rest Service options. And yes the other way is like you mentioned: http:<host-name>:<port-name>/<schema-alias>/<object-alias>/ and see the result.
If you want to know the detail architecture, I would suggest to follow this oracle document: http://www.oracle.com/technetwork/developer-tools/rest-data-services/overview/index.html
I have recently installed the ORDS in production environment successfully. Actually there are two ways you can install ORDS:
Standalone mode:
Using sql developer you can easily configure the standalone mode: http://www.thatjeffsmith.com/archive/2015/04/deploying-oracle-rest-data-services-from-oracle-sql-developer/
But if you would like to use the terminal you can use the following steps:
https://oracle-base.com/articles/misc/oracle-rest-data-services-ords-standalone-mode
Advanced mode:
https://oracle-base.com/articles/misc/oracle-rest-data-services-ords-3-installation-on-tomcat-7.
In the advanced mode ORDS supports Tomcat, WebLogic, and Glassfish application servers
When to use which:
Use Advanced Mode for production
Use Standalone Mode for Development and Testing. You can use Advanced Mode for development and testing but since the standalone mode is quite easy for installation, it is recommended one.
For querying:
http://www.toadworld.com/platforms/oracle/w/wiki/11471.more-oracle-rest-data-services-features
https://svgonugu.com/2015/11/21/adf-bc-rest-services-i/
Note: If your database is PDB you could have some problem installing it and there are some tricks to solve it depending on the problem. Please let me know I would love to answer.

Categories

Resources