Jdbc connection not established

Hi Team ,
Below is the code Iam using running jdbc application , Iam new to Java . Iam not getting the excpected output


folder NAme : jdbcprograms
in this folder I have ojdbc6.jar and DBConnection.java file and class file.

import java.sql.*;

public class DBConnection
{
      public static void main(String [] args)
      {
            try
            {
      
                  Class.forName("jdbc.odbc.JdbcOdbcDriver");
                  Connection conn = DriverManager.getConnection("jdbc:odbc:Oracle-Hr","HR","orcl");
                  System.out.println(conn.getClass().getName());
            if (conn==null)
            {
                  System.out.println("Connection not established");
            }
            else
            {
                  System.out.println("Connection is  established");
            }
            }
            catch(SQLException e)
            {
                  System.out.println(e);            
            }
            catch(ClassNotFoundException e)      
            {
                  System.out.println(e);            
            }
            catch(Exception e)
            {
                  System.out.println(e);            
            }            
      }
}


When I run the code as below , I get the below output , but not getting the connection established output. Any help is really appreciated

D:\JdbcPrograms>java -jar ojdbc6.jar DBConnection
Oracle 11.2.0.1.0 JDBC 4.0 compiled with JDK6

Expected Output
Class Name Output for Connection Class
Connection established.
sam_2012Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CEHJCommented:
D:\JdbcPrograms>java -jar ojdbc6.jar DBConnection

Open in new window


is the wrong command. It should be

D:\JdbcPrograms>java -cp ojdbc6.jar;. DBConnection

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sam_2012Author Commented:
D:\JdbcPrograms>java -cp ojdbc6.jar;. DBConnection
java.lang.ClassNotFoundException: jdbc.odbc.JdbcOdbcDriver

getting the above error
CEHJCommented:
Is that jar in that directory? If so, it doesn't contain the driver
sam_2012Author Commented:
Thanks a lot. I kept the correct jar file in the folder it ran successfully
CEHJCommented:
:)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JDBC

From novice to tech pro — start learning today.