Source Code Cross Referenced for UIControllerForUpdates.java in  » Database-Client » DBBrowser » org » dbbrowser » ui » 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 Client » DBBrowser » org.dbbrowser.ui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.dbbrowser.ui;
002:
003:        import infrastructure.logging.Log;
004:
005:        import java.sql.Connection;
006:        import java.sql.SQLException;
007:        import org.dbbrowser.db.engine.exception.DBEngineException;
008:        import org.dbbrowser.db.engine.model.ColumnInfo;
009:        import org.dbbrowser.db.engine.model.DBRow;
010:        import org.dbbrowser.db.engine.model.View;
011:        import org.dbbrowser.db.engine.updateengine.DBUpdateEngine;
012:        import org.dbbrowser.db.engine.updateengine.GenericDBUpdateEngine;
013:        import org.dbbrowser.db.engine.updateengine.MySQLDBUpdateEngine;
014:        import org.dbbrowser.db.engine.updateengine.OracleDBUpdateEngine;
015:        import org.dbbrowser.drivermanager.ConnectionInfo;
016:        import org.dbbrowser.drivermanager.DBBrowserDriverManager;
017:        import org.dbbrowser.drivermanager.DriverManagerException;
018:
019:        /**
020:         * UI Controller for updating the database
021:         */
022:        public class UIControllerForUpdates {
023:            public static final String ORACLE_DBMS = "Oracle";
024:            public static final String MYSQL_DBMS = "MySQL";
025:            public static final String MSSQL_DBMS = "MS-SQL";
026:
027:            private ConnectionInfo connectionInfo = null;
028:            private DBUpdateEngine dbUpdateEngine = null;
029:
030:            /**
031:             * Connects to the database using the supplied connection info.  DirverManager caches the connection.  Start a DBQueryEngine
032:             * @param connectionInfo
033:             * @param masterPassword
034:             */
035:            public void setup(ConnectionInfo connectionInfo,
036:                    String masterPassword) throws DriverManagerException,
037:                    DBEngineException {
038:                this .connectionInfo = connectionInfo;
039:                Connection connection = DBBrowserDriverManager.getInstance()
040:                        .getConnection(connectionInfo, masterPassword);
041:
042:                if (ORACLE_DBMS.equals(connectionInfo.getDBMSType())) {
043:                    try {
044:                        this .dbUpdateEngine = new OracleDBUpdateEngine(
045:                                connection.createStatement());
046:                    } catch (SQLException exc) {
047:                        throw new DBEngineException(exc.getMessage());
048:                    }
049:                }
050:
051:                if (MYSQL_DBMS.equals(connectionInfo.getDBMSType())) {
052:                    try {
053:                        this .dbUpdateEngine = new MySQLDBUpdateEngine(
054:                                connection.createStatement());
055:                    } catch (SQLException exc) {
056:                        throw new DBEngineException(exc.getMessage());
057:                    }
058:                }
059:
060:                if (MSSQL_DBMS.equals(connectionInfo.getDBMSType())) {
061:                    try {
062:                        this .dbUpdateEngine = new GenericDBUpdateEngine(
063:                                connection.createStatement());
064:                    } catch (SQLException exc) {
065:                        throw new DBEngineException(exc.getMessage());
066:                    }
067:                }
068:            }
069:
070:            /**
071:             * Set autocommit
072:             * @param autoCommitFlag
073:             * @throws DBEngineException
074:             */
075:            public void setAutoCommit(boolean autoCommitFlag)
076:                    throws DBEngineException {
077:                try {
078:                    this .dbUpdateEngine.getStatement().getConnection()
079:                            .setAutoCommit(autoCommitFlag);
080:                    Log.getInstance().debugMessage(
081:                            "Autocommit " + autoCommitFlag,
082:                            this .getClass().getName());
083:                } catch (SQLException exc) {
084:                    throw new DBEngineException(exc.getMessage());
085:                }
086:            }
087:
088:            /**
089:             * Commit
090:             * @throws DBEngineException
091:             */
092:            public void commit() throws DBEngineException {
093:                try {
094:                    this .dbUpdateEngine.getStatement().getConnection().commit();
095:                    Log.getInstance().debugMessage("Commit complete",
096:                            this .getClass().getName());
097:                } catch (SQLException exc) {
098:                    throw new DBEngineException(exc.getMessage());
099:                }
100:            }
101:
102:            /**
103:             * Rollback
104:             * @throws DBEngineException
105:             */
106:            public void rollback() throws DBEngineException {
107:                try {
108:                    this .dbUpdateEngine.getStatement().getConnection()
109:                            .rollback();
110:                    Log.getInstance().debugMessage("Rollback complete",
111:                            this .getClass().getName());
112:                } catch (SQLException exc) {
113:                    throw new DBEngineException(exc.getMessage());
114:                }
115:            }
116:
117:            /**
118:             * Return the connection info representing the connection
119:             * @return
120:             */
121:            public ConnectionInfo getConnectionInfo() {
122:                return this .connectionInfo;
123:            }
124:
125:            /**
126:             * Update the view definition for the view
127:             * @param view
128:             * @throws DBEngineException
129:             */
130:            public void updateViewDefinition(View view)
131:                    throws DBEngineException {
132:                this .dbUpdateEngine.updateViewDefinition(view);
133:            }
134:
135:            /**
136:             * Add new column to the table
137:             * @param schemaName
138:             * @param tableName
139:             * @param columnInfo
140:             * @throws DBEngineException
141:             */
142:            public void addNewColumn(String schemaName, String tableName,
143:                    ColumnInfo columnInfo) throws DBEngineException {
144:                this .dbUpdateEngine.addNewColumn(schemaName, tableName,
145:                        columnInfo);
146:            }
147:
148:            /**
149:             * Drop the column from the table
150:             * @param schemaName
151:             * @param tableName
152:             * @param columnInfo
153:             * @throws DBEngineException
154:             */
155:            public void dropColumn(String schemaName, String tableName,
156:                    ColumnInfo columnInfo) throws DBEngineException {
157:                this .dbUpdateEngine.dropColumn(schemaName, tableName,
158:                        columnInfo);
159:            }
160:
161:            /**
162:             * Add a new row to the database
163:             * @param schemaName
164:             * @param tableName
165:             * @param dbRow
166:             * @throws DBEngineException
167:             */
168:            public void addNewRow(String schemaName, String tableName,
169:                    DBRow dbRow) throws DBEngineException {
170:                this .dbUpdateEngine.addNewRow(schemaName, tableName, dbRow);
171:            }
172:
173:            /**
174:             * Update the database using the data from the DBRow
175:             * @param schemaName
176:             * @param tableName
177:             * @param dbRow
178:             * @throws DBEngineException
179:             */
180:            public void update(String schemaName, String tableName, DBRow dbRow)
181:                    throws DBEngineException {
182:                this .dbUpdateEngine.update(schemaName, tableName, dbRow);
183:            }
184:
185:            /**
186:             * Delete the row
187:             * @param schemaName
188:             * @param tableName
189:             * @param dbRow
190:             * @throws DBEngineException
191:             */
192:            public void deleteRow(String schemaName, String tableName,
193:                    DBRow dbRow) throws DBEngineException {
194:                this.dbUpdateEngine.deleteRow(schemaName, tableName, dbRow);
195:            }
196:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.