Thursday, May 12, 2016

#504 JCS / DB CS --> Lifting and shifting a web app from on-prem to Oracle PaaS

A short post to show how easy it is to lift and shift a web app from on-prem to the Oracle Cloud.

My on-prem app is very basic, simply a servlet that calls my local Oracle DB.
The servlet calls a helper class, CallDB().
Here is an extract from that class.
As you can see, I have hard coded the connect info -

connection = DriverManager.getConnection("
jdbc:oracle:thin:@localhost:1521:xe", "system", "welcome1");

 


Here is an extract from the servlet - As you can see, I am simply executing

SELECT TO_CHAR(SYSDATE) FROM DUAL;












I run this from JDeveloper, the servlet is deployed to the integrated weblogic server.










Now how do I lift and shift this to JCS and DB CS?

Very easy -

Step 1 - Amend the connect string in the helper class to point to my DBCS environment.
Here is the format of the connect string -

 connection = DriverManager.getConnection("
jdbc:oracle:thin:@YourMachine:1521/YourDB", "YourDBUser", "YourPwd");

So how did I get the connect string for my DB CS instance?

I worked the above out by looking at one of the datasources
already defined in my JCS instance, and just extrapolated from that.

















Just take the URL from above.

So that's it!

















You can, of course, validate the string by sshing into the DB CS VM.

Then go to the /network/admin directory and check tnsnames.ora.


Step 2 - Package up the web app as a WAR file.

Step 3 - Deploy the WAR file via the JCS WLS console - just
select option from the hamburger menu.














































As you can see, I have already deployed my SimpleJDBCDemo app.

I have deployed to the admin server and manager server on JCS.

Step 4. Test using the public ip address of the JCS VM.









We can check the weblogic log files for the output messages from CallDB()
ssh into the WLS vm.

sudo su -oracle

Navigate down the WLS directory structure -













tail -f NCJCS_do_adminserver.out

Re-execute the servlet - and view the messages in the .out file -






Great stuff!

No comments: