Source Code Cross Referenced for InterbaseDialect.java in  » Database-Client » squirrel-sql-2.6.5a » net » sourceforge » squirrel_sql » fw » dialects » 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 » squirrel sql 2.6.5a » net.sourceforge.squirrel_sql.fw.dialects 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (C) 2006 Rob Manning
003:         * manningr@users.sourceforge.net
004:         *
005:         * This program is free software; you can redistribute it and/or
006:         * modify it under the terms of the GNU General Public License
007:         * as published by the Free Software Foundation; either version 2
008:         * of the License, or any later version.
009:         *
010:         * This program is distributed in the hope that it will be useful,
011:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
012:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
013:         * GNU General Public License for more details.
014:         *
015:         * You should have received a copy of the GNU General Public License
016:         * along with this program; if not, write to the Free Software
017:         * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
018:         */
019:        package net.sourceforge.squirrel_sql.fw.dialects;
020:
021:        import java.sql.SQLException;
022:        import java.util.List;
023:
024:        import net.sourceforge.squirrel_sql.fw.sql.IDatabaseObjectInfo;
025:        import net.sourceforge.squirrel_sql.fw.sql.ISQLDatabaseMetaData;
026:        import net.sourceforge.squirrel_sql.fw.sql.ITableInfo;
027:        import net.sourceforge.squirrel_sql.fw.sql.TableColumnInfo;
028:
029:        /**
030:         * An extension to the standard Hibernate Interbase dialect
031:         * 
032:         */
033:        public class InterbaseDialect extends
034:                org.hibernate.dialect.InterbaseDialect implements 
035:                HibernateDialect {
036:
037:            public InterbaseDialect() {
038:                super ();
039:                /*
040:                 * TODO: hookup with Interbase spec and adjust these as necessary.
041:                 * 
042:                registerColumnType(Types.BIGINT, "integer");
043:                registerColumnType(Types.BINARY, 2000000000,"bit varying($l)");
044:                registerColumnType(Types.BIT, "bit(1)");
045:                registerColumnType(Types.BLOB, 2000000000, "bit varying($l)");
046:                registerColumnType(Types.BOOLEAN, "bit(1)");
047:                registerColumnType(Types.CHAR, 2000000000, "char($l)");
048:                registerColumnType(Types.CLOB, 2000000000, "varchar($l)");
049:                registerColumnType(Types.DATE, "date");
050:                registerColumnType(Types.DECIMAL, "decimal(36,2");
051:                registerColumnType(Types.DOUBLE, "double precision");
052:                registerColumnType(Types.FLOAT, 15, "float($l)");
053:                registerColumnType(Types.INTEGER, "integer");        
054:                registerColumnType(Types.LONGVARBINARY, 2000000000, "bit varying($l)");
055:                registerColumnType(Types.LONGVARCHAR, 31995, "varchar($l)");
056:                registerColumnType(Types.NUMERIC, "numeric(17,2)");
057:                registerColumnType(Types.REAL, "real");
058:                registerColumnType(Types.SMALLINT, "smallint");
059:                registerColumnType(Types.TIME, "date");
060:                registerColumnType(Types.TIMESTAMP, "timestamp");
061:                registerColumnType(Types.TINYINT, "tinyint");
062:                registerColumnType(Types.VARBINARY, 31995, "bit varying($l)");
063:                registerColumnType(Types.VARCHAR, 2000000000,"varchar($l)");  
064:                 */
065:            }
066:
067:            /* (non-Javadoc)
068:             * @see net.sourceforge.squirrel_sql.plugins.dbcopy.dialects.HibernateDialect#canPasteTo(net.sourceforge.squirrel_sql.fw.sql.DatabaseObjectType)
069:             */
070:            public boolean canPasteTo(IDatabaseObjectInfo info) {
071:                return true;
072:            }
073:
074:            /* (non-Javadoc)
075:             * @see net.sourceforge.squirrel_sql.plugins.dbcopy.dialects.HibernateDialect#supportsSchemasInTableDefinition()
076:             */
077:            public boolean supportsSchemasInTableDefinition() {
078:                return false;
079:            }
080:
081:            /* (non-Javadoc)
082:             * @see net.sourceforge.squirrel_sql.plugins.dbcopy.dialects.HibernateDialect#getLengthFunction()
083:             */
084:            public String getLengthFunction(int dataType) {
085:                return "length";
086:            }
087:
088:            /* (non-Javadoc)
089:             * @see net.sourceforge.squirrel_sql.plugins.dbcopy.dialects.HibernateDialect#getMaxFunction()
090:             */
091:            public String getMaxFunction() {
092:                return "max";
093:            }
094:
095:            /* (non-Javadoc)
096:             * @see net.sourceforge.squirrel_sql.plugins.dbcopy.dialects.HibernateDialect#getMaxPrecision(int)
097:             */
098:            public int getMaxPrecision(int dataType) {
099:                return 0;
100:            }
101:
102:            /* (non-Javadoc)
103:             * @see net.sourceforge.squirrel_sql.plugins.dbcopy.dialects.HibernateDialect#getMaxScale(int)
104:             */
105:            public int getMaxScale(int dataType) {
106:                return getMaxPrecision(dataType);
107:            }
108:
109:            /* (non-Javadoc)
110:             * @see net.sourceforge.squirrel_sql.plugins.dbcopy.dialects.HibernateDialect#getPrecisionDigits(int, int)
111:             */
112:            public int getPrecisionDigits(int columnSize, int dataType) {
113:                return columnSize;
114:            }
115:
116:            /* (non-Javadoc)
117:             * @see net.sourceforge.squirrel_sql.plugins.dbcopy.dialects.HibernateDialect#getColumnLength(int, int)
118:             */
119:            public int getColumnLength(int columnSize, int dataType) {
120:                return columnSize;
121:            }
122:
123:            /**
124:             * The string which identifies this dialect in the dialect chooser.
125:             * 
126:             * @return a descriptive name that tells the user what database this dialect
127:             *         is design to work with.
128:             */
129:            public String getDisplayName() {
130:                return "Interbase";
131:            }
132:
133:            /**
134:             * Returns boolean value indicating whether or not this dialect supports the
135:             * specified database product/version.
136:             * 
137:             * @param databaseProductName the name of the database as reported by 
138:             * 							  DatabaseMetaData.getDatabaseProductName()
139:             * @param databaseProductVersion the version of the database as reported by
140:             *                              DatabaseMetaData.getDatabaseProductVersion()
141:             * @return true if this dialect can be used for the specified product name
142:             *              and version; false otherwise.
143:             */
144:            public boolean supportsProduct(String databaseProductName,
145:                    String databaseProductVersion) {
146:                if (databaseProductName == null) {
147:                    return false;
148:                }
149:                if (databaseProductName.trim().toLowerCase().startsWith(
150:                        "interbase")) {
151:                    // We don't yet have the need to discriminate by version.
152:                    return true;
153:                }
154:                return false;
155:            }
156:
157:            /**
158:             * Returns the SQL statement to use to add a column to the specified table
159:             * using the information about the new column specified by info.
160:             * @param info information about the new column such as type, name, etc.
161:             * 
162:             * @return
163:             * @throws UnsupportedOperationException if the database doesn't support 
164:             *         adding columns after a table has already been created.
165:             */
166:            public String[] getColumnAddSQL(TableColumnInfo info)
167:                    throws UnsupportedOperationException {
168:                throw new UnsupportedOperationException(
169:                        "This database dialect doesn't support adding columns to tables");
170:            }
171:
172:            /**
173:             * Returns a boolean value indicating whether or not this dialect supports
174:             * adding comments to columns.
175:             * 
176:             * @return true if column comments are supported; false otherwise.
177:             */
178:            public boolean supportsColumnComment() {
179:                return false;
180:            }
181:
182:            /**
183:             * Returns the SQL statement to use to add a comment to the specified 
184:             * column of the specified table.
185:             * 
186:             * @param tableName the name of the table to create the SQL for.
187:             * @param columnName the name of the column to create the SQL for.
188:             * @param comment the comment to add.
189:             * @return
190:             * @throws UnsupportedOperationException if the database doesn't support 
191:             *         annotating columns with a comment.
192:             */
193:            @SuppressWarnings("unused")
194:            public String getColumnCommentAlterSQL(String tableName,
195:                    String columnName, String comment)
196:                    throws UnsupportedOperationException {
197:                throw new UnsupportedOperationException(
198:                        "This database dialect doesn't support adding comments to columns");
199:            }
200:
201:            /**
202:             * Returns a boolean value indicating whether or not this database dialect
203:             * supports dropping columns from tables.
204:             * 
205:             * @return true if the database supports dropping columns; false otherwise.
206:             */
207:            public boolean supportsDropColumn() {
208:                // TODO: need to verify this
209:                return true;
210:            }
211:
212:            /**
213:             * Returns the SQL that forms the command to drop the specified colum in the
214:             * specified table.
215:             * 
216:             * @param tableName the name of the table that has the column
217:             * @param columnName the name of the column to drop.
218:             * @return
219:             * @throws UnsupportedOperationException if the database doesn't support 
220:             *         dropping columns. 
221:             */
222:            public String getColumnDropSQL(String tableName, String columnName) {
223:                // TODO: Need to verify this        
224:                return DialectUtils.getColumnDropSQL(tableName, columnName);
225:            }
226:
227:            /**
228:             * Returns the SQL that forms the command to drop the specified table.  If
229:             * cascade contraints is supported by the dialect and cascadeConstraints is
230:             * true, then a drop statement with cascade constraints clause will be 
231:             * formed.
232:             * 
233:             * @param iTableInfo the table to drop
234:             * @param cascadeConstraints whether or not to drop any FKs that may 
235:             * reference the specified table.
236:             * @return the drop SQL command.
237:             */
238:            public List<String> getTableDropSQL(ITableInfo iTableInfo,
239:                    boolean cascadeConstraints, boolean isMaterializedView) {
240:                // TODO: Need to verify this
241:                return DialectUtils.getTableDropSQL(iTableInfo, true,
242:                        cascadeConstraints, false, DialectUtils.CASCADE_CLAUSE,
243:                        false);
244:            }
245:
246:            /**
247:             * Returns the SQL that forms the command to add a primary key to the 
248:             * specified table composed of the given column names.
249:             * 
250:             * @param pkName the name of the constraint
251:             * @param columnNames the columns that form the key
252:             * @return
253:             */
254:            public String[] getAddPrimaryKeySQL(String pkName,
255:                    TableColumnInfo[] columnNames, ITableInfo ti) {
256:                // TODO: implement
257:                throw new UnsupportedOperationException(
258:                        "getAddPrimaryKeySQL not implemented");
259:            }
260:
261:            /**
262:             * Returns the SQL statement to use to add a comment to the specified 
263:             * column of the specified table.
264:             * @param info information about the column such as type, name, etc.
265:             * @return
266:             * @throws UnsupportedOperationException if the database doesn't support 
267:             *         annotating columns with a comment.
268:             */
269:            public String getColumnCommentAlterSQL(TableColumnInfo info)
270:                    throws UnsupportedOperationException {
271:                // TODO: implement        
272:                throw new UnsupportedOperationException("Not yet implemented");
273:            }
274:
275:            /**
276:             * Returns the SQL used to alter the specified column to not allow null 
277:             * values
278:             * 
279:             * @param info the column to modify
280:             * @return the SQL to execute
281:             */
282:            public String getColumnNullableAlterSQL(TableColumnInfo info) {
283:                // TODO: implement
284:                throw new UnsupportedOperationException("Not yet implemented");
285:            }
286:
287:            /**
288:             * Returns a boolean value indicating whether or not this database dialect
289:             * supports renaming columns.
290:             * 
291:             * @return true if the database supports changing the name of columns;  
292:             *         false otherwise.
293:             */
294:            public boolean supportsRenameColumn() {
295:                // TODO: need to verify this
296:                return true;
297:            }
298:
299:            /**
300:             * Returns the SQL that is used to change the column name.
301:             * 
302:             * 
303:             * @param from the TableColumnInfo as it is
304:             * @param to the TableColumnInfo as it wants to be
305:             * 
306:             * @return the SQL to make the change
307:             */
308:            public String getColumnNameAlterSQL(TableColumnInfo from,
309:                    TableColumnInfo to) {
310:                // TODO: implement
311:                throw new UnsupportedOperationException("Not yet implemented");
312:            }
313:
314:            /**
315:             * Returns a boolean value indicating whether or not this dialect supports 
316:             * modifying a columns type.
317:             * 
318:             * @return true if supported; false otherwise
319:             */
320:            public boolean supportsAlterColumnType() {
321:                // TODO: verify this
322:                return true;
323:            }
324:
325:            /**
326:             * Returns the SQL that is used to change the column type.
327:             * 
328:             * @param from the TableColumnInfo as it is
329:             * @param to the TableColumnInfo as it wants to be
330:             * 
331:             * @return the SQL to make the change
332:             * @throw UnsupportedOperationException if the database doesn't support 
333:             *         modifying column types. 
334:             */
335:            public List<String> getColumnTypeAlterSQL(TableColumnInfo from,
336:                    TableColumnInfo to) throws UnsupportedOperationException {
337:                // TODO: implement
338:                throw new UnsupportedOperationException("Not Yet Implemented");
339:            }
340:
341:            /**
342:             * Returns a boolean value indicating whether or not this database dialect
343:             * supports changing a column from null to not-null and vice versa.
344:             * 
345:             * @return true if the database supports dropping columns; false otherwise.
346:             */
347:            public boolean supportsAlterColumnNull() {
348:                // TODO Auto-generated method stub
349:                return false;
350:            }
351:
352:            /**
353:             * Returns a boolean value indicating whether or not this database dialect
354:             * supports changing a column's default value.
355:             * 
356:             * @return true if the database supports modifying column defaults; false 
357:             *         otherwise
358:             */
359:            public boolean supportsAlterColumnDefault() {
360:                // TODO Need to verify this
361:                return true;
362:            }
363:
364:            /**
365:             * Returns the SQL command to change the specified column's default value
366:             *   
367:             * @param info the column to modify and it's default value.
368:             * @return SQL to make the change
369:             */
370:            public String getColumnDefaultAlterSQL(TableColumnInfo info) {
371:                // TODO need to implement or change the message
372:                throw new UnsupportedOperationException("Not yet implemented");
373:            }
374:
375:            /**
376:             * Returns the SQL command to drop the specified table's primary key.
377:             * 
378:             * @param pkName the name of the primary key that should be dropped
379:             * @param tableName the name of the table whose primary key should be 
380:             *                  dropped
381:             * @return
382:             */
383:            public String getDropPrimaryKeySQL(String pkName, String tableName) {
384:                return DialectUtils.getDropPrimaryKeySQL(pkName, tableName,
385:                        false, false);
386:            }
387:
388:            /**
389:             * Returns the SQL command to drop the specified table's foreign key 
390:             * constraint.
391:             * 
392:             * @param fkName the name of the foreign key that should be dropped
393:             * @param tableName the name of the table whose foreign key should be 
394:             *                  dropped
395:             * @return
396:             */
397:            public String getDropForeignKeySQL(String fkName, String tableName) {
398:                return DialectUtils.getDropForeignKeySQL(fkName, tableName);
399:            }
400:
401:            /**
402:             * Returns the SQL command to create the specified table.
403:             * 
404:             * @param tables the tables to get create statements for
405:             * @param md the metadata from the ISession
406:             * @param prefs preferences about how the resultant SQL commands should be 
407:             *              formed.
408:             * @param isJdbcOdbc whether or not the connection is via JDBC-ODBC bridge.
409:             *  
410:             * @return the SQL that is used to create the specified table
411:             */
412:            public List<String> getCreateTableSQL(List<ITableInfo> tables,
413:                    ISQLDatabaseMetaData md, CreateScriptPreferences prefs,
414:                    boolean isJdbcOdbc) throws SQLException {
415:                return DialectUtils.getCreateTableSQL(tables, md, this, prefs,
416:                        isJdbcOdbc);
417:            }
418:
419:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.