我在 domino 服务器中创建了一个 servlet,第一次调用它时我没有看到任何错误,但是在我看到这个之后:
java.sql.SQLException:连接不存在。在 com.ibm.as400.access.JDError.throwSQLException(JDError.java:389) 在 com.ibm.as400.access.AS400JDBCConnection.checkOpen(AS400JDBCConnection.java:394) 在 com.ibm.as400.access.AS400JDBCConnection.prepareStatement (AS400JDBCConnection.java:1868) 在 com.ibm.as400.access.AS400JDBCConnection.prepareStatement(AS400JDBCConnection.java:1703)
如果我想调用 servlet,我现在必须在每次多米诺服务器时重新启动
任何其他解决方案将不胜感激
编辑 :
使用 Apache DBCP 后,我还有另一个错误:
java.sql.SQLException:连接已关闭。在 org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.checkOpen(P??oolingDataSource.java:175) 在 org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.prepareStat??ement(PoolingDataSource.java:301)
COODE 获取/池连接:
公共类 ConnexionAS400 {
public static ConnexionAS400 connexionAS4000= null;
private static Connection connAS400 = null;
public static ConnexionAS400 getInstance(){
if(connexionAS4000 == null)
connexionAS4000 = new ConnexionAS400();
return connexionAS4000;
}
private ConnexionAS400(){
String Url = "jdbc:as400://172.31.5.100";
String Username = "DEVATIRD";
String Password = "ATIRD";
String Driver = "com.ibm.as400.access.AS400JDBCDriver";
try
{
Class.forName(Driver);
ConnectionFactory connectionFactory = new DriverManagerConnectionFactory(Url,Username,Password);
PoolableConnectionFactory poolableConnectionFactory = new PoolableConnectionFactory(connectionFactory, new GenericObjectPool(null), null, "SELECT 1", false, true);
ObjectPool connectionPool = new GenericObjectPool(poolableConnectionFactory,GenericObjectPool.DEFAULT_MAX_ACTIVE,GenericObjectPool.WHEN_EXHAUSTED_GROW,GenericObjectPool.DEFAULT_MAX_WAIT,GenericObjectPool.DEFAULT_MAX_IDLE,false,true);
PoolingDataSource dataSource = new PoolingDataSource(connectionPool);
connAS400 = dataSource.getConnection();
}
catch (NoClassDefFoundError exno)
{
System.out.println("ERREUR: Impossible de charger la classe");
exno.printStackTrace();
}
catch (Exception e)
{
System.out.println("ERREUR: Impossible de charger le driver JDBC AS400.");
e.printStackTrace();
}
}
public Connection openConnectionAS400() {
return connAS400;
}
public void closeConnectionAS400() {
try {
connAS400.close();
} catch (SQLException e) {
System.out
.println("ERREUR: Lors de la fermeture de la connection.");
e.printStackTrace();
}
}}
提前致谢。