Home » Developer & Programmer » JDeveloper, Java & XML » socket closed
socket closed [message #91599] Wed, 04 December 2002 17:35 Go to next message
s y
Messages: 1
Registered: December 2002
Junior Member
I use a class OraclePool initialize the oracle connection pool, then I use a class OracleConn gets the connection. I have several class extends OracleConn which takes care database operations(OracleCust, OracleSales, etc), every class has a finalize() method close all PreparedStatement and connection. The problem is I constantly get java.sql.SQLException: IO Exception: Socket Closed.
Does any one how to check the connections on connection pool? Do I need close the connection?

public class OraclePool {
private OracleConnectionPoolDataSource ocpds;
private static OraclePool pool;

private OraclePool() {
initPool();
}
public static OraclePool getInstance() {
if( pool == null )
pool=new OraclePool();
return pool;
}
public OracleConnectionPoolDataSource getPool(){
return ocpds;
}
private boolean initPool() {
try {
if (ocpds == null) ocpds = new OracleConnectionPoolDataSource();
String url = “testUrl”;
String user = “testUser”;
String password = “testPassword”;

ocpds.setURL(url);
ocpds.setUser(user);
ocpds.setPassword(password);

return true;
}
catch ( Exception ex ) {
Logger.getLogger(getClass().getName()).severe(ex.toString());
}
return false;
}
}

public class OracleConn {
protected Connection connection;
protected PooledConnection pc;

public OracleConn() throws DBException {
if ( !connectDB() )
throw new DBException();
}

public boolean connectDB() {
try {
pc = OraclePool.getInstance().getPool().getPooledConnection();
Class.forName( "oracle.jdbc.driver.OracleDriver" );
connection = pc.getConnection();
// more code

}


protected void finalize() {
close();
}

public void close() {
try {
connection.close();
pc.close();
}
catch ( SQLException sqlex ) {
Logger.getLogger(getClass().getName()).severe(sqlex.toString());
}
}

}

public class OracleCust extends OracleConn{
private PreparedStatement sqlGetCust;
private PreparedStatement sqlAddCust;
private PreparedStatement sqlAddUpdateCust;
private PreparedStatement sqlRemoveCust;

// some method

protected void finalize() {
close();
}

public void close() {
try {
sqlGetCust.close();
sqlAddCust.close();
sqlUpdateCust.close();
sqlRemoveCust.close();

connection.close();
pc.close();
}
catch ( SQLException sqlex ) {
Logger.getLogger(getClass().getName()).severe(sqlex.toString());
}
}
}

public class OracleSales extends OracleConn{
private PreparedStatement sqlGetSales;
private PreparedStatement sqlAddSales;
private PreparedStatement sqlAddUpdateSales;
private PreparedStatement sqlRemoveSales;

// some method

protected void finalize() {
close();
}

public void close() {
try {
sqlGetSales.close();
sqlAddSales.close();
sqlUpdateSales.close();
sqlRemoveSales.close();

connection.close();
pc.close();
}
catch ( SQLException sqlex ) {
Logger.getLogger(getClass().getName()).severe(sqlex.toString());
}
}
}
Re: socket closed [message #91612 is a reply to message #91599] Mon, 09 December 2002 06:57 Go to previous message
Mahesh Rajendran
Messages: 10694
Registered: March 2002
Location: oracleDocoVille
Senior Member
Account Moderator
1. Is there any firewall involved?
2. what is the OS, Oracle versions?
3. in case of unix , check the value env.setting ORA_NLS33
Previous Topic: Re: Bigger type length than Maximum
Next Topic: "System.out.println(...)" don't work
Goto Forum:
  


Current Time: Tue Jul 27 22:56:01 CDT 2021