package com.ist.common.util;import java.sql.*;import javax.naming.context;import Javax.naming.initialcontext;import javax.naming.namingexception;public class jdbcoracletest  {    //ORCL is the database name in the Oracle database, and localhost represents the Oracle database that connects to the native //1521 is the port number of the connection private static string url= "JDBC:ORACLE:THIN:@192.168.99.98:1521:ORCL"; //system user name for landing Oracle database private static String user= "nms09"; //manager password for user name System private static string password= "Nms09"; public static Connection conn; public static preparedstatement ps; public static Resultset rs; public static statement st ; //How to connect a database public void getconnection () { try { //initializing the driver package class.forname ("Oracle.jdbc.driver.OracleDriver"); //assigning values to conn based on database connection characters, names, and Passwords conn=drivermanager.getconnection (url, User, password); } catch (exception e) { // todo: handle exception e.printstacktrace (); } } // Test whether the connection to the Oracle database is successful public static void main (String[] args) { jdbcoracletest basedao=new jdbcoracletest (); basedao.getconnection (); &nbsP; if (conn==null) {            SYSTEM.OUT.PRINTLN ("Connection to Oracle database failed! "); }else{             SYSTEM.OUT.PRINTLN ("Connection to Oracle database was successful! "); } } }
JAVA JDBC Connection Oracle Test code