Skip to content

Latest commit

 

History

History
35 lines (19 loc) · 3.27 KB

File metadata and controls

35 lines (19 loc) · 3.27 KB

WebLogicServer Java Servlet

The Oracle JDBC drivers allow Java applications to connect and process data in the Oracle Database. Oracle WebLogic Server is the application server for building and deploying enterprise Java EE applications. This repository has code samples for a Java Servlet that connects to the Oracle Database using the Oracle JDBC driver. We have furnished build.xml to compile the servlet and the Readme.md that has instructions to compile and deploy this servlet on WebLogic Server. If you have subscribed to any Oracle Database Service on Cloud such as DBCS, EECS, BMCS etc., follow these instructions to verify the connectivity with WebLogic Server.

What you need to install?

  • Web Logic Server v12.2.1.2: Download and install the WebLogic Server v12.2.1.2
  • Apache Ant: Make sure you have Apache ANT to compile the source code
  • JDBC driver: You can choose to use the JDBC driver (ojdbc7.jar) that is shipped with WebLogicServer v 12.2.1.2 or you can download and use the latest ojdbc8.jar from OTN
  • Oracle Database: You need to have a working Oracle Database with the credentials to verify the successful connection. Make sure either you have subscribed to Oracle Database Service on Cloud (DBCS, EECS, BMCS, ExaCS) or installed an Oracle Database on premise.

Steps to compile the Java Servlet

  • Update build.xml: Download the build.xml present in this repository. Update WLS_HOME to point to the location where WebLogic Server is installed.
  • Create a Datasource in WebLogicServer: Create an Oracle Datasource through the admin console. Refer to the blog for more details "Create and Deploy a Java Servlet using WebLogic Server". Let us name this datasource as orcljdbc_ds
  • Update JDBCSample_Servlet: Download the JDBCSample_Servlet from this repository and Update the method getDataSource() to use the correct Oracle datasource name. E.g.,orcljdbc_ds created through admin console.
  • Create the war file: Go to the location where the build.xml is located. Execute the command ant that will compile and also create the JDBCSample.war file in the dist folder.

Steps to deploy and run the Java Servlet

  • Deploy the WAR file: Start the WebLogic Server and open the admin console. Follow the steps in this blog to deploy JDBCSample.war
  • Invoke the Servlet: Invoke the servlet at https://localhost:7001/JDBCSample/JDBCSample_Servlet
  • Check the Results: Check the results on the page and make sure that it prints driver information retrieved from the Oracle database.

Other Resources