Source Code Cross Referenced for TimesTenDialect.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.sql.Types;
023:        import java.util.List;
024:
025:        import net.sourceforge.squirrel_sql.fw.sql.IDatabaseObjectInfo;
026:        import net.sourceforge.squirrel_sql.fw.sql.ISQLDatabaseMetaData;
027:        import net.sourceforge.squirrel_sql.fw.sql.ITableInfo;
028:        import net.sourceforge.squirrel_sql.fw.sql.TableColumnInfo;
029:
030:        /**
031:         * An extension to the standard Hibernate Informix dialect
032:         * 
033:         */
034:        public class TimesTenDialect extends
035:                org.hibernate.dialect.TimesTenDialect implements 
036:                HibernateDialect {
037:
038:            public TimesTenDialect() {
039:                super ();
040:                registerColumnType(Types.BIGINT, "bigint");
041:                registerColumnType(Types.BINARY, 8300, "binary($l)");
042:                registerColumnType(Types.BINARY, 4194304, "varbinary($l)");
043:                registerColumnType(Types.BINARY, "varbinary(4194304)");
044:                registerColumnType(Types.BIT, "tinyint");
045:                registerColumnType(Types.BLOB, 4194304, "varbinary($l)");
046:                registerColumnType(Types.BLOB, "varbinary(4194304)");
047:                registerColumnType(Types.BOOLEAN, "tinyint");
048:                registerColumnType(Types.CHAR, 8300, "char($l)");
049:                registerColumnType(Types.CHAR, 4194304, "varchar($l)");
050:                registerColumnType(Types.CHAR, "varchar(4194304)");
051:                registerColumnType(Types.CLOB, 4194304, "varchar($l)");
052:                registerColumnType(Types.CLOB, "varchar(4194304)");
053:                registerColumnType(Types.DATE, "date");
054:                registerColumnType(Types.DECIMAL, "decimal($p,$s)");
055:                registerColumnType(Types.DOUBLE, "double");
056:                registerColumnType(Types.FLOAT, "float");
057:                registerColumnType(Types.INTEGER, "integer");
058:                registerColumnType(Types.LONGVARBINARY, 4194304,
059:                        "varbinary($l)");
060:                registerColumnType(Types.LONGVARBINARY, "varbinary(4194304)");
061:                registerColumnType(Types.LONGVARCHAR, 4194304, "varchar($l)");
062:                registerColumnType(Types.LONGVARCHAR, "varchar(4194304)");
063:                registerColumnType(Types.NUMERIC, "numeric($p,$s)");
064:                registerColumnType(Types.REAL, "float");
065:                registerColumnType(Types.SMALLINT, "smallint");
066:                registerColumnType(Types.TIME, "time");
067:                registerColumnType(Types.TIMESTAMP, "timestamp");
068:                registerColumnType(Types.TINYINT, "tinyint");
069:                registerColumnType(Types.VARBINARY, 4194304, "varbinary($l)");
070:                registerColumnType(Types.VARBINARY, "varbinary(4194304)");
071:                registerColumnType(Types.VARCHAR, 4194304, "varchar($l)");
072:                registerColumnType(Types.VARCHAR, "varchar(4194304)");
073:
074:            }
075:
076:            /* (non-Javadoc)
077:             * @see net.sourceforge.squirrel_sql.plugins.dbcopy.dialects.HibernateDialect#canPasteTo(net.sourceforge.squirrel_sql.fw.sql.DatabaseObjectType)
078:             */
079:            public boolean canPasteTo(IDatabaseObjectInfo info) {
080:                return true;
081:            }
082:
083:            /* (non-Javadoc)
084:             * @see net.sourceforge.squirrel_sql.plugins.dbcopy.dialects.HibernateDialect#supportsSchemasInTableDefinition()
085:             */
086:            public boolean supportsSchemasInTableDefinition() {
087:                return true;
088:            }
089:
090:            /* (non-Javadoc)
091:             * @see net.sourceforge.squirrel_sql.plugins.dbcopy.dialects.HibernateDialect#getLengthFunction()
092:             */
093:            public String getLengthFunction(int dataType) {
094:                return "length";
095:            }
096:
097:            /* (non-Javadoc)
098:             * @see net.sourceforge.squirrel_sql.plugins.dbcopy.dialects.HibernateDialect#getMaxFunction()
099:             */
100:            public String getMaxFunction() {
101:                return "max";
102:            }
103:
104:            /* (non-Javadoc)
105:             * @see net.sourceforge.squirrel_sql.plugins.dbcopy.dialects.HibernateDialect#getMaxPrecision(int)
106:             */
107:            public int getMaxPrecision(int dataType) {
108:                int result = Integer.MAX_VALUE;
109:                if (dataType == Types.DECIMAL || dataType == Types.NUMERIC) {
110:                    result = 40;
111:                }
112:                if (dataType == Types.FLOAT) {
113:                    result = 53;
114:                }
115:                return result;
116:            }
117:
118:            /* (non-Javadoc)
119:             * @see net.sourceforge.squirrel_sql.plugins.dbcopy.dialects.HibernateDialect#getMaxScale(int)
120:             */
121:            public int getMaxScale(int dataType) {
122:                return getMaxPrecision(dataType);
123:            }
124:
125:            /* (non-Javadoc)
126:             * @see net.sourceforge.squirrel_sql.plugins.dbcopy.dialects.HibernateDialect#getPrecisionDigits(int, int)
127:             */
128:            public int getPrecisionDigits(int columnSize, int dataType) {
129:                return columnSize;
130:            }
131:
132:            /* (non-Javadoc)
133:             * @see net.sourceforge.squirrel_sql.plugins.dbcopy.dialects.HibernateDialect#getColumnLength(int, int)
134:             */
135:            public int getColumnLength(int columnSize, int dataType) {
136:                return columnSize;
137:            }
138:
139:            /**
140:             * The string which identifies this dialect in the dialect chooser.
141:             * 
142:             * @return a descriptive name that tells the user what database this dialect
143:             *         is design to work with.
144:             */
145:            public String getDisplayName() {
146:                return "TimesTen";
147:            }
148:
149:            /**
150:             * Returns boolean value indicating whether or not this dialect supports the
151:             * specified database product/version.
152:             * 
153:             * @param databaseProductName the name of the database as reported by 
154:             * 							  DatabaseMetaData.getDatabaseProductName()
155:             * @param databaseProductVersion the version of the database as reported by
156:             *                              DatabaseMetaData.getDatabaseProductVersion()
157:             * @return true if this dialect can be used for the specified product name
158:             *              and version; false otherwise.
159:             */
160:            public boolean supportsProduct(String databaseProductName,
161:                    String databaseProductVersion) {
162:                if (databaseProductName == null) {
163:                    return false;
164:                }
165:                if (databaseProductName.trim().toLowerCase().startsWith(
166:                        "timesten")) {
167:                    // We don't yet have the need to discriminate by version.
168:                    return true;
169:                }
170:                return false;
171:            }
172:
173:            /**
174:             * Returns the SQL statement to use to add a column to the specified table
175:             * using the information about the new column specified by info.
176:             * @param info information about the new column such as type, name, etc.
177:             * 
178:             * @return
179:             * @throws UnsupportedOperationException if the database doesn't support 
180:             *         adding columns after a table has already been created.
181:             */
182:            public String[] getColumnAddSQL(TableColumnInfo info)
183:                    throws UnsupportedOperationException {
184:                return new String[] { DialectUtils.getColumnAddSQL(info, this ,
185:                        true, false, false) };
186:            }
187:
188:            /**
189:             * Returns a boolean value indicating whether or not this database dialect
190:             * supports dropping columns from tables.
191:             * 
192:             * @return true if the database supports dropping columns; false otherwise.
193:             */
194:            public boolean supportsDropColumn() {
195:                return true;
196:            }
197:
198:            /**
199:             * Returns the SQL that forms the command to drop the specified colum in the
200:             * specified table.
201:             * 
202:             * @param tableName the name of the table that has the column
203:             * @param columnName the name of the column to drop.
204:             * @return
205:             * @throws UnsupportedOperationException if the database doesn't support 
206:             *         dropping columns. 
207:             */
208:            public String getColumnDropSQL(String tableName, String columnName) {
209:                return DialectUtils.getColumnDropSQL(tableName, columnName);
210:            }
211:
212:            /**
213:             * Returns the SQL that forms the command to drop the specified table.  If
214:             * cascade contraints is supported by the dialect and cascadeConstraints is
215:             * true, then a drop statement with cascade constraints clause will be 
216:             * formed.
217:             * 
218:             * @param iTableInfo the table to drop
219:             * @param cascadeConstraints whether or not to drop any FKs that may 
220:             * reference the specified table.
221:             * @return the drop SQL command.
222:             */
223:            public List<String> getTableDropSQL(ITableInfo iTableInfo,
224:                    boolean cascadeConstraints, boolean isMaterializedView) {
225:                return DialectUtils.getTableDropSQL(iTableInfo, true,
226:                        cascadeConstraints, false, DialectUtils.CASCADE_CLAUSE,
227:                        false);
228:            }
229:
230:            /**
231:             * Returns the SQL that forms the command to add a primary key to the 
232:             * specified table composed of the given column names.
233:             * 
234:             * @param pkName the name of the constraint
235:             * @param columnNames the columns that form the key
236:             * @return
237:             */
238:            public String[] getAddPrimaryKeySQL(String pkName,
239:                    TableColumnInfo[] columnNames, ITableInfo ti) {
240:                int featureId = DialectUtils.ADD_PRIMARY_KEY_TYPE;
241:                String msg = DialectUtils
242:                        .getUnsupportedMessage(this , featureId);
243:                throw new UnsupportedOperationException(msg);
244:            }
245:
246:            /**
247:             * Returns a boolean value indicating whether or not this dialect supports
248:             * adding comments to columns.
249:             * 
250:             * @return true if column comments are supported; false otherwise.
251:             */
252:            public boolean supportsColumnComment() {
253:                return false;
254:            }
255:
256:            /**
257:             * Returns the SQL statement to use to add a comment to the specified 
258:             * column of the specified table.
259:             * @param info information about the column such as type, name, etc.
260:             * @return
261:             * @throws UnsupportedOperationException if the database doesn't support 
262:             *         annotating columns with a comment.
263:             */
264:            public String getColumnCommentAlterSQL(TableColumnInfo info)
265:                    throws UnsupportedOperationException {
266:                int featureId = DialectUtils.COLUMN_COMMENT_ALTER_TYPE;
267:                String msg = DialectUtils
268:                        .getUnsupportedMessage(this , featureId);
269:                throw new UnsupportedOperationException(msg);
270:            }
271:
272:            /**
273:             * Returns a boolean value indicating whether or not this database dialect
274:             * supports changing a column from null to not-null and vice versa.
275:             * 
276:             * @return true if the database supports dropping columns; false otherwise.
277:             */
278:            public boolean supportsAlterColumnNull() {
279:                return false;
280:            }
281:
282:            /**
283:             * Returns the SQL used to alter the specified column to not allow null 
284:             * values
285:             * 
286:             * @param info the column to modify
287:             * @return the SQL to execute
288:             */
289:            public String getColumnNullableAlterSQL(TableColumnInfo info) {
290:                int featureId = DialectUtils.COLUMN_NULL_ALTER_TYPE;
291:                String msg = DialectUtils
292:                        .getUnsupportedMessage(this , featureId);
293:                throw new UnsupportedOperationException(msg);
294:            }
295:
296:            /**
297:             * Returns a boolean value indicating whether or not this database dialect
298:             * supports renaming columns.
299:             * 
300:             * @return true if the database supports changing the name of columns;  
301:             *         false otherwise.
302:             */
303:            public boolean supportsRenameColumn() {
304:                return false;
305:            }
306:
307:            /**
308:             * Returns the SQL that is used to change the column name.
309:             * 
310:             * 
311:             * @param from the TableColumnInfo as it is
312:             * @param to the TableColumnInfo as it wants to be
313:             * 
314:             * @return the SQL to make the change
315:             */
316:            public String getColumnNameAlterSQL(TableColumnInfo from,
317:                    TableColumnInfo to) {
318:                int featureId = DialectUtils.COLUMN_NAME_ALTER_TYPE;
319:                String msg = DialectUtils
320:                        .getUnsupportedMessage(this , featureId);
321:                throw new UnsupportedOperationException(msg);
322:            }
323:
324:            /**
325:             * Returns a boolean value indicating whether or not this dialect supports 
326:             * modifying a columns type.
327:             * 
328:             * @return true if supported; false otherwise
329:             */
330:            public boolean supportsAlterColumnType() {
331:                return false;
332:            }
333:
334:            /**
335:             * Returns the SQL that is used to change the column type.
336:             * 
337:             * @param from the TableColumnInfo as it is
338:             * @param to the TableColumnInfo as it wants to be
339:             * 
340:             * @return the SQL to make the change
341:             * @throw UnsupportedOperationException if the database doesn't support 
342:             *         modifying column types. 
343:             */
344:            public List<String> getColumnTypeAlterSQL(TableColumnInfo from,
345:                    TableColumnInfo to) throws UnsupportedOperationException {
346:                int featureId = DialectUtils.COLUMN_TYPE_ALTER_TYPE;
347:                String msg = DialectUtils
348:                        .getUnsupportedMessage(this , featureId);
349:                throw new UnsupportedOperationException(msg);
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:                return false;
361:            }
362:
363:            /**
364:             * Returns the SQL command to change the specified column's default value
365:             *   
366:             * @param info the column to modify and it's default value.
367:             * @return SQL to make the change
368:             */
369:            public String getColumnDefaultAlterSQL(TableColumnInfo info) {
370:                /* 
371:                 * TimesTen reference claims this is a supported operation, but it 
372:                 * yields an exception for me: 
373:                 * 
374:                 * ALTER TABLE test MODIFY noDefaultVarcharCol  DEFAULT 'Default Value'
375:                 * 
376:                 *  Exception in thread "main" 
377:                 *  java.sql.SQLException: [TimesTen][TimesTen 6.0.1 ODBC Driver][TimesTen]TT1001: 
378:                 *  Syntax error in SQL statement before or at: "NODEFAULTVARCHARCOL", 
379:                 *  character position: 26 -- file "ptSqlY.y", lineno 1940, procedure "sbPtParseSql()"
380:                 *  
381:                String alterClause = DialectUtils.MODIFY_CLAUSE;
382:                String defaultClause = DialectUtils.DEFAULT_CLAUSE;
383:                return DialectUtils.getColumnDefaultAlterSQL(this, 
384:                										     info, 
385:                										     alterClause, 
386:                										     false, 
387:                										     defaultClause);
388:                										     
389:                So, for now, just throw an exception:
390:                 */
391:                int featureId = DialectUtils.COLUMN_DEFAULT_ALTER_TYPE;
392:                String msg = DialectUtils
393:                        .getUnsupportedMessage(this , featureId);
394:                throw new UnsupportedOperationException(msg);
395:            }
396:
397:            /**
398:             * Returns the SQL command to drop the specified table's primary key.
399:             * 
400:             * @param pkName the name of the primary key that should be dropped
401:             * @param tableName the name of the table whose primary key should be 
402:             *                  dropped
403:             * @return
404:             */
405:            public String getDropPrimaryKeySQL(String pkName, String tableName) {
406:                return DialectUtils.getDropPrimaryKeySQL(pkName, tableName,
407:                        false, false);
408:            }
409:
410:            /**
411:             * Returns the SQL command to drop the specified table's foreign key 
412:             * constraint.
413:             * 
414:             * @param fkName the name of the foreign key that should be dropped
415:             * @param tableName the name of the table whose foreign key should be 
416:             *                  dropped
417:             * @return
418:             */
419:            public String getDropForeignKeySQL(String fkName, String tableName) {
420:                return DialectUtils.getDropForeignKeySQL(fkName, tableName);
421:            }
422:
423:            /**
424:             * Returns the SQL command to create the specified table.
425:             * 
426:             * @param tables the tables to get create statements for
427:             * @param md the metadata from the ISession
428:             * @param prefs preferences about how the resultant SQL commands should be 
429:             *              formed.
430:             * @param isJdbcOdbc whether or not the connection is via JDBC-ODBC bridge.
431:             *  
432:             * @return the SQL that is used to create the specified table
433:             */
434:            public List<String> getCreateTableSQL(List<ITableInfo> tables,
435:                    ISQLDatabaseMetaData md, CreateScriptPreferences prefs,
436:                    boolean isJdbcOdbc) throws SQLException {
437:                return DialectUtils.getCreateTableSQL(tables, md, this, prefs,
438:                        isJdbcOdbc);
439:            }
440:
441:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.