The class given below connects to a oracle database using JDBC from a Java standalone class. You can reuse the same class. Make sure that you change the properties like the oracle connection url, database connection username and password.

Connect Oracle Database using JDBC @
public class JavaGeniousConnectOracle {
  public static void main(String[] args)
      throws ClassNotFoundException, SQLException

         (new oracle.jdbc.driver.OracleDriver());
        String url = "jdbc:oracle:thin:@//server.local:1521/prod";
    Connection conn =
         DriverManager.getConnection(url,"scott", "tiger");
    Statement stmt = conn.createStatement();
    ResultSet rset =
         stmt.executeQuery("select * from SYS.V_$VERSION");
    while ( {
         System.out.println (rset.getString(1)); 
    System.out.println ("Connected to the Database and Closed Successfully."); 

Sandeep Joshi
Mathematics, Technology and Programming are my passion. I am a part of Java Ecosystem and through this blog, I contribute to it. I am here to blog about my interests, views and experiences.
I am on Google+ and Facebook.
I feel proud to be listed as a "National Memory Record Holder" in the Limca Book of Records, 2009 and have attempted for an International Memory record in the Guiness Book of Records. I can remember the value of PI upto 10,000 digits after the decimal (3.1415.....). You can contact me on ; I would like to hear from you :)