Java application connect Oracle database

In this tutorial, you are introduced the way which a java application connect oracle database. You should follow five steps to make database connectivity. This tutorial is using Oracle11g as the database and you need to know the following information for the oracle database:

Driver class: The driver class oracle.jdbc.driver.OracleDriver is used for oracle database
Connection URL: The connection URL is jdbc:oracle:thin:@localhost:1521:demo, it means that jdbc is the API, oracle is the database, thin is the driver, localhost is the server name on which oracle is running, you may also use IP address, 1521 is the port number and demo is the Oracle service name.
Username/Password: The account to login the oracle database.

Let’s build a sample to make a Java Application connect Oracle database

Here, you must have Oracle11g Oralce database on your local computer. This sample be using account javabycode/democonora to login oracle database.

You should create a table in oracle database, for example table name is FRUIT. Then insert a record for table.

This program use ojdbc driver for oracle database is a jar file ojdbc6-11.2.0.2.0.jar. You could download this library following the link

Run it and you will get the result

This sample is not difficult for java beginners. Now, you can build your own java application connect Oracle database. Hope you like and comment

Happy Learing!

Leave a Comment

*

Please share it if you found this useful
Hide Buttons