Sun. Oct 24th, 2021

Requirement: I have an Oracle database XE. I want to connect to the database using JDBC driver and query the EMPLOYEES table. I want to display the LAST_NAME of the employee having EMPLOYEE_ID=101.

The purpose of this post is to demonstrate how we can establish JDBC connection programmatically without using the wizard provided in JDeveloper.

Solution: For solution to the above requirement follow the steps below:

Step 1: Download the Oracle JDBC Driver (ojdbc6.jar) from the following URL:

http://www.oracle.com/technetwork/database/enterprise-edition/jdbc-112010-090769.html

Step 2: Open JDeveloper and create a Java Desktop Application. Give the application name as “DBDemo“. Give the Project Name as JDBCDemo“.

Step 3: Add ojdbc6.jar in the Libraries and Classpath of the “JDBCDemo’. To add the ojdbc6.jar right click on the JDBCDemo > Select Project Properties > Libraries and Classpath > Add JAR/Directory (Browse and add the ojdbc6.jar).

Step 4: Create a new Java class EmpDetail. Write the below Java code

Thus, when we compile and run the Java code we get the below output:

Last name of Employee 101 is : Kochhar

Hence, the solution to our requirement.

If you like the post please comment, share, and do join me on Facebook. Please subscribe to my YouTube Channel for video tutorials.

Thanks & Regards,
Susanto Paul

 441 total views,  2 views today

By Susanto Paul

Susanto is an Oracle ACE, a qualified MCA, MBA, and a highly-skilled Senior Oracle Specialist. He is an enthusiastic Blogger and YouTuber who helps learners to solve their complex problems more efficiently. He has 9+ years of experience in multiple technologies like AWS, Oracle ADF, Oracle APEX, Oracle JET, Oracle VBCS, Oracle IDCS, Oracle PL/SQL, Oracle Integration Cloud, Java, JDBC, Servlets, JSP, Spring, Hibernate, HTML5, CSS3, JavaScript, TypeScript, NodesJS, Angular, MySQL, Oracle WebLogic Server, JUnit, JMeter, Selenium Web Driver, etc. He is a certified: Oracle Certified Professional Java SE 6 Programmer, Oracle ADF 11g Certified Implementation Specialist, Oracle Cloud Platform Application Integration 2020 Certified Specialist, Oracle Cloud Infrastructure Foundations 2020 Certified Associate, and Oracle Cloud Infrastructure Developer 2020 Certified Associate

Leave a Reply

Your email address will not be published. Required fields are marked *

satta king chart