Tags

11g (5) 12c (6) 18c (3) 19c (4) ASM (1) Critical Patch (11) Data Pump (1) Dataguard (9) Diverse (3) GRID (7) GitLab (2) Linux (8) OEM (2) ORA Errors (13) Oracle (12) RMAN (4)
Showing posts with label Oracle JDBC Connection Test. Show all posts
Showing posts with label Oracle JDBC Connection Test. Show all posts

Friday, December 5, 2025

Oracle JDBC Connection Test



How to test Oracle connection via JDBC Thin driver.


PURPOSE: All documents are provided on this Blog just for educational purposes only.  Please make sure that you run it in your test environment before to move on to production environment.

Oracle JDBC Connection Test


PURPOSE: All documents are provided on this Blog just for educational purposes only.  Please make sure that you run it in your test environment before to move on to production environment. 


STEP 1.
Create a file OracleCon.java with the following code.
vi OracleCon.java

import java.sql.*;
public class OracleCon
{
public static void main(String args[])
throws ClassNotFoundException, SQLException
  {
   Class.forName("oracle.jdbc.driver.OracleDriver");
     String url = "jdbc:oracle:thin:@ ORADBPRD.th.com:1521:KARDBPRD";
       Connection conn =
         DriverManager.getConnection(url,"user_tst01","pw_xyz");
         conn.setAutoCommit(false);
     Statement stmt = conn.createStatement();
     ResultSet rs=stmt.executeQuery("select user from dual;");
     while(rs.next())
     {
      System.out.println (rs.getString(1));
     }
   stmt.close();
   System.out.println ("Connection succeeded");
  }
}

STEP 2.
Compile the code.

javac OracleCon.java

Execute the program as follow.
java OracleCon

USER_TST01
Connection succeeded


Oracle JDBC Connection Test

How to test Oracle connection via JDBC Thin driver. PURPOSE: All documents are provided on this Blog just for educational purposes o...