私のエラー:
Java.sql.SQLException: Listener refused the connection with the following error:
ORA-12516, TNS:listener could not find available handler with matching protocol
stack
The Connection descriptor used by the client was:
//10.2.5.21:9001/XE
at Oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.Java
:112)
at Oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.Java
:261)
at Oracle.jdbc.driver.T4CConnection.logon(T4CConnection.Java:387)
at Oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.Java:
414)
at Oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.Java:165)
at Oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtensio
n.Java:35)
at Oracle.jdbc.driver.OracleDriver.connect(OracleDriver.Java:801)
at Oracle.jdbc.pool.OracleDataSource.getPhysicalConnection(OracleDataSou
rce.Java:297)
at Oracle.jdbc.pool.OracleDataSource.getConnection(OracleDataSource.Java
:221)
at Oracle.jdbc.pool.OracleDataSource.getConnection(OracleDataSource.Java
:165)
at utilityService.DB_util.setOracleConnectionActive(DB_util.Java:99)
at utilityService.DB_util.getRecPreparedAuthentication(DB_util.Java:124)
私の一般的なデータベース接続クラス:
package utilityService;
import Java.sql.CallableStatement;
import Java.sql.Connection;
import Java.sql.PreparedStatement;
import Java.sql.ResultSet;
import Java.sql.SQLException;
import Java.sql.Statement;
import Oracle.jdbc.pool.OracleDataSource;
public class DB_util {
String propValue = "";
ResultSet rec = null;
Statement stm = null;
PreparedStatement pre_stm = null;
CallableStatement call_stm = null;
Connection conn1 = null;
/**
* Constructure to get Oracle connection
*/
public DB_util() {
Util util=new Util();
propValue=util.getFilePathToSave();
//propValue = Util.propValue;// get Oracle connection
setOracleConnectionActive();
}
/**
* Close all Oracle connections and result sets.
*/
public void setOracleConnectionClose() {
try {
if (conn1 != null || !conn1.isClosed()) {
if (rec != null) {
rec.close();
rec = null;
}
if (stm != null) {
stm.close();
stm = null;
}
if (pre_stm != null) {
pre_stm.close();
pre_stm = null;
}
if (call_stm != null) {
call_stm.close();
call_stm = null;
}
conn1.commit();
conn1.close();
conn1 = null;
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
/**
* return a result set according to sql sent
*
* @param SQL
* @return
*/
public ResultSet getRec(String SQL) {
try {
setOracleConnectionActive();
stm = conn1.createStatement();
rec = stm.executeQuery(SQL);
return rec;
} catch (Exception ex) {
ex.printStackTrace();
return rec;
}
}
/**
* Activate Oracle connection
*/
private void setOracleConnectionActive() {
try {
if (conn1 == null || conn1.isClosed()) {
OracleDataSource ods = new OracleDataSource();
if (propValue != null) {
ods.setURL(propValue);
}
conn1 = ods.getConnection();
System.out.println("DB connection CONNECTED......");
conn1.setAutoCommit(false);
}
} catch (Exception ex) {
//setOracleConnectionActive();
ex.printStackTrace();
System.out.println("DB connection FAILED......");
}
}
/**
* send prepared result set with user authenticate
*
* @param SQL
* @param strInputUserMobile
* @param strInputUserName
* @param strInputUserPassword
* @return
*/
public ResultSet getRecPreparedAuthentication(String SQL,
String strInputUserMobile, String strInputUserName,
String strInputUserPassword) {
try {
setOracleConnectionActive();
pre_stm = conn1.prepareStatement(SQL);
pre_stm.setString(1, strInputUserMobile);
pre_stm.setString(2, strInputUserName);
pre_stm.setString(3, strInputUserPassword);
rec = pre_stm.executeQuery();
return rec;
} catch (Exception ex) {
ex.printStackTrace();
return rec;
}
}
/**
* insert sql to db which is send as a sql
*
* @param SQL
* @return
*/
public int insertSQL(String SQL) {
int output = 0;
try {
setOracleConnectionActive();
stm = conn1.createStatement();
output = stm.executeUpdate(SQL);
conn1.commit();
output = 1;
} catch (Exception ex) {
try {
conn1.rollback();
output = 0;
} catch (SQLException e) {
e.printStackTrace();
output = 0;
}
ex.printStackTrace();
}
return output;
}
/**
* Send a callable statement according to sent sql
*
* @param SQL
* @return
*/
public CallableStatement callableStatementSQL(String SQL) {
int output = 0;
try {
setOracleConnectionActive();
call_stm = conn1.prepareCall(SQL);
} catch (Exception ex) {
try {
conn1.rollback();
output = 0;
} catch (SQLException e) {
e.printStackTrace();
output = 0;
}
ex.printStackTrace();
}
return call_stm;
}
}
すべてのトランザクションでこのクラスを参照し、フェッチおよびCRUD操作を実行します。コードに問題はありますか?
あなたは多くの接続を開いたが、それが問題だ。あなたのコードでは、開いた接続を閉じなかったと思います。
データベースのバウンスは一時的に解決できますが、連続して実行すると再表示されます。また、データベースへの同時接続数を確認する必要があります。最大DBプロセスパラメータに達した場合、これは一般的な症状です。
このスレッドの礼儀: https://community.Oracle.com/thread/362226?tstart=-1
私は、SQLコマンドラインでこの問題を修正しました:
connect system/<password>
alter system set processes=300 scope=spfile;
alter system set sessions=300 scope=spfile;
データベースを再起動します。