Source Code Cross Referenced for Export.java in  » Database-DBMS » db-derby-10.2 » org » apache » derby » impl » load » 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 DBMS » db derby 10.2 » org.apache.derby.impl.load 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:
003:           Derby - Class org.apache.derby.impl.load.Export
004:
005:           Licensed to the Apache Software Foundation (ASF) under one or more
006:           contributor license agreements.  See the NOTICE file distributed with
007:           this work for additional information regarding copyright ownership.
008:           The ASF licenses this file to You under the Apache License, Version 2.0
009:           (the "License"); you may not use this file except in compliance with
010:           the License.  You may obtain a copy of the License at
011:
012:              http://www.apache.org/licenses/LICENSE-2.0
013:
014:           Unless required by applicable law or agreed to in writing, software
015:           distributed under the License is distributed on an "AS IS" BASIS,
016:           WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017:           See the License for the specific language governing permissions and
018:           limitations under the License.
019:
020:         */
021:
022:        package org.apache.derby.impl.load;
023:
024:        import java.sql.Connection;
025:        import java.sql.ResultSet;
026:        import java.io.IOException;
027:        import java.sql.SQLException;
028:        import java.util.*;
029:
030:        /**
031:         * This class provides ways to export data from
032:         * a table or a view into a file. Export functions provided 
033:         * in this  class are called through Systement Procedures.  
034:         */
035:        public class Export extends ExportAbstract {
036:
037:            private String outputFileName;
038:
039:            private void doExport() throws SQLException {
040:                try {
041:                    if (entityName == null && selectStatement == null)
042:                        throw LoadError.entityNameMissing();
043:
044:                    if (outputFileName == null)
045:                        throw LoadError.dataFileNull();
046:                    try {
047:                        doAllTheWork();
048:                    } catch (IOException iex) {
049:                        //in case of ioexception, catch it and throw it as our own exception
050:                        throw LoadError.errorWritingData();
051:                    }
052:                } catch (Exception ex) {
053:                    throw LoadError.unexpectedError(ex);
054:                }
055:
056:            }
057:
058:            private Export(Connection con, String schemaName, String tableName,
059:                    String selectStatement, String outputFileName,
060:                    String characterDelimeter, String columnDelimeter,
061:                    String codeset) throws SQLException {
062:                this .con = con;
063:                this .schemaName = schemaName;
064:                this .entityName = tableName;
065:                this .selectStatement = selectStatement;
066:                this .outputFileName = outputFileName;
067:                try {
068:                    controlFileReader = new ControlInfo();
069:                    controlFileReader.setControlProperties(characterDelimeter,
070:                            columnDelimeter, codeset);
071:                } catch (Exception ex) {
072:                    throw LoadError.unexpectedError(ex);
073:                }
074:            }
075:
076:            /**
077:             * SYSCS_EXPORT_TABLE  system Procedure from ij or from a Java application
078:             * invokes  this method to perform export of  a table data to a file.
079:             * @param con	 The Cloudscape database connection URL for the database containing the table
080:             * @param schemaName	schema name of the table data is being exported from
081:             * @param tableName     Name of the Table from which  data has to be exported.
082:             * @param outputFileName Name of the file to  which data has to be exported.
083:             * @param columnDelimeter  Delimiter that seperates columns in the output file
084:             * @param characterDelimeter  Delimiter that is used to quoate non-numeric types
085:             * @param codeset           Codeset that should be used to write  the data to  the file
086:             * @exception SQL Exception on errors
087:             */
088:
089:            public static void exportTable(Connection con, String schemaName,
090:                    String tableName, String outputFileName,
091:                    String columnDelimeter, String characterDelimeter,
092:                    String codeset) throws SQLException {
093:
094:                Export fex = new Export(con, schemaName, tableName, null,
095:                        outputFileName, characterDelimeter, columnDelimeter,
096:                        codeset);
097:
098:                fex.doExport();
099:            }
100:
101:            /**
102:             * SYSCS_EXPORT_QUERY  system Procedure from ij or from a Java application
103:             * invokes  this method to perform export of the data retrieved by select statement to a file.
104:             * @param con	 The Cloudscape database connection URL for the database containing the table
105:             * @param selectStatement    select query that is used to export the data
106:             * @param outputFileName Name of the file to  which data has to be exported.
107:             * @param columnDelimeter  Delimiter that seperates columns in the output file
108:             * @param characterDelimeter  Delimiter that is used to quiote non-numeric types
109:             * @param codeset           Codeset that should be used to write  the data to  the file
110:             * @exception SQL Exception on errors
111:             */
112:            public static void exportQuery(Connection con,
113:                    String selectStatement, String outputFileName,
114:                    String columnDelimeter, String characterDelimeter,
115:                    String codeset) throws SQLException {
116:
117:                Export fex = new Export(con, null, null, selectStatement,
118:                        outputFileName, characterDelimeter, columnDelimeter,
119:                        codeset);
120:                fex.doExport();
121:            }
122:
123:            /**
124:             * For internal use only
125:             * @exception	Exception if there is an error
126:             */
127:            //returns the control file reader corresponding to the control file passed
128:            protected ExportWriteDataAbstract getExportWriteData()
129:                    throws Exception {
130:                return new ExportWriteData(outputFileName, controlFileReader);
131:            }
132:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.