Add mechanism to close DB connections
Oracle ends up refusing connections if we don't close them git-svn-id: http://webgoat.googlecode.com/svn/trunk@128 4033779f-a91e-0410-96ef-6bf7bf53c507
This commit is contained in:
parent
6f5e7c37f7
commit
5f67544b24
@ -2,6 +2,7 @@ package org.owasp.webgoat;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
|
import java.sql.SQLException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
@ -205,6 +206,12 @@ public class HammerHead extends HttpServlet
|
|||||||
log(request, "Could not write error screen: "
|
log(request, "Could not write error screen: "
|
||||||
+ thr.getMessage());
|
+ thr.getMessage());
|
||||||
}
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
WebSession.closeConnection();
|
||||||
|
} catch (SQLException sqle) {
|
||||||
|
sqle.printStackTrace();
|
||||||
|
}
|
||||||
// System.out.println( "HH Leaving doPost: " );
|
// System.out.println( "HH Leaving doPost: " );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -308,7 +308,7 @@ public class WebSession
|
|||||||
public static synchronized Connection getConnection(WebSession s)
|
public static synchronized Connection getConnection(WebSession s)
|
||||||
throws SQLException, ClassNotFoundException
|
throws SQLException, ClassNotFoundException
|
||||||
{
|
{
|
||||||
if ( connection == null )
|
if ( connection == null || connection.isClosed() )
|
||||||
{
|
{
|
||||||
connection = DatabaseUtilities.makeConnection( s );
|
connection = DatabaseUtilities.makeConnection( s );
|
||||||
}
|
}
|
||||||
@ -316,6 +316,13 @@ public class WebSession
|
|||||||
return connection;
|
return connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static synchronized void closeConnection() throws SQLException
|
||||||
|
{
|
||||||
|
if (connection != null && !connection.isClosed()) {
|
||||||
|
connection.close();
|
||||||
|
connection = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description of the Method
|
* Description of the Method
|
||||||
|
Loading…
x
Reference in New Issue
Block a user