Source Code Cross Referenced for ConfigReader.java in  » Database-JDBC-Connection-Pool » octopus » org » webdocwf » util » loader » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Database JDBC Connection Pool » octopus » org.webdocwf.util.loader 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /**
0002:          ConfigReader - Read vales from config files for specified database.
0003:            Copyright (C) 2002-2003  Together
0004:            This library is free software; you can redistribute it and/or
0005:            modify it under the terms of the GNU Lesser General Public
0006:            License as published by the Free Software Foundation; either
0007:            version 2.1 of the License, or (at your option) any later version.
0008:            This library is distributed in the hope that it will be useful,
0009:            but WITHOUT ANY WARRANTY; without even the implied warranty of
0010:            MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0011:            Lesser General Public License for more details.
0012:            You should have received a copy of the GNU Lesser General Public
0013:            License along with this library; if not, write to the Free Software
0014:            Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
0015:         ConfigReader.java
0016:         Date: 20.5.2003.
0017:         */package org.webdocwf.util.loader;
0018:
0019:        import java.io.*;
0020:
0021:        import javax.xml.parsers.*;
0022:        import org.w3c.dom.*;
0023:        import org.webdocwf.util.loader.logging.*;
0024:        import java.util.Hashtable;
0025:
0026:        /**
0027:         * Class read configuration parameters from configuration XML file.
0028:         *
0029:         * @author     Zoran Milakovic, Radoslav Dutina
0030:         * @version    1.1
0031:         */
0032:        public class ConfigReader {
0033:
0034:            private Logger logger;
0035:            private String strVendorFileName = null;
0036:            private String strDriverClassName = "";
0037:            private int iFirstColumnResult = 1;
0038:            private boolean bRequiredUser = false;
0039:            private boolean bEnableJumpResult = false;
0040:            private boolean bAfterLastRow = true;
0041:            private boolean bEnableOrderBy = false;
0042:            private boolean bRowCountEnabled = false;
0043:            private boolean bSetFetchSizeEnabled = false;
0044:            private String oidDbType = "";
0045:            private String versionDbType = "";
0046:            private String oidColumnName = "oid";
0047:            private String versionColumnName = "version";
0048:            //This is default date format.
0049:            //private String dateFormat = "MM/dd/yyyy hh:mm:ss";
0050:            private String dateFormat = "yyyy-MM-dd";
0051:
0052:            private boolean bSetCursorNameEnabled = false;
0053:            private boolean bSetEmptyStringAsNull = false;
0054:            private boolean bReadingOrderRelevant = false;
0055:            private boolean bGetColumnsSupported = false;
0056:            private boolean bSetMaxRowsSupported = false;
0057:            private String bConnectionPrefix = "";
0058:            private boolean bFileSystemDatabase = false;
0059:            private String confJarStructure = "";
0060:            private boolean useSeparateConfFiles = false;
0061:            private Hashtable javaTypeMapp = new Hashtable();
0062:            //ZK added this 6.5.2004
0063:            private Hashtable isNumberMapp = new Hashtable();
0064:            private Hashtable isBinaryObjectMap = new Hashtable();
0065:            private Hashtable isDateMap = new Hashtable();
0066:            private Hashtable isWithNMap = new Hashtable();
0067:            //end
0068:            private String currentDriverName = "";
0069:            private String currentDatabaseName = "";
0070:
0071:            private static final String BYTE_ARRAY = "1";
0072:            private static final String JAVA_MATH_BIGDECIMAL = "2";
0073:            private static final String JAVA_LANG_DOUBLE = "3";
0074:            private static final String JAVA_LANG_FLOAT = "4";
0075:            private static final String JAVA_LANG_INTEGER = "5";
0076:            private static final String JAVA_LANG_LONG = "6";
0077:            private static final String JAVA_LANG_SHORT = "7";
0078:            private static final String JAVA_LANG_STRING = "8";
0079:            private static final String JAVA_SQL_DATE = "9";
0080:            private static final String JAVA_SQL_TIME = "10";
0081:            private static final String JAVA_SQL_TIMESTAMP = "11";
0082:            private static final String JAVA_LANG_BOOLEAN = "12";
0083:            private static final String JAVA_LANG_BYTE = "13";
0084:            private static final String JAVA_LANG_OBJECT = "14";
0085:
0086:            public static final String SPACE_ESCAPE = "__";
0087:
0088:            /**Method readConfigValues read specific values for desired database(dbVendor) and
0089:             * puts them into global variables. Third parameter in this method describes which database is analysed (target or source)
0090:             * Method reads values from Loader.conf configuration file (XML format).
0091:             * @param dbVendor - String - type of source database (table);
0092:             * @param strType - String - type of Loader database (source or target);
0093:             * @param driverName is name of the driver
0094:             * @throws LoaderException
0095:             */
0096:            public void readConfigValues(String dbVendor, String driverName,
0097:                    String strType) throws LoaderException {
0098:                Document doc = null;
0099:                this .logger.write("full",
0100:                        "\treadConfigValues method is started.");
0101:                if (this .javaTypeMapp.size() > 0)
0102:                    this .javaTypeMapp.clear();
0103:                try {
0104:                    DocumentBuilderFactory dbf = DocumentBuilderFactory
0105:                            .newInstance();
0106:                    DocumentBuilder db = null;
0107:                    db = dbf.newDocumentBuilder();
0108:
0109:                    String OCTOPUS_HOME = System.getProperty("OCTOPUS_HOME");
0110:                    String databaseConfFile = null;
0111:                    InputStream confFile = null;
0112:                    File configFile = null;
0113:
0114:                    //sinisa - Octopus supports mssql and msql values for dbVendor element
0115:                    if (dbVendor.equalsIgnoreCase("mssql"))
0116:                        dbVendor = "MSQL";
0117:                    if (dbVendor.equalsIgnoreCase("Hsqldb"))
0118:                        dbVendor = "HypersonicSQL";
0119:
0120:                    if (this .strVendorFileName != null
0121:                            && !this .strVendorFileName.equals("")) {
0122:                        configFile = new File(this .strVendorFileName);
0123:                        if (configFile.exists()) {
0124:                            doc = db.parse(configFile);
0125:                        }
0126:                    } else {
0127:                        if (OCTOPUS_HOME != null) {
0128:                            if (!(OCTOPUS_HOME.endsWith("\\") || OCTOPUS_HOME
0129:                                    .endsWith("/")))
0130:                                OCTOPUS_HOME += "/";
0131:                            configFile = new File(OCTOPUS_HOME
0132:                                    + "conf/OctopusDBVendors.xml");
0133:                            if (configFile.exists())
0134:                                doc = db.parse(configFile);
0135:                        } else {
0136:                            if (this .useSeparateConfFiles) {
0137:                                confFile = this 
0138:                                        .getClass()
0139:                                        .getClassLoader()
0140:                                        .getResourceAsStream(
0141:                                                this .confJarStructure
0142:                                                        + "/OctopusDBVendors.xml");
0143:                            } else {
0144:                                confFile = this 
0145:                                        .getClass()
0146:                                        .getClassLoader()
0147:                                        .getResourceAsStream(
0148:                                                "xml/conf/OctopusDBVendors.xml");
0149:                            }
0150:                            if (confFile != null)
0151:                                doc = db.parse(confFile);
0152:                        }
0153:                    }
0154:                    if (doc != null) {
0155:                        NodeList tagConfFile = doc
0156:                                .getElementsByTagName("Vendor");
0157:                        out: for (int i = 0; i < tagConfFile.getLength(); i++) {
0158:                            Node nodeMain = tagConfFile.item(i);
0159:                            NamedNodeMap attrs = nodeMain.getAttributes();
0160:                            Node nodeDriver = attrs.getNamedItem("name");
0161:                            if (nodeDriver != null
0162:                                    && nodeDriver.getFirstChild()
0163:                                            .getNodeValue().equalsIgnoreCase(
0164:                                                    dbVendor)) {
0165:                                databaseConfFile = nodeMain.getFirstChild()
0166:                                        .getNodeValue();
0167:                                break out;
0168:                            }
0169:                        }
0170:                    } else {
0171:                        //if driver name don't exists use default for source i target
0172:                        if (strType.equalsIgnoreCase("source"))
0173:                            databaseConfFile = "CsvConf.xml";
0174:                        else
0175:                            databaseConfFile = "MSQLConf.xml";
0176:                    }
0177:
0178:                    doc = null;
0179:                    if (OCTOPUS_HOME == null) {
0180:                        if (this .useSeparateConfFiles) {
0181:                            confFile = getClass().getClassLoader()
0182:                                    .getResourceAsStream(
0183:                                            this .confJarStructure + "/"
0184:                                                    + databaseConfFile);
0185:                        } else {
0186:                            confFile = getClass().getClassLoader()
0187:                                    .getResourceAsStream(
0188:                                            "xml/conf/" + databaseConfFile);
0189:                        }
0190:                        if (confFile != null)
0191:                            doc = db.parse(confFile);
0192:                    } else {
0193:
0194:                        if (databaseConfFile != null) {
0195:                            configFile = new File(databaseConfFile);
0196:                            //          check if absolute databaseConfigFile path exist,and if not try to find it in current directory
0197:                            if (!configFile.exists()) {
0198:                                configFile = new File(OCTOPUS_HOME + "/conf/"
0199:                                        + databaseConfFile);
0200:                            }
0201:                        } else {
0202:                            //just to prevent NullPointerException,if configFile == null
0203:                            configFile = new File("null");
0204:                        }
0205:
0206:                        if (configFile.exists()) {
0207:                            doc = db.parse(configFile);
0208:                        }
0209:                    }
0210:
0211:                    if (doc == null) {
0212:                        if (strType.equalsIgnoreCase("source")) {
0213:                            this .logger
0214:                                    .write("normal",
0215:                                            "Failed to load config file for source database, load default configuration.");
0216:                            this .strDriverClassName = "org.relique.jdbc.csv.CsvDriver";
0217:                            this .iFirstColumnResult = 1;
0218:                            this .bRequiredUser = false;
0219:                            this .bEnableJumpResult = false;
0220:                            this .bAfterLastRow = true;
0221:                            this .bEnableOrderBy = false;
0222:                            if (driverName == null || driverName.equals(""))
0223:                                driverName = "csv";
0224:                            this .bFileSystemDatabase = true;
0225:                        } else {
0226:                            this .logger
0227:                                    .write("normal",
0228:                                            "Failed to load config file for target database, load default configuration.");
0229:                            this .strDriverClassName = "com.newatlanta.jturbo.driver.Driver";
0230:                            this .iFirstColumnResult = 1;
0231:                            this .bRequiredUser = true;
0232:                            if (driverName == null || driverName.equals(""))
0233:                                driverName = "jTurbo";
0234:                        }
0235:                    }
0236:                } catch (Exception e) {
0237:                    this .logger.write("normal", "Sorry, an error occurred: "
0238:                            + e.getMessage());
0239:                    LoaderException le = new LoaderException("Exception: ",
0240:                            (Throwable) e);
0241:                    throw le;
0242:                }
0243:
0244:                String strDriverName = "";
0245:                if (doc != null) {
0246:                    if (driverName == null || driverName.equalsIgnoreCase("")) {
0247:                        if (dbVendor.equalsIgnoreCase("MSQL"))
0248:                            driverName = "jTurbo";
0249:                    }
0250:
0251:                    //read values from tag OidDbType
0252:                    if (doc.getElementsByTagName("OidDbType").getLength() != 0) {
0253:                        NodeList tagOidDbType = doc
0254:                                .getElementsByTagName("OidDbType");
0255:                        Node tempChildNode = tagOidDbType.item(0)
0256:                                .getFirstChild();
0257:                        if (tempChildNode != null) {
0258:                            this .oidDbType = tagOidDbType.item(0)
0259:                                    .getFirstChild().getNodeValue();
0260:                        } else {
0261:                            LoaderException le = new LoaderException(
0262:                                    "You must set data in tag <OidDbType> in conf file for database vendor!");
0263:                            throw le;
0264:                        }
0265:                    } else {
0266:                        LoaderException le = new LoaderException(
0267:                                "Tag <OidDbType> doesn't exist in conf file for database vendor. You must set this tag with appropriate value.");
0268:                        throw le;
0269:                    }
0270:
0271:                    //read values from tag VersionDbType
0272:                    if (doc.getElementsByTagName("VersionDbType").getLength() != 0) {
0273:                        NodeList tagVersionDbType = doc
0274:                                .getElementsByTagName("VersionDbType");
0275:                        Node tempChildNode = tagVersionDbType.item(0)
0276:                                .getFirstChild();
0277:                        if (tempChildNode != null) {
0278:                            this .versionDbType = tagVersionDbType.item(0)
0279:                                    .getFirstChild().getNodeValue();
0280:                        } else {
0281:                            LoaderException le = new LoaderException(
0282:                                    "You must set data in tag <VersionDbType>in conf file for database vendor!");
0283:                            throw le;
0284:                        }
0285:                    } else {
0286:                        LoaderException le = new LoaderException(
0287:                                "Tag <VersionDbType> doesn't exist in conf file for database vendor. You must set this tag with appropriate value.");
0288:                        throw le;
0289:                    }
0290:
0291:                    //read values from tag OidDbColumnName
0292:                    if (doc.getElementsByTagName("OidDbColumnName").getLength() != 0) {
0293:                        NodeList tagOidColumnName = doc
0294:                                .getElementsByTagName("OidDbColumnName");
0295:                        Node tempChildNode = tagOidColumnName.item(0)
0296:                                .getFirstChild();
0297:                        if (tempChildNode != null) {
0298:                            this .oidColumnName = tagOidColumnName.item(0)
0299:                                    .getFirstChild().getNodeValue();
0300:                        } else {
0301:                            LoaderException le = new LoaderException(
0302:                                    "You must set data in tag <OidDbColumnName> in conf file for database vendor.");
0303:                            throw le;
0304:                        }
0305:                    } else {
0306:                        LoaderException le = new LoaderException(
0307:                                "Tag <OidDbColumnName> doesn't exist in conf file for database vendor.You must set this tag with appropriate value.");
0308:                        throw le;
0309:                    }
0310:
0311:                    //read values from tag VersionDbColumnName
0312:                    if (doc.getElementsByTagName("VersionDbColumnName")
0313:                            .getLength() != 0) {
0314:                        NodeList tagVersionColumnName = doc
0315:                                .getElementsByTagName("VersionDbColumnName");
0316:                        Node tempChildNode = tagVersionColumnName.item(0)
0317:                                .getFirstChild();
0318:                        if (tempChildNode != null) {
0319:                            this .versionColumnName = tagVersionColumnName.item(
0320:                                    0).getFirstChild().getNodeValue();
0321:                        } else {
0322:                            LoaderException le = new LoaderException(
0323:                                    "You must set data in tag <VersionDbColumnName> in conf file for database vendor.");
0324:                            throw le;
0325:                        }
0326:                    } else {
0327:                        LoaderException le = new LoaderException(
0328:                                "Tag <VersionDbColumnName> doesn't exist in conf file for database vendor. You must set this tag with appropriate value.");
0329:                        throw le;
0330:                    }
0331:
0332:                    //read values from tag DateFormat
0333:                    if (doc.getElementsByTagName("DateFormat").getLength() != 0) {
0334:                        NodeList tagDateFormat = doc
0335:                                .getElementsByTagName("DateFormat");
0336:                        Node tempChildNode = tagDateFormat.item(0)
0337:                                .getFirstChild();
0338:                        if (tempChildNode != null) {
0339:                            this .dateFormat = tagDateFormat.item(0)
0340:                                    .getFirstChild().getNodeValue();
0341:                        }
0342:                    } else {
0343:                        LoaderException le = new LoaderException(
0344:                                "Tag <DateFormat> doesn't exist in conf file for database vendor. You must set this tag with appropriate value.");
0345:                        throw le;
0346:                    }
0347:
0348:                    //if(strType.equalsIgnoreCase("target")){
0349:                    NodeList tagJavaType = doc.getElementsByTagName("SQLType");
0350:                    Node nodeJavaTMain = tagJavaType.item(0);
0351:                    NodeList dataTypeNodes = nodeJavaTMain.getChildNodes();
0352:                    String nodeAttrIsNumber = "";
0353:                    String nodeAttrIsBinary = "";
0354:                    String nodeAttrIsDate = "";
0355:                    String nodeAttrIsWithN = "";
0356:                    for (int i = 0; i < dataTypeNodes.getLength(); i++) {
0357:                        if (dataTypeNodes.item(i).getNodeType() == Node.ELEMENT_NODE) {
0358:                            String nodeName = dataTypeNodes.item(i)
0359:                                    .getNodeName();
0360:                            String nodeAttr = dataTypeNodes.item(i)
0361:                                    .getAttributes().getNamedItem("javaType")
0362:                                    .getNodeValue();
0363:                            //ZK added this 6.5.2004
0364:                            if (dataTypeNodes.item(i).getAttributes()
0365:                                    .getNamedItem("isNumber") != null) {
0366:                                nodeAttrIsNumber = dataTypeNodes.item(i)
0367:                                        .getAttributes().getNamedItem(
0368:                                                "isNumber").getNodeValue();
0369:                            } else {
0370:                                nodeAttrIsNumber = "false";
0371:                            }
0372:
0373:                            if (dataTypeNodes.item(i).getAttributes()
0374:                                    .getNamedItem("isBinary") != null) {
0375:                                nodeAttrIsBinary = dataTypeNodes.item(i)
0376:                                        .getAttributes().getNamedItem(
0377:                                                "isBinary").getNodeValue();
0378:                            } else {
0379:                                nodeAttrIsBinary = "false";
0380:                            }
0381:
0382:                            if (dataTypeNodes.item(i).getAttributes()
0383:                                    .getNamedItem("isDate") != null) {
0384:                                nodeAttrIsDate = dataTypeNodes.item(i)
0385:                                        .getAttributes().getNamedItem("isDate")
0386:                                        .getNodeValue();
0387:                            } else {
0388:                                nodeAttrIsDate = "false";
0389:                            }
0390:
0391:                            if (dataTypeNodes.item(i).getAttributes()
0392:                                    .getNamedItem("isWithN") != null) {
0393:                                nodeAttrIsWithN = dataTypeNodes.item(i)
0394:                                        .getAttributes()
0395:                                        .getNamedItem("isWithN").getNodeValue();
0396:                            } else {
0397:                                nodeAttrIsWithN = "false";
0398:                            }
0399:
0400:                            //end
0401:                            String nodeAttrInt;
0402:                            if (nodeAttr.equalsIgnoreCase("byte[]"))
0403:                                nodeAttrInt = BYTE_ARRAY;
0404:                            else if (nodeAttr
0405:                                    .equalsIgnoreCase("java.math.BigDecimal"))
0406:                                nodeAttrInt = JAVA_MATH_BIGDECIMAL;
0407:                            else if (nodeAttr
0408:                                    .equalsIgnoreCase("java.lang.Double"))
0409:                                nodeAttrInt = JAVA_LANG_DOUBLE;
0410:                            else if (nodeAttr
0411:                                    .equalsIgnoreCase("java.lang.Float"))
0412:                                nodeAttrInt = JAVA_LANG_FLOAT;
0413:                            else if (nodeAttr
0414:                                    .equalsIgnoreCase("java.lang.Integer"))
0415:                                nodeAttrInt = JAVA_LANG_INTEGER;
0416:                            else if (nodeAttr
0417:                                    .equalsIgnoreCase("java.lang.Long"))
0418:                                nodeAttrInt = JAVA_LANG_LONG;
0419:                            else if (nodeAttr
0420:                                    .equalsIgnoreCase("java.lang.Short"))
0421:                                nodeAttrInt = JAVA_LANG_SHORT;
0422:                            else if (nodeAttr
0423:                                    .equalsIgnoreCase("java.lang.String"))
0424:                                nodeAttrInt = JAVA_LANG_STRING;
0425:                            else if (nodeAttr.equalsIgnoreCase("java.sql.Date"))
0426:                                nodeAttrInt = JAVA_SQL_DATE;
0427:                            else if (nodeAttr.equalsIgnoreCase("java.sql.Time"))
0428:                                nodeAttrInt = JAVA_SQL_TIME;
0429:                            else if (nodeAttr
0430:                                    .equalsIgnoreCase("java.sql.Timestamp"))
0431:                                nodeAttrInt = JAVA_SQL_TIMESTAMP;
0432:                            else if (nodeAttr
0433:                                    .equalsIgnoreCase("java.lang.Boolean"))
0434:                                nodeAttrInt = JAVA_LANG_BOOLEAN;
0435:                            else if (nodeAttr
0436:                                    .equalsIgnoreCase("java.lang.Byte"))
0437:                                nodeAttrInt = JAVA_LANG_BYTE;
0438:                            else
0439:                                nodeAttrInt = JAVA_LANG_OBJECT;
0440:
0441:                            //REPLACE ALL __ WITH SPACES
0442:                            nodeName = Utils.replaceAll(nodeName,
0443:                                    ConfigReader.SPACE_ESCAPE, " ");
0444:
0445:                            isNumberMapp.put(nodeName.toLowerCase(),
0446:                                    nodeAttrIsNumber);
0447:
0448:                            isBinaryObjectMap.put(nodeName.toLowerCase(),
0449:                                    nodeAttrIsBinary);
0450:
0451:                            isDateMap.put(nodeName.toLowerCase(),
0452:                                    nodeAttrIsDate);
0453:
0454:                            isWithNMap.put(nodeName.toLowerCase(),
0455:                                    nodeAttrIsWithN);
0456:
0457:                            javaTypeMapp.put(nodeName, nodeAttrInt);
0458:                        }
0459:                    }
0460:                    //}
0461:                    NodeList tagDbVendor = doc.getElementsByTagName("Driver");
0462:                    out: for (int i = 0; i < tagDbVendor.getLength(); i++) {
0463:                        Node nodeMain = tagDbVendor.item(i);
0464:                        NamedNodeMap attrs = nodeMain.getAttributes();
0465:                        Node nodeDriver = attrs.getNamedItem("name");
0466:                        if (nodeDriver != null) {
0467:                            strDriverName = nodeDriver.getNodeValue();
0468:                            if (driverName == null
0469:                                    || driverName.equalsIgnoreCase(""))
0470:                                driverName = strDriverName;
0471:                            if (!(driverName == null || driverName
0472:                                    .equalsIgnoreCase(""))) {
0473:                                if (strDriverName.equalsIgnoreCase(driverName)) {
0474:                                    NodeList configNodes = nodeMain
0475:                                            .getChildNodes();
0476:                                    for (int j = 0; j < configNodes.getLength(); j++) {
0477:                                        if (configNodes.item(j).getNodeName()
0478:                                                .equalsIgnoreCase(
0479:                                                        "FirstColumnResult")) {
0480:                                            NamedNodeMap configAttributes = null;
0481:                                            Node nodeValue = null;
0482:                                            configAttributes = configNodes
0483:                                                    .item(j).getAttributes();
0484:                                            if (configAttributes != null) {
0485:                                                if ((nodeValue = configAttributes
0486:                                                        .getNamedItem("value")) != null) {
0487:                                                    this .iFirstColumnResult = Integer
0488:                                                            .parseInt(nodeValue
0489:                                                                    .getNodeValue());
0490:                                                }
0491:                                            }
0492:                                        } else if (configNodes.item(j)
0493:                                                .getNodeName()
0494:                                                .equalsIgnoreCase(
0495:                                                        "RequiredUser")) {
0496:                                            NamedNodeMap configAttributes = null;
0497:                                            Node nodeValue = null;
0498:                                            configAttributes = configNodes
0499:                                                    .item(j).getAttributes();
0500:                                            if (configAttributes != null) {
0501:                                                if ((nodeValue = configAttributes
0502:                                                        .getNamedItem("value")) != null) {
0503:                                                    this .bRequiredUser = (new Boolean(
0504:                                                            nodeValue
0505:                                                                    .getNodeValue()))
0506:                                                            .booleanValue();
0507:                                                }
0508:                                            }
0509:                                        } else if (configNodes.item(j)
0510:                                                .getNodeName()
0511:                                                .equalsIgnoreCase(
0512:                                                        "EnableJumpInResult")) {
0513:                                            NamedNodeMap configAttributes = null;
0514:                                            Node nodeValue = null;
0515:                                            configAttributes = configNodes
0516:                                                    .item(j).getAttributes();
0517:                                            if (configAttributes != null) {
0518:                                                if ((nodeValue = configAttributes
0519:                                                        .getNamedItem("value")) != null) {
0520:                                                    this .bEnableJumpResult = (new Boolean(
0521:                                                            nodeValue
0522:                                                                    .getNodeValue()))
0523:                                                            .booleanValue();
0524:                                                }
0525:                                            }
0526:                                        } else if (configNodes.item(j)
0527:                                                .getNodeName()
0528:                                                .equalsIgnoreCase( //
0529:                                                        "Connection")) {
0530:                                            NamedNodeMap configAttributes = null;
0531:                                            Node nodeValue = null;
0532:                                            configAttributes = configNodes
0533:                                                    .item(j).getAttributes();
0534:                                            if (configAttributes != null) {
0535:                                                if ((nodeValue = configAttributes
0536:                                                        .getNamedItem("value")) != null) {
0537:                                                    this .bConnectionPrefix = nodeValue
0538:                                                            .getNodeValue();
0539:                                                }
0540:                                            }
0541:                                        } else if (configNodes.item(j)
0542:                                                .getNodeName()
0543:                                                .equalsIgnoreCase( //
0544:                                                        "AfterLastRow")) {
0545:                                            NamedNodeMap configAttributes = null;
0546:                                            Node nodeValue = null;
0547:                                            configAttributes = configNodes
0548:                                                    .item(j).getAttributes();
0549:                                            if (configAttributes != null) {
0550:                                                if ((nodeValue = configAttributes
0551:                                                        .getNamedItem("value")) != null) {
0552:                                                    this .bAfterLastRow = (new Boolean(
0553:                                                            nodeValue
0554:                                                                    .getNodeValue()))
0555:                                                            .booleanValue();
0556:                                                }
0557:                                            }
0558:                                        } else if (configNodes.item(j)
0559:                                                .getNodeName()
0560:                                                .equalsIgnoreCase(
0561:                                                        "EnableOrderBy")) {
0562:                                            NamedNodeMap configAttributes = null;
0563:                                            Node nodeValue = null;
0564:                                            configAttributes = configNodes
0565:                                                    .item(j).getAttributes();
0566:                                            if (configAttributes != null) {
0567:                                                if ((nodeValue = configAttributes
0568:                                                        .getNamedItem("value")) != null) {
0569:                                                    this .bEnableOrderBy = (new Boolean(
0570:                                                            nodeValue
0571:                                                                    .getNodeValue()))
0572:                                                            .booleanValue();
0573:                                                }
0574:                                            }
0575:                                        } else if (configNodes.item(j)
0576:                                                .getNodeName()
0577:                                                .equalsIgnoreCase("ClassName")) {
0578:                                            NamedNodeMap configAttributes = null;
0579:                                            Node nodeValue = null;
0580:                                            configAttributes = configNodes
0581:                                                    .item(j).getAttributes();
0582:                                            if (configAttributes != null) {
0583:                                                if ((nodeValue = configAttributes
0584:                                                        .getNamedItem("value")) != null) {
0585:                                                    this .strDriverClassName = (nodeValue
0586:                                                            .getNodeValue())
0587:                                                            .toString();
0588:                                                }
0589:                                            }
0590:                                        } else if (configNodes.item(j)
0591:                                                .getNodeName()
0592:                                                .equalsIgnoreCase( //
0593:                                                        "RowCountEnabled")) {
0594:                                            NamedNodeMap configAttributes = null;
0595:                                            Node nodeValue = null;
0596:                                            configAttributes = configNodes
0597:                                                    .item(j).getAttributes();
0598:                                            if (configAttributes != null) {
0599:                                                if ((nodeValue = configAttributes
0600:                                                        .getNamedItem("value")) != null) {
0601:                                                    this .bRowCountEnabled = (new Boolean(
0602:                                                            nodeValue
0603:                                                                    .getNodeValue()))
0604:                                                            .booleanValue();
0605:                                                }
0606:                                            }
0607:                                        } else if (configNodes.item(j)
0608:                                                .getNodeName()
0609:                                                .equalsIgnoreCase( //
0610:                                                        "SetFetchSizeEnabled")) {
0611:                                            NamedNodeMap configAttributes = null;
0612:                                            Node nodeValue = null;
0613:                                            configAttributes = configNodes
0614:                                                    .item(j).getAttributes();
0615:                                            if (configAttributes != null) {
0616:                                                if ((nodeValue = configAttributes
0617:                                                        .getNamedItem("value")) != null) {
0618:                                                    this .bSetFetchSizeEnabled = (new Boolean(
0619:                                                            nodeValue
0620:                                                                    .getNodeValue()))
0621:                                                            .booleanValue();
0622:                                                }
0623:                                            }
0624:                                        } else if (configNodes.item(j)
0625:                                                .getNodeName()
0626:                                                .equalsIgnoreCase( //
0627:                                                        "SetCursorNameEnabled")) {
0628:                                            NamedNodeMap configAttributes = null;
0629:                                            Node nodeValue = null;
0630:                                            configAttributes = configNodes
0631:                                                    .item(j).getAttributes();
0632:                                            if (configAttributes != null) {
0633:                                                if ((nodeValue = configAttributes
0634:                                                        .getNamedItem("value")) != null) {
0635:                                                    this .bSetCursorNameEnabled = (new Boolean(
0636:                                                            nodeValue
0637:                                                                    .getNodeValue()))
0638:                                                            .booleanValue();
0639:                                                }
0640:                                            }
0641:                                        } else if (configNodes.item(j)
0642:                                                .getNodeName()
0643:                                                .equalsIgnoreCase( //
0644:                                                        "SetEmptyStringAsNull")) {
0645:                                            NamedNodeMap configAttributes = null;
0646:                                            Node nodeValue = null;
0647:                                            configAttributes = configNodes
0648:                                                    .item(j).getAttributes();
0649:                                            if (configAttributes != null) {
0650:                                                if ((nodeValue = configAttributes
0651:                                                        .getNamedItem("value")) != null) {
0652:                                                    this .bSetEmptyStringAsNull = (new Boolean(
0653:                                                            nodeValue
0654:                                                                    .getNodeValue()))
0655:                                                            .booleanValue();
0656:                                                }
0657:                                            }
0658:                                        } else if (configNodes.item(j)
0659:                                                .getNodeName()
0660:                                                .equalsIgnoreCase( //
0661:                                                        "ReadingOrderRelevant")) {
0662:                                            NamedNodeMap configAttributes = null;
0663:                                            Node nodeValue = null;
0664:                                            configAttributes = configNodes
0665:                                                    .item(j).getAttributes();
0666:                                            if (configAttributes != null) {
0667:                                                if ((nodeValue = configAttributes
0668:                                                        .getNamedItem("value")) != null) {
0669:                                                    this .bReadingOrderRelevant = (new Boolean(
0670:                                                            nodeValue
0671:                                                                    .getNodeValue()))
0672:                                                            .booleanValue();
0673:                                                }
0674:                                            }
0675:                                        } else if (configNodes.item(j)
0676:                                                .getNodeName()
0677:                                                .equalsIgnoreCase( //
0678:                                                        "FileSystemDatabase")) {
0679:                                            NamedNodeMap configAttributes = null;
0680:                                            Node nodeValue = null;
0681:                                            configAttributes = configNodes
0682:                                                    .item(j).getAttributes();
0683:                                            if (configAttributes != null) {
0684:                                                if ((nodeValue = configAttributes
0685:                                                        .getNamedItem("value")) != null) {
0686:                                                    this .bFileSystemDatabase = (new Boolean(
0687:                                                            nodeValue
0688:                                                                    .getNodeValue()))
0689:                                                            .booleanValue();
0690:                                                }
0691:                                            }
0692:                                        } else if (configNodes.item(j)
0693:                                                .getNodeName()
0694:                                                .equalsIgnoreCase( //
0695:                                                        "GetColumnsSupported")) {
0696:                                            NamedNodeMap configAttributes = null;
0697:                                            Node nodeValue = null;
0698:                                            configAttributes = configNodes
0699:                                                    .item(j).getAttributes();
0700:                                            if (configAttributes != null) {
0701:                                                if ((nodeValue = configAttributes
0702:                                                        .getNamedItem("value")) != null) {
0703:                                                    this .bGetColumnsSupported = (new Boolean(
0704:                                                            nodeValue
0705:                                                                    .getNodeValue()))
0706:                                                            .booleanValue();
0707:                                                }
0708:                                            }
0709:                                        } else if (configNodes.item(j)
0710:                                                .getNodeName()
0711:                                                .equalsIgnoreCase( //
0712:                                                        "SetMaxRowsSupported")) {
0713:                                            NamedNodeMap configAttributes = null;
0714:                                            Node nodeValue = null;
0715:                                            configAttributes = configNodes
0716:                                                    .item(j).getAttributes();
0717:                                            if (configAttributes != null) {
0718:                                                if ((nodeValue = configAttributes
0719:                                                        .getNamedItem("value")) != null) {
0720:                                                    this .bSetMaxRowsSupported = (new Boolean(
0721:                                                            nodeValue
0722:                                                                    .getNodeValue()))
0723:                                                            .booleanValue();
0724:                                                }
0725:                                            }
0726:                                        }
0727:
0728:                                    } //configNodes.getLength()
0729:                                    break out;
0730:                                }
0731:                            }
0732:                        }
0733:                    }
0734:                }
0735:                this .logger.write("full",
0736:                        "\treadConfigValues method is finished.");
0737:            }
0738:
0739:            /**
0740:             * This method read value of javaTypeMapp parameter
0741:             * @return value of javaTypeMapp attribute.
0742:             */
0743:            public Hashtable getJavaTypeMapings() {
0744:                return this .javaTypeMapp;
0745:            }
0746:
0747:            /**
0748:             * This method read value of isNumberMapp parameter
0749:             * @return value of javaTypeMapp attribute.
0750:             */
0751:            public Hashtable getIsNumberMapp() {
0752:                return this .isNumberMapp;
0753:            }
0754:
0755:            /**
0756:             * Method isNumber is used for checking column type.
0757:             * @param s String that represents column type.
0758:             * @return true if it is numeric and false if it is not.
0759:             */
0760:            public boolean isNumber(String s) throws LoaderException {
0761:                if (s != null)
0762:                    s = s.toLowerCase();
0763:                boolean isNumber = false;
0764:                //		TODO TEST THIS!!!ZK added next line because of problems with LONG VARCHAR on DB2
0765:                //s = Utils.replaceAll(s," ","_");
0766:                //		TODO ZK added next line because of problems with LONG VARCHAR on DB2
0767:                //				   if (s.equalsIgnoreCase("LONG VARCHAR")){
0768:                //				       s = "long_varchar";
0769:                //				   }
0770:                if (this .isNumberMapp.containsKey(s)) {
0771:                    Object bValue = this .isNumberMapp.get(s);
0772:                    if (bValue != null
0773:                            && (bValue.toString()).equalsIgnoreCase("true")) {
0774:                        //return (new Boolean(bValue.toString()).booleanValue());
0775:                        return true;
0776:                    }
0777:                } else {
0778:                    LoaderException le = new LoaderException(
0779:                            "Exception:",
0780:                            new Exception(
0781:                                    "Type "
0782:                                            + s
0783:                                            + " is not supported. You must add it in conf file for this database vendor."));
0784:                    throw le;
0785:                }
0786:                return isNumber;
0787:
0788:            }
0789:
0790:            /**
0791:             * Method isNumber is used for checking column type.
0792:             * @param s String that represents column type.
0793:             * @return true if it is numeric and false if it is not.
0794:             */
0795:            public boolean isBinaryObject(String s) throws LoaderException {
0796:                if (s != null)
0797:                    s = s.toLowerCase();
0798:                boolean isBinaryObject = false;
0799:                //TODO TEST THIS!!!ZK added next line because of problems with LONG VARCHAR on DB2
0800:                //s = Utils.replaceAll(s," ","_");
0801:                //TODO ZK added next line because of problems with LONG VARCHAR on DB2
0802:                //			 if (s.equalsIgnoreCase("LONG VARCHAR")){
0803:                //			 s = "long_varchar";
0804:                //			 }
0805:                //end
0806:                if (this .isBinaryObjectMap.containsKey(s)) {
0807:
0808:                    Object bValue = this .isBinaryObjectMap.get(s);
0809:                    if (bValue != null
0810:                            && (bValue.toString()).equalsIgnoreCase("true")) {
0811:                        //return (new Boolean(bValue.toString()).booleanValue());
0812:                        return true;
0813:                    }
0814:                } else {
0815:                    LoaderException le = new LoaderException(
0816:                            "Exception:",
0817:                            new Exception(
0818:                                    "Type "
0819:                                            + s
0820:                                            + " is not supported. You must add it in conf file for this database vendor."));
0821:                    throw le;
0822:                }
0823:                return isBinaryObject;
0824:
0825:            }
0826:
0827:            /**
0828:             * Method isDate is used for checking column type.
0829:             * @param s String that represents column type.
0830:             * @return true if it is numeric and false if it is not.
0831:             */
0832:            public boolean isDate(String s) throws LoaderException {
0833:                if (s != null)
0834:                    s = s.toLowerCase();
0835:                boolean isDate = false;
0836:                //TODO TEST THIS!!!ZK added next line because of problems with LONG VARCHAR on DB2
0837:                //s = Utils.replaceAll(s," ","_");
0838:                //TODO ZK added next line because of problems with LONG VARCHAR on DB2
0839:                //			if (s.equalsIgnoreCase("LONG VARCHAR")){
0840:                //				s = "long_varchar";
0841:                //			}
0842:                //end
0843:                if (this .isDateMap.containsKey(s)) {
0844:                    Object dValue = this .isDateMap.get(s);
0845:                    if ((dValue != null)
0846:                            && (dValue.toString()).equalsIgnoreCase("true")) {
0847:                        //return (new Boolean(dValue.toString()).booleanValue());
0848:                        return true;
0849:                    }
0850:
0851:                } else {
0852:                    LoaderException le = new LoaderException(
0853:                            "Exception:",
0854:                            new Exception(
0855:                                    "Type "
0856:                                            + s
0857:                                            + " is not supported. You must add it in conf file for this database vendor."));
0858:                    throw le;
0859:                }
0860:                return isDate;
0861:
0862:            }
0863:
0864:            /**
0865:             * Method isWithN is used for checking column type.
0866:             * @param s String that represents column type.
0867:             * @return true if it is numeric and false if it is not.
0868:             */
0869:            public boolean isWithN(String s) throws LoaderException {
0870:                if (s != null)
0871:                    s = s.toLowerCase();
0872:                boolean isWithN = false;
0873:                //				if (s.equalsIgnoreCase("LONG VARCHAR")){
0874:                //					s = "long_varchar";
0875:                //				}
0876:                if (this .isWithNMap.containsKey(s)) {
0877:                    Object bValue = this .isWithNMap.get(s);
0878:                    if (bValue != null
0879:                            && (bValue.toString()).equalsIgnoreCase("true")) {
0880:                        return true;
0881:                    }
0882:                } else {
0883:                    LoaderException le = new LoaderException(
0884:                            "Exception:",
0885:                            new Exception(
0886:                                    "Type "
0887:                                            + s
0888:                                            + " is not supported. You must add it in conf file for this database vendor."));
0889:                    throw le;
0890:                }
0891:                return isWithN;
0892:
0893:            }
0894:
0895:            /**
0896:             * This method read value of bGetColumnsSupported parameter
0897:             * @return value of bGetColumnsSupported attribute.
0898:             */
0899:            public boolean getColumnsSupported() {
0900:                return this .bGetColumnsSupported;
0901:            }
0902:
0903:            /**
0904:             * This method read value of bSetMaxRowsSupported parameter
0905:             * @return value of bSetMaxRowsSupported attribute.
0906:             */
0907:            public boolean getMaxRowsSupported() {
0908:                return this .bSetMaxRowsSupported;
0909:            }
0910:
0911:            /**
0912:             * This method read value of oidColumnName parameter
0913:             * @return value of oidColumnName attribute.
0914:             */
0915:            public String getOidColumnName() {
0916:                return this .oidColumnName;
0917:            }
0918:
0919:            /**
0920:             * This method read value of versionColumnName parameter
0921:             * @return value of versionColumnName attribute.
0922:             */
0923:            public String getVersionColumnName() {
0924:                return this .versionColumnName;
0925:            }
0926:
0927:            /**
0928:             * This method read value of bConnectionPrefix parameter
0929:             * @return value of bConnectionPrefix attribute.
0930:             */
0931:            public String getConnectionPrefix() {
0932:                return this .bConnectionPrefix;
0933:            }
0934:
0935:            /**
0936:             * This method read value of bReadingOrderRelevant parameter
0937:             * @return value of bReadingOrderRelevant attribute.
0938:             */
0939:            public boolean getReadingOrderRelevant() {
0940:                return this .bReadingOrderRelevant;
0941:            }
0942:
0943:            /**
0944:             * This method read value of bSetEmptyStringAsNull parameter
0945:             * @return value of bSetEmptyStringAsNull attribute.
0946:             */
0947:            public boolean getSetEmptyStringAsNull() {
0948:                return this .bSetEmptyStringAsNull;
0949:            }
0950:
0951:            /**
0952:             * This method read value of bSetCursorNameEnabled parameter
0953:             * @return value of bSetCursorNameEnabled attribute.
0954:             */
0955:            public boolean getSetCursorNameEnabled() {
0956:                return this .bSetCursorNameEnabled;
0957:            }
0958:
0959:            /**
0960:             * This method read value of bSetFetchSizeEnabled parameter
0961:             * @return value of bSetFetchSizeEnabled attribute.
0962:             */
0963:            public boolean getSetFetchSizeEnabled() {
0964:                return this .bSetFetchSizeEnabled;
0965:            }
0966:
0967:            /**
0968:             * This method read value of bRowCountEnabled parameter
0969:             * @return value of bRowCountEnabled attribute.
0970:             */
0971:            public boolean getRowCountEnabled() {
0972:                return this .bRowCountEnabled;
0973:            }
0974:
0975:            /**
0976:             * This method read value of bEnableOrderBy parameter
0977:             * @return value of EnableOrderBy attribute.
0978:             */
0979:            public boolean getEnableOrderBy() {
0980:                return this .bEnableOrderBy;
0981:            }
0982:
0983:            /**
0984:             * This method read value of bAfterLastRow parameter
0985:             * @return value of AfterLastRow attribute.
0986:             */
0987:            public boolean getAfterLastRow() {
0988:                return this .bAfterLastRow;
0989:            }
0990:
0991:            /**
0992:             * This method read value of bFileSystemDatabase parameter
0993:             * @return value of bFileSystemDatabase attribute.
0994:             */
0995:            public boolean getFileSystemDatabase() {
0996:                return this .bFileSystemDatabase;
0997:            }
0998:
0999:            /**
1000:             * This method read value of bEnableJumpResult parameter
1001:             * @return value of EnableJumpResult attribute.
1002:             */
1003:            public boolean getEnableJumpResult() {
1004:                return this .bEnableJumpResult;
1005:            }
1006:
1007:            /**
1008:             * This method read value of bRequiredUser parameter
1009:             * @return value of RequiredUser attribute.
1010:             */
1011:            public boolean getRequiredUser() {
1012:                return this .bRequiredUser;
1013:            }
1014:
1015:            /**
1016:             * This method read value of iFirstColumnResult parameter
1017:             * @return value of FirstColumnResult attribute.
1018:             */
1019:            public int getFirstColumnResult() {
1020:                return this .iFirstColumnResult;
1021:            }
1022:
1023:            /**
1024:             * This method read value of strDriverClassName parameter
1025:             * @return value of SourceDriverClassName attribute.
1026:             */
1027:            public String getDriverClassName() {
1028:                return this .strDriverClassName;
1029:            }
1030:
1031:            /**
1032:             * This method read value of strVendorFileName parameter
1033:             * @return value of VendorFileName attribute.
1034:             */
1035:            public String getVendorFileName() {
1036:                return this .strVendorFileName;
1037:            }
1038:
1039:            /**
1040:             * This method set value of strVendorFileName parameter
1041:             * @param fileName set dbVendorFileName which is used for reading separated database conf files.
1042:             */
1043:            public void setVendorFileName(String fileName) {
1044:                this .strVendorFileName = fileName;
1045:            }
1046:
1047:            /**
1048:             * This method set value of echo parameter
1049:             * @param logger set Logger which is used for log file.
1050:             */
1051:            public void setLogger(Logger logger) {
1052:                this .logger = logger;
1053:            }
1054:
1055:            /**
1056:             * This method read value from parameter
1057:             * @return value of parameter
1058:             */
1059:            public String getOidDbType() {
1060:                return this .oidDbType;
1061:            }
1062:
1063:            /**
1064:             * This method read value from parameter
1065:             * @return value of parameter
1066:             */
1067:            public String getVersionDbType() {
1068:                return this .versionDbType;
1069:            }
1070:
1071:            /**
1072:             * This method read value from parameter
1073:             * @return value of parameter
1074:             */
1075:            public String getDateFormat() {
1076:                return this .dateFormat;
1077:            }
1078:
1079:            /**
1080:             * This method set value of confJarStructure parameter
1081:             * @param confJarStructure is value of parameter
1082:             */
1083:            public void setConfJarStructure(String confJarStructure) {
1084:                if (confJarStructure != null
1085:                        && !confJarStructure.equalsIgnoreCase("")) {
1086:                    if (confJarStructure.endsWith("/")
1087:                            || confJarStructure.endsWith("\\"))
1088:                        confJarStructure = confJarStructure.substring(0,
1089:                                confJarStructure.length() - 1);
1090:
1091:                    this .confJarStructure = confJarStructure;
1092:                    this .useSeparateConfFiles = true;
1093:                }
1094:            }
1095:
1096:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.