Author: sumedha
Date: Thu Mar 13 18:10:41 2008
New Revision: 14786
Log:
Fix for KPTPMG-4 & connection leakage for nested queries
Modified:
branches/wsas/java/2.2/commons/data-services/src/main/java/org/wso2/ws/dataservice/DBUtils.java
Modified:
branches/wsas/java/2.2/commons/data-services/src/main/java/org/wso2/ws/dataservice/DBUtils.java
==============================================================================
---
branches/wsas/java/2.2/commons/data-services/src/main/java/org/wso2/ws/dataservice/DBUtils.java
(original)
+++
branches/wsas/java/2.2/commons/data-services/src/main/java/org/wso2/ws/dataservice/DBUtils.java
Thu Mar 13 18:10:41 2008
@@ -258,7 +258,11 @@
boolean hasResponse = true;
OMNamespace omNs = null;
String sqlQuery = queryElement.getFirstChildWithName(new
QName("sql")).getText();
- try {
+ try {
+ if(queryLevel > 0){
+ queryLevel --;
+ }
+
//Parameter dbConnectionParam =
axisService.getParameter(DBConstants.DB_CONNECTION);
//if(dbConnectionParam == null){
// throw new AxisFault("Database connection not
found in Axis Configuration");
@@ -549,6 +553,10 @@
Result resultObj = null;
//String columnDefault = null;
+ if(queryLevel > 0){
+ queryLevel --;
+ }
+
String sqlQuery = queryElement.getFirstChildWithName(new
QName("sql")).getText();
try {
//Parameter dbConnectionParam =
axisService.getParameter(DBConstants.DB_CONNECTION);
@@ -1459,56 +1467,58 @@
throws AxisFault{
java.sql.Timestamp timestamp = null;
SimpleDateFormat sdf;
- try{
- sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.SSSSSS");
- java.util.Date date = sdf.parse(value);
- timestamp = new java.sql.Timestamp(date.getTime());
- }catch(ParseException e){
- try{
- sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
- java.util.Date date = sdf.parse(value);
- timestamp = new java.sql.Timestamp(date.getTime());
- }catch(ParseException e1){
- sdf = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss.sss'Z'");
- try {
- java.util.Date date = sdf.parse(value);
- timestamp = new java.sql.Timestamp(date.getTime());
- } catch (ParseException e2) {
- try {
- sdf = new
SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss.sss'+'hh:mm");
+ if(value != null && value.trim().length() > 0){
+ try{
+ sdf = new SimpleDateFormat("yyyy-MM-dd
hh:mm:ss.SSSSSS");
+ java.util.Date date = sdf.parse(value);
+ timestamp = new java.sql.Timestamp(date.getTime());
+ }catch(ParseException e){
+ try{
+ sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
+ java.util.Date date = sdf.parse(value);
+ timestamp = new java.sql.Timestamp(date.getTime());
+ }catch(ParseException e1){
+ sdf = new
SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss.sss'Z'");
+ try {
java.util.Date date = sdf.parse(value);
timestamp = new
java.sql.Timestamp(date.getTime());
- } catch (ParseException e3) {
- try{
- sdf = new
SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss.sss'-'hh:mm");
+ } catch (ParseException e2) {
+ try {
+ sdf = new
SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss.sss'+'hh:mm");
java.util.Date date = sdf.parse(value);
- timestamp = new
java.sql.Timestamp(date.getTime());
- } catch (ParseException e4) {
+ timestamp = new
java.sql.Timestamp(date.getTime());
+ } catch (ParseException e3) {
try{
- sdf = new
SimpleDateFormat("yyyy-MM-dd");
+ sdf = new
SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss.sss'-'hh:mm");
java.util.Date date =
sdf.parse(value);
timestamp = new
java.sql.Timestamp(date.getTime());
- } catch (ParseException
e5) {
- log.error("Incorrect Timestamp
format for parameter : "+paramName
- +".Timestamp
should be in one of following formats " +
-
"yyyy-MM-dd'T'hh:mm:ss.sss'+'hh:mm, " +
-
"yyyy-MM-dd'T'hh:mm:ss.sss'-'hh:mm, " +
-
"yyyy-MM-dd'T'hh:mm:ss.sss'Z', " +
-
"yyyy-MM-dd hh:mm:ss.SSSSSS or " +
-
"yyyy-MM-dd hh:mm:ss", e5);
- throw new
AxisFault("Incorrect Timestamp format for parameter : "+paramName
- +".Timestamp
should be in one of following formats " +
-
"yyyy-MM-dd'T'hh:mm:ss.sss'+'hh:mm, " +
-
"yyyy-MM-dd'T'hh:mm:ss.sss'-'hh:mm, " +
-
"yyyy-MM-dd'T'hh:mm:ss.sss'Z', " +
-
"yyyy-MM-dd hh:mm:ss.SSSSSS or " +
-
"yyyy-MM-dd hh:mm:ss", e5);
+ } catch (ParseException
e4) {
+ try{
+ sdf = new
SimpleDateFormat("yyyy-MM-dd");
+ java.util.Date date =
sdf.parse(value);
+ timestamp = new
java.sql.Timestamp(date.getTime());
+ } catch
(ParseException e5) {
+ log.error("Incorrect
Timestamp format for parameter : "+paramName
+
+".Timestamp should be in one of following formats " +
+
"yyyy-MM-dd'T'hh:mm:ss.sss'+'hh:mm, " +
+
"yyyy-MM-dd'T'hh:mm:ss.sss'-'hh:mm, " +
+
"yyyy-MM-dd'T'hh:mm:ss.sss'Z', " +
+
"yyyy-MM-dd hh:mm:ss.SSSSSS or " +
+
"yyyy-MM-dd hh:mm:ss", e5);
+ throw
new AxisFault("Incorrect Timestamp format for parameter : "+paramName
+
+".Timestamp should be in one of following formats " +
+
"yyyy-MM-dd'T'hh:mm:ss.sss'+'hh:mm, " +
+
"yyyy-MM-dd'T'hh:mm:ss.sss'-'hh:mm, " +
+
"yyyy-MM-dd'T'hh:mm:ss.sss'Z', " +
+
"yyyy-MM-dd hh:mm:ss.SSSSSS or " +
+
"yyyy-MM-dd hh:mm:ss", e5);
+ }
}
}
}
- }
- }
- }
+ }
+ }
+ }
return timestamp;
}
@@ -1520,16 +1530,18 @@
private static Time getTime(String value, String paramName)
throws AxisFault {
- java.sql.Time time;
- try {
- SimpleDateFormat sdf = new SimpleDateFormat("hh:mm:ss");
- java.util.Date date = sdf.parse(value);
- time = new java.sql.Time(date.getTime());
- } catch (ParseException e) {
- log.error("Incorrect Time format for parameter : "+
paramName
- +
".Time should be in the format hh:mm:ss",e);
- throw new AxisFault("Incorrect Time format for
parameter : "+ paramName
- +
".Time should be in the format hh:mm:ss",e);
+ java.sql.Time time = null;
+ if(value != null && value.trim().length() > 0){
+ try {
+ SimpleDateFormat sdf = new
SimpleDateFormat("hh:mm:ss");
+ java.util.Date date = sdf.parse(value);
+ time = new java.sql.Time(date.getTime());
+ } catch (ParseException e) {
+ log.error("Incorrect Time format for parameter
: "+ paramName
+
+ ".Time should be in the format hh:mm:ss",e);
+ throw new AxisFault("Incorrect Time format for
parameter : "+ paramName
+
+ ".Time should be in the format hh:mm:ss",e);
+ }
}
return time;
}
_______________________________________________
Wsas-java-dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/wsas-java-dev