The example of this article tells the method of Java based on the JDBC connection Oracle 11G Release2. Share it for everyone for your reference. The specifics are as follows:
The JDBC connection of Oracle 11G Release 2 seems to be different. If you receive the following abnormalities:
Listener Refused the Connection with the Following Error: ORA-12505, TNS: Listener Does Not CurrenTly Knowing Given in Connect DescripTor.
Then you must use the following connection method:
/*************************************************** ? ***********************************/package com.vigilance.java.sample;import java.sql. Connection; Import Java.sql.DriverManager; Import Java.sql.ResultSet; Import Java.sql.sqlexception; Import Java.sql.Statement;/*** @Author httt P: //vigilance.co.in */Public Class ConnectjdbCoracLe11g {/*** this class demodrates the code for connecting oracle 11g database users. _Driver = "Oracle.jdbc.driver.orAcledriver"; string jdbc_string = "JDBC: ODBC: Thin: @Hostname: Portnumber/SID"; // in case of 11g user '/' Instead of: string user_name = "user_name"; string passwd = "password" ; Connection conn = null; ResultSet RS = null; statement stmt = null; try {class.Forname (jdbc_driver); conn = driverManager.getConnection (JDBC_STRING, User_name, Passwd); .createStatement (); String Query = "Select * from Table Tbl"; RS = stmt.executequery (query);} Catch (sqlexception sqlex) {sqlex.printstacktrace ();} CASSNOTFOUNDEXCEPTION) {e.printstacktrace (); } Finally {try {if (RS! = Null) RS.Close ( ); IF (STMT! = Null) stmt.close (); if (conn! = Null) const.close ();} Catch (sqlexception e) {e.printstacktrace ();}}}}}}}}}}}}}It is hoped that this article is helpful to everyone's Java program design.