Source Code Cross Referenced for SqlElement.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) 


001:        /**
002:          SqlElement - Sql element in xml file.
003:            Copyright (C) 2002-2003  Together
004:            This library is free software; you can redistribute it and/or
005:            modify it under the terms of the GNU Lesser General Public
006:            License as published by the Free Software Foundation; either
007:            version 2.1 of the License, or (at your option) any later version.
008:            This library is distributed in the hope that it will be useful,
009:            but WITHOUT ANY WARRANTY; without even the implied warranty of
010:            MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
011:            Lesser General Public License for more details.
012:            You should have received a copy of the GNU Lesser General Public
013:            License along with this library; if not, write to the Free Software
014:            Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
015:         SqlElement.java
016:         Date: 20.5.2003.
017:         @version 1.0.0
018:         @author: Zoran Milakovic zoran@prozone.co.yu
019:         */package org.webdocwf.util.loader;
020:
021:        import java.io.*;
022:        import java.util.*;
023:        import javax.xml.parsers.*;
024:        import org.w3c.dom.*;
025:        import org.webdocwf.util.loader.logging.*;
026:
027:        /**
028:         * Class is wrapper for SqlElement tag in XML file.
029:         *
030:         * @author     Zoran Milakovic
031:         * @version    1.1
032:         */
033:        public class SqlElement {
034:
035:            private String strSqlName = "";
036:            //private String strSqlLogMode = "";
037:            private String strSqlOnErrorContinue = "";
038:            private String strSqlCommit = "";
039:
040:            //  String strLogMode = "";
041:            private String strDefaultLogMode = "";
042:            private boolean bOnErrorContinue;
043:            private boolean bDefaultOnErrorContinue = false;
044:            private boolean bDefaultCommit = true;
045:            //  private String strTargetDbVendor = "";
046:            //  private String strTargetDriverName = "";
047:
048:            //  private String strJDBCTargetParameterDriver = "";
049:            //  private String strJDBCTargetParameterConnection = "";
050:            //  private String strJDBCTargetParameterUser = "";
051:            //  private String strJDBCTargetParameterPassword = "";
052:            //  private String strTargetDriverClassName = "";
053:
054:            private JdbcParametersElement jdbcParametersElement;
055:            private ConfigReader configReader;
056:            private Logger logger;
057:            private LoaderJobAttrReader loaderJobReader;
058:
059:            /**
060:             * Method parseSql is used to analyse import XML file
061:             * about sql tags. Return number of sql elements in a whole xml input file.
062:             * @param inStream Data from inputXML file which is converted into InputStream.
063:             * @return Number of sql tags in an input XML file.
064:             * @throws LoaderException
065:             */
066:            public int parseSql(InputStream inStream) throws LoaderException {
067:                int iNumTagsImportJob = 0;
068:                Document doc = null;
069:                this .logger.write("full", "\tparseSql method is started.");
070:                try {
071:                    DocumentBuilderFactory dbf = DocumentBuilderFactory
072:                            .newInstance();
073:                    DocumentBuilder db = null;
074:                    db = dbf.newDocumentBuilder();
075:                    doc = db.parse(inStream);
076:                } catch (Exception e) {
077:                    this .logger.write("normal", "Sorry, an error occurred: "
078:                            + e);
079:                    LoaderException le = new LoaderException("Exception: ",
080:                            (Throwable) e);
081:                    throw le;
082:                    //            System.exit(1);
083:                }
084:                if (doc != null) {
085:                    NodeList tagBasic = doc.getElementsByTagName("sql");
086:                    iNumTagsImportJob = tagBasic.getLength();
087:                    Vector vecNames = new Vector();
088:                    String strName = "";
089:                    for (int i = 0; i < iNumTagsImportJob; i++) {
090:                        strName = new String("");
091:                        strName = OctopusXMLUtil.importAttributeValue(doc,
092:                                "sql", "name", i);
093:                        for (int j = 0; j < vecNames.size(); j++) {
094:                            if (strName.equals("")) {
095:                                this .logger
096:                                        .write("normal",
097:                                                "Sorry, an error occurred: No Sql statement name .");
098:                                LoaderException le = new LoaderException(
099:                                        "Exception: ",
100:                                        (Throwable) (new Exception(
101:                                                "Sorry, an error occurred: No Sql statement name .")));
102:                                throw le;
103:                            }
104:                            if (strName.equalsIgnoreCase(vecNames.get(j)
105:                                    .toString())) {
106:                                this .logger.write("normal",
107:                                        "Sorry, an error occurred: More Sql statements with same name :"
108:                                                + strName);
109:                                LoaderException le = new LoaderException(
110:                                        "Exception: ",
111:                                        (Throwable) (new Exception(
112:                                                "Sorry, an error occurred: More Sql statements with same name :")));
113:                                throw le;
114:                            }
115:                        }
116:                        vecNames.addElement(strName);
117:                    }
118:                }
119:                try {
120:                    inStream.reset();
121:                } catch (IOException e) {
122:                    this .logger.write("normal", "Sorry, an error occurred: "
123:                            + e);
124:                    LoaderException le = new LoaderException("IOxception: ",
125:                            (Throwable) e);
126:                    throw le;
127:                    //            System.exit(1);
128:                }
129:                this .logger.write("full", "\tparseSql method is finished.");
130:                return iNumTagsImportJob;
131:            }
132:
133:            /**
134:             * This method set value of logger parameter
135:             * @param logger is value of parameter
136:             */
137:            public void setLogger(Logger logger) {
138:                this .logger = logger;
139:            }
140:
141:            /**
142:             * This method set value of echo parameter
143:             * @param reader is value of parameter
144:             */
145:            public void setConfigReader(ConfigReader reader) {
146:                this .configReader = reader;
147:            }
148:
149:            /**
150:             * This method set value of jdbcParametersElement parameter
151:             * @param jdbc is value of parameter
152:             */
153:            public void setJdbcParametersElement(JdbcParametersElement jdbc) {
154:                this .jdbcParametersElement = jdbc;
155:            }
156:
157:            /**
158:             * Method importSQLStatement imports sql attributes from xml file and puts them in the global variables.
159:             * Return Vector. It's elements are strings which represents sql statements.
160:             * @param inStream Data from inputXML file which is converted into InputStream.
161:             * @param iSqlItem Number of sql tag in XML file which will be analised.
162:             * @return vector
163:             * @throws LoaderException
164:             */
165:            public Vector importSQLStatement(InputStream inStream, int iSqlItem)
166:                    throws LoaderException {
167:                Vector strValue = new Vector();
168:                Vector vecJDBCTargetValue = new Vector();
169:                Vector vecJDBCTargetName = new Vector();
170:                Document doc = null;
171:                String strNodeValue = "";
172:                this .logger.write("full",
173:                        "\timportSQLStatement  method is started.");
174:                try {
175:                    DocumentBuilderFactory dbf = DocumentBuilderFactory
176:                            .newInstance();
177:                    DocumentBuilder db = null;
178:                    db = dbf.newDocumentBuilder();
179:                    doc = db.parse(inStream);
180:                    if (doc != null) {
181:                        NodeList tagBasic = doc.getElementsByTagName("sql");
182:                        if (tagBasic.getLength() != 0) {
183:                            Element docFragment = (Element) tagBasic
184:                                    .item(iSqlItem);
185:                            this .strSqlName = docFragment.getAttribute("name");
186:                            /*
187:                             this.strSqlLogMode = docFragment.getAttribute("logMode");
188:                             if (this.strSqlLogMode.equals("")) {
189:                             this.strSqlLogMode = loaderJobReader.getDefaultLogMode();
190:                             }
191:                             */
192:                            this .strSqlOnErrorContinue = docFragment
193:                                    .getAttribute("onErrorContinue");
194:                            //          if (this.strSqlOnErrorContinue.equals("")) {
195:                            //            if (this.bOnErrorContinue == true)
196:                            //              this.strSqlOnErrorContinue = "true";
197:                            //            else
198:                            //              this.strSqlOnErrorContinue = (new Boolean(this.bDefaultOnErrorContinue)).toString();
199:                            //          }
200:
201:                            this .strSqlCommit = docFragment
202:                                    .getAttribute("commit");
203:                            if (this .strSqlCommit.equals("")) {
204:                                this .strSqlCommit = (new Boolean(
205:                                        this .bDefaultCommit)).toString();
206:                            }
207:                            String strReturnCode = docFragment
208:                                    .getAttribute("returnCode");
209:                            if (!strReturnCode.equals("")) {
210:                                ReturnCode.setErrorReturnCode(Integer
211:                                        .parseInt(strReturnCode));
212:                            } else
213:                                ReturnCode.setErrorReturnCode(ReturnCode
214:                                        .getDefaultErrorReturnCode());
215:
216:                            NodeList targetTag = docFragment
217:                                    .getElementsByTagName("sqlStmt");
218:                            for (int i = 0; i < targetTag.getLength(); i++) {
219:                                NodeList nodeText = targetTag.item(i)
220:                                        .getChildNodes();
221:                                if (nodeText.item(0) != null) {
222:                                    strNodeValue = nodeText.item(0)
223:                                            .getNodeValue();
224:                                    strValue.addElement(strNodeValue);
225:                                }
226:                            }
227:                        }
228:                    }
229:                } catch (Exception e) {
230:                    this .logger.write("normal", "Sorry, an error occurred: "
231:                            + e);
232:                    LoaderException le = new LoaderException("Exception: ",
233:                            (Throwable) e);
234:                    throw le;
235:                    //            System.exit(1);
236:                }
237:                try {
238:                    inStream.reset();
239:                } catch (IOException e) {
240:                    this .logger.write("normal", "Sorry, an error occurred: "
241:                            + e);
242:                    LoaderException le = new LoaderException("IOException: ",
243:                            (Throwable) e);
244:                    throw le;
245:                    //            System.exit(1);
246:                }
247:                this .logger.write("full",
248:                        "\timportSQLStatement  method is finished.");
249:                return strValue;
250:            }
251:
252:            //  public String getTargetDriverClassName() {
253:            //    return this.strTargetDriverClassName;
254:            //  }
255:            //  public String getJDBCTargetParameterPassword() {
256:            //    return this.strJDBCTargetParameterPassword;
257:            //  }
258:            //
259:            //  public String getJDBCTargetParameterUser() {
260:            //    return this.strJDBCTargetParameterUser;
261:            //  }
262:            //
263:            //  public String getJDBCTargetParameterConnection() {
264:            //    return this.strJDBCTargetParameterConnection;
265:            //  }
266:            //
267:            //  public String getJDBCTargetParameterDriver() {
268:            //    return this.strJDBCTargetParameterDriver;
269:            //  }
270:
271:            //  public String getTargetDriverName() {
272:            //    return this.strTargetDriverName;
273:            //  }
274:            //
275:            //  public String getTargetDbVendor() {
276:            //    return this.strTargetDbVendor;
277:            //  }
278:
279:            /**
280:             * This method read value of bDefaultCommit parameter
281:             * @return default value for attribute Commit
282:             */
283:            public boolean getDefaultCommit() {
284:                return this .bDefaultCommit;
285:            }
286:
287:            /**
288:             * This method read value of bDefaultOnErrorContinue parameter
289:             * @return default value for attribute OnErrorContinue
290:             */
291:            public boolean getDefaultOnErrorContinue() {
292:                return this .bDefaultOnErrorContinue;
293:            }
294:
295:            /**
296:             * This method read value of bOnErrorContinue parameter
297:             * @return value for attribute OnErrorContinue
298:             */
299:            public boolean getOnErrorContinue() {
300:                return this .bOnErrorContinue;
301:            }
302:
303:            /**
304:             * This method read value of strDefaultLogMode parameter
305:             * @return default value for attribute LogMode
306:             */
307:            public String getDefaultLogMode() {
308:                return this .strDefaultLogMode;
309:            }
310:
311:            /**
312:             * This method read value of strLogMode parameter
313:             * @return value for attribute LogMode
314:             */
315:            //  public String getLogMode() {
316:            //    return this.strLogMode;
317:            //  }
318:            /**
319:             * This method read value of strSqlCommit parameter
320:             * @return value for attribute SqlCommit
321:             */
322:            public String getSqlCommit() {
323:                return this .strSqlCommit;
324:            }
325:
326:            /**
327:             * This method read value of strSqlOnErrorContinue parameter
328:             * @return value for attribute SqlOnErrorContinue
329:             */
330:            public String getSqlOnErrorContinue() {
331:                return this .strSqlOnErrorContinue;
332:            }
333:
334:            /**
335:             * This method read value of strSqlLogMode parameter
336:             * @return value for attribute SqlLogMode
337:             */
338:            //  public String getSqlLogMode() {
339:            //    return this.strSqlLogMode;
340:            //  }
341:            /**
342:             * This method read value of strSqlName parameter
343:             * @return value for attribute SqlName
344:             */
345:            public String getSqlName() {
346:                return this .strSqlName;
347:            }
348:
349:            /**
350:             * Set LoaderJobAttrReader object
351:             * @param loader LoaderJobAttrReader object,which stores loaderJob tag attributes
352:             */
353:            public void setLoaderJob(LoaderJobAttrReader loader) {
354:                this.loaderJobReader = loader;
355:            }
356:
357:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.