Java is a programming language that helps in performing a particular task. DBMS is used to manage large amounts of data. Today most of the real time applications are a combination of Java and DBMS.
Oracle (SQL Plus) sometimes gets installed in Windows 7 but when tried to access by entering the User Id and Password, denies the access. But it works when tried to connect using the SQL Command Prompt.
1)Download “ojdbc6.jar” file from the official Oracle website.
2) Place it in “C:\Program Files\Java\jre6\lib\ext” directory. Sometimes this may need the permission of the Administrator to accept it.
3) Go to “Administrative Tools” by click on “Start” then go to “Control Panel” followed by “System Security” and then on “Administrative Tools”. Double click on ODBC from the right panel.
4)In the System DSN, click on “Add”.
5)Select Oracle in XE from the options and click on “Finish”. If the DBMS used is MySQL then you need to select SQL Server from the options. Different applications have different Data Sources to be specified. So one should be careful while selecting the Data Source.
6)Specify the Data Source Name, TSN Name & UserId. Data Source Name is a sample data source used to connect to DBMS through Java. It can be given any name as desired. The description is just an additional explanation. It can be left blank. TNS Service Name is the name of the class in the tns file. The user Id is the Id used to connect to the server. Let the default applications be as it is and save it by click on “OK”.
7) The linking is completed. To check if the link is proper, Try out the below program by executing it using Command Prompt.
public class TestProgram
public static void main(String a)
System.out.println("JDBC Driver loaded");
System.out.println("Connected to the Oracle Database");
Replace the words Id and password with the Id and passport used to connect to the SQL server.
9)Compile it using “javac TestProgram.java”.
10)Run it using “java TestProgram”.
11)The output must display the following.
If you had any questions let us know through comments.