Menu

Commit [r1156]  Maximize  Restore  History

Fixed bugs the JUnit test showed for DB2 connections

hotzst 2009-03-07

changed /trunk/ch.sahits.codegen.java.datatools/src/ch/sahits/codegen/util/DTPConnectionParser.java
/trunk/ch.sahits.codegen.java.datatools/src/ch/sahits/codegen/util/DTPConnectionParser.java Diff Switch to side-by-side view
--- a/trunk/ch.sahits.codegen.java.datatools/src/ch/sahits/codegen/util/DTPConnectionParser.java
+++ b/trunk/ch.sahits.codegen.java.datatools/src/ch/sahits/codegen/util/DTPConnectionParser.java
@@ -264,11 +264,18 @@
 	}
 	/**
 	 * Retrieve the host from the connection String for a DB2.
+	 * The implementation is based on {@link "http://publib.boulder.ibm.com/infocenter/db2luw/v8/index.jsp?topic=/com.ibm.db2.udb.doc/ad/cjvjt2cn.htm"}
+	 * and {@link "http://www.torsten-horn.de/techdocs/java-sql.htm#DB2"}
 	 * @param connectionURL
 	 * @return host
 	 */
 	private String getDB2Host(String connectionURL) {
-		String part = connectionURL.substring("jdbc:db2//".length());
+		String part=connectionURL;
+		if (vendor.equals(DB2_VENDOR_ISERIES)){
+			part = connectionURL.substring("jdbc:as400://".length());
+		} else if (vendor.equals(DB2_VENDOR) || vendor.equals(DB2_VENDOR_ZSERIES)){
+			part = connectionURL.substring("jdbc:db2://".length());
+		}
 		if (part.indexOf(":")>0){
 			// includes port number
 			return part.substring(0,part.indexOf(":"));
@@ -476,17 +483,30 @@
 	/**
 	 * Retrieve the port number of the connection URL if it is a network based URL
 	 * or the default port
+	 * The implementation is based on {@link "http://publib.boulder.ibm.com/infocenter/db2luw/v8/index.jsp?topic=/com.ibm.db2.udb.doc/ad/cjvjt2cn.htm"}
+	 * and {@link "http://www.torsten-horn.de/techdocs/java-sql.htm#DB2"}
 	 * @param connectionURL
 	 * @return port number
 	 */
 	private int getDB2Port(String connectionURL) {
-		String part = connectionURL.substring("jdbc:db2//".length());
+		String part=connectionURL;
+		if (vendor.equals(DB2_VENDOR_ISERIES)){
+			part = connectionURL.substring("jdbc:as400://".length());
+		} else if (vendor.equals(DB2_VENDOR) || vendor.equals(DB2_VENDOR_ZSERIES)){
+			part = connectionURL.substring("jdbc:db2://".length());
+		}
 		if (part.indexOf(":")>0){
 			// includes port number
-			return Integer.parseInt(part.substring(part.indexOf(":"),part.indexOf("/")));
+			String port = part.substring(part.indexOf(":")+1,part.indexOf("/"));
+			return Integer.parseInt(port);
 		} else {
 			// Default port;
-			return 50000;
+			if (vendor.equals(DB2_VENDOR_ISERIES) || vendor.equals(DB2_VENDOR_ZSERIES)){
+				return 446;
+			} else if (vendor.equals(DB2_VENDOR)){
+				return 50000;
+			}
+			return 0;
 		}
 	}
 	/**
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.