baliuka 2003/03/19 10:40:08
Modified: dbutils/src/java/org/apache/commons/dbutils DbException.java
DbUtils.java ProcedureUtils.java
Log:
implemented printStackTrace in DbException
Revision Changes Path
1.3 +19 -0
jakarta-commons-sandbox/dbutils/src/java/org/apache/commons/dbutils/DbException.java
Index: DbException.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/dbutils/src/java/org/apache/commons/dbutils/DbException.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DbException.java 16 Mar 2003 09:29:32 -0000 1.2
+++ DbException.java 19 Mar 2003 18:40:08 -0000 1.3
@@ -39,5 +39,24 @@
return cause;
}
+
+
+
+ public void printStackTrace(java.io.PrintWriter ps){
+ Throwable t = getCause();
+ super.printStackTrace(ps);
+ if( t != null ){
+ ps.println("Caused by:");
+ if(t instanceof java.sql.SQLException ){
+ DbUtils.printStackTrace( (java.sql.SQLException)t, ps);
+ }else {
+ t.printStackTrace(ps);
+ }
+ }
+
+ }
+
+
+
}
1.23 +15 -8
jakarta-commons-sandbox/dbutils/src/java/org/apache/commons/dbutils/DbUtils.java
Index: DbUtils.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/dbutils/src/java/org/apache/commons/dbutils/DbUtils.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- DbUtils.java 19 Mar 2003 09:21:39 -0000 1.22
+++ DbUtils.java 19 Mar 2003 18:40:08 -0000 1.23
@@ -295,10 +295,12 @@
return false;
} catch (IllegalAccessException iae) {
iae.printStackTrace();
- return false;
+ return true; //constructor is privite, ok for DriverManager contract
} catch (InstantiationException ie) {
ie.printStackTrace();
return false;
+ }catch(Throwable t){
+ return false;
}
}
@@ -388,7 +390,7 @@
continue LOOP;
}
}
- throw new SQLException(" index not found for " +
pd[i].getName() );
+ throw new SQLException(" index not found for " + name );
}
do{
@@ -404,8 +406,8 @@
for(int i = 1; i <= cnt; i++){
Object value = rs.getObject(i);
int index = nameToIndex[i];
- if( rs.wasNull() &&
pd[index].getPropertyType().isPrimitive() ){
- value = DEFAULTS.get( pd[index].getPropertyType() );
+ if( rs.wasNull() ){
+ continue;
}
try{
@@ -564,13 +566,18 @@
// quiet
}
}
+
+
- public static void printStackTrace(SQLException sqle, java.io.PrintStream ps){
+ public static void printStackTrace(SQLException sqle, java.io.PrintWriter ps){
SQLException next = sqle;
while( next != null ){
next.printStackTrace(ps);
next = next.getNextException();
+ if(next != null){
+ ps.println("Next SQLException:");
+ }
}
@@ -578,11 +585,11 @@
public static void printStackTrace(SQLException sqle){
- printStackTrace( sqle, System.err );
+ printStackTrace( sqle, new java.io.PrintWriter( System.err ) );
}
- public static void printWarnings(Connection connection, java.io.PrintStream ps){
+ public static void printWarnings(Connection connection, java.io.PrintWriter ps){
if( connection != null ){
try{
printStackTrace(connection.getWarnings(), ps);
@@ -594,7 +601,7 @@
}
public static void printWarnings(Connection connection ){
- printWarnings(connection,System.err);
+ printWarnings(connection,new java.io.PrintWriter(System.err));
}
1.14 +2 -13
jakarta-commons-sandbox/dbutils/src/java/org/apache/commons/dbutils/ProcedureUtils.java
Index: ProcedureUtils.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/dbutils/src/java/org/apache/commons/dbutils/ProcedureUtils.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- ProcedureUtils.java 19 Mar 2003 09:21:39 -0000 1.13
+++ ProcedureUtils.java 19 Mar 2003 18:40:08 -0000 1.14
@@ -269,17 +269,6 @@
};
- for(int i = 0; i < names.length; i++){
-
- try{
-
- return loader.loadClass(names[i]);
-
- }catch(ClassNotFoundException cnfe){
-
- }
-
- }
for(int i = 0; i < imports.length; i++){
try{
@@ -603,7 +592,7 @@
if(connection == null){
- throw new IllegalStateException("object disconnected: " +
method);
+ throw new IllegalStateException("object is disconnected: " +
method);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]