Java Doc for DBUtil.java in  » Database-Client » squirrel-sql-2.6.5a » net » sourceforge » squirrel_sql » plugins » dbcopy » util » 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.plugins.dbcopy.util 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   net.sourceforge.squirrel_sql.plugins.dbcopy.I18NBaseObject
      net.sourceforge.squirrel_sql.plugins.dbcopy.util.DBUtil

DBUtil
public class DBUtil extends I18NBaseObject (Code)
A utility class for interacting with the database.




Method Summary
public static  StringbindVariable(PreparedStatement ps, int sourceColType, int destColType, int index, ResultSet rs)
     Reads the value from the specified ResultSet at column index index, and based on the type, calls the appropriate setXXX method on ps with the value obtained.
public static  voidcheckKeyword(ISession session, String table, String column)
     Checks the specified column is not a keyword in the specified session.
public static  voiddeleteDataInExistingTable(ISession session, String catalogName, String schemaName, String tableName)
     Deletes existing data from the destination connection specified in the specified table.
public static  booleandropTable(String tableName, String schemaName, String catalogName, ISession session, boolean cascade, int sessionType)
    
public static  ResultSetexecuteQuery(ISession session, String sql)
     Executes the specified sql statement on the specified connection and returns the ResultSet.
Parameters:
  con -
Parameters:
  sql -
Parameters:
  mysqlBigResultFix - if true, provides a work-around which is usefulin the case that the connection is to a MySQL database.
public static  intexecuteUpdate(ISQLConnection con, String SQL, boolean writeSQL)
     Executes the given SQL using the specified SQLConnection.
Parameters:
  con - the SQLConnection to execute the update on.
Parameters:
  SQL - the statement to execute.
public static  StringfixCase(ISession session, String identifier)
     Uppercase / Lowercase / Mixedcase identifiers are a big problem.
public static  StringgetCatSep(ISession session)
    
public static  intgetColumnCount(ISQLConnection sourceConn, ITableInfo ti)
    
public static  StringgetColumnList(TableColumnInfo[] colInfoArr)
    
public static  StringgetColumnName(ISQLConnection sourceConn, ITableInfo ti, int column)
    
public static  String[]getColumnNames(ISQLConnection sourceConn, ITableInfo ti)
    
public static  StringgetColumnSql(SessionInfoProvider prov, TableColumnInfo colInfo, String sourceTableName, String destTableName)
     Uses the column type mapper to get the column type and appends that to the name with an optional not null modifier.
public static  intgetColumnType(ISQLConnection con, ITableInfo ti, String columnName)
    
public static  intgetColumnType(ISQLConnection con, ITableInfo ti, int column)
    
public static  int[]getColumnTypes(ISQLConnection con, ITableInfo ti, String[] colNames)
    
public static  int[]getColumnTypes(ISQLConnection con, ITableInfo ti)
    
public static  StringgetCreateTableSql(SessionInfoProvider prov, ITableInfo ti)
    
public static  Set<String>getForeignKeySQL(SessionInfoProvider prov, ITableInfo ti, ArrayList<ITableInfo> selectedTableInfos)
     Returns a List of SQL statements that add foreign key(s) to the table described in the specified ITableInfo.
public static  StringgetInsertSQL(SessionInfoProvider prov, String columnList, ITableInfo ti, int columnCount)
    
public static  StringgetLastStatement()
    
public static  StringgetLastStatementValues()
    
public static  StringgetMaxColumnLengthSQL(ISession sourceSession, TableColumnInfo colInfo, String tableName, boolean tableNameIsQualified)
     Gets the SQL statement which can be used to select the maximum length of the current data found in tableName within the specified column.
public static  StringgetPKColumnString(ISQLConnection sourceConn, ITableInfo ti)
     Returns a string that looks like: (PK_COL1, PK_COL2, PK_COL3, ...) or null if there is no primary key for the specified table.
public static  StringgetQualifiedObjectName(ISession session, String catalogName, String schemaName, String objectName, int sessionType)
     Decide whether or not the session specified needs fully qualified table names (schema.table).
public static  StringgetSelectQuery(SessionInfoProvider prov, String columnList, ITableInfo ti)
    
public static  intgetTableCount(ISession session, String catalog, String schema, String tableName, int sessionType)
     Returns a count of the records in the specified table.
public static  ITableInfogetTableInfo(ISession session, String schema, String tableName)
    
public static  ITableInfo[]getTables(ISession session, String catalog, String schema, String tableName)
    
public static  booleanisBinaryType(TableColumnInfo columnInfo)
     Returns a boolean value indicating whether or not the specified TableColumnInfo represents a database column that holds binary type data.
public static  booleanisKeyword(ISession session, String data)
     Check the specified session to determine if the specified data is a keyword.
public static  intreplaceOtherDataType(TableColumnInfo colInfo)
     Takes the specified colInfo, gets the data type to see if it is 1111(OTHER).
public static  booleansameDatabaseType(ISession session1, ISession session2)
    
public static  voidsanityCheckPreferences(ISession destSession)
     This will take into account any special needs that the destination session has with regard to user preferences, and throw a MappingException if any user preference isn't valid for the specified destination session.
public static  voidsetLastStatement(String lastStatement)
    
public static  voidsetLastStatementValues(String values)
    
public static  voidsetPreferences(DBCopyPreferenceBean bean)
    
public static  booleantableHasForeignKey(String destCatalog, String destSchema, String destTableName, ForeignKeyInfo fkInfo, SessionInfoProvider prov)
    
public static  booleantableHasPrimaryKey(ISQLConnection con, ITableInfo ti)
    
public static  booleantypesAreEquivalent(int sourceType, int destType)
     Decides whether or not the specified column types (java.sql.Type constants) use the same java type to read from the source database as the one used to write to the destination database.
public static  voidvalidateColumnNames(ITableInfo ti, SessionInfoProvider prov)
    



Method Detail
bindVariable
public static String bindVariable(PreparedStatement ps, int sourceColType, int destColType, int index, ResultSet rs) throws SQLException(Code)
Reads the value from the specified ResultSet at column index index, and based on the type, calls the appropriate setXXX method on ps with the value obtained.
Parameters:
  ps -
Parameters:
  sourceColType -
Parameters:
  destColType -
Parameters:
  index -
Parameters:
  rs - a string representation of the value that was bound.
throws:
  SQLException -



checkKeyword
public static void checkKeyword(ISession session, String table, String column) throws MappingException(Code)
Checks the specified column is not a keyword in the specified session.
Parameters:
  session - the session whose keywords to check against
Parameters:
  table - the name of the table to use in the error message
Parameters:
  column - the name of the column to check
throws:
  MappingException - if the specified column is a keyword in the specified session



deleteDataInExistingTable
public static void deleteDataInExistingTable(ISession session, String catalogName, String schemaName, String tableName) throws SQLException, UserCancelledOperationException(Code)
Deletes existing data from the destination connection specified in the specified table. This will use preferences to determine if truncate command is preferred. If truncate is preferred and fails, then delete will be attempted.
Parameters:
  con -
Parameters:
  tablename -
throws:
  SQLException -



dropTable
public static boolean dropTable(String tableName, String schemaName, String catalogName, ISession session, boolean cascade, int sessionType) throws UserCancelledOperationException(Code)



executeQuery
public static ResultSet executeQuery(ISession session, String sql) throws SQLException(Code)
Executes the specified sql statement on the specified connection and returns the ResultSet.
Parameters:
  con -
Parameters:
  sql -
Parameters:
  mysqlBigResultFix - if true, provides a work-around which is usefulin the case that the connection is to a MySQL database. If the number of rows is large this will prevent the driver from readingthem all into client memory. MySQL's normal practice is to do such a thing for performance reasons.
throws:
  Exception -



executeUpdate
public static int executeUpdate(ISQLConnection con, String SQL, boolean writeSQL) throws SQLException(Code)
Executes the given SQL using the specified SQLConnection.
Parameters:
  con - the SQLConnection to execute the update on.
Parameters:
  SQL - the statement to execute. either the row count for INSERT, UPDATE or DELETE statements, or 0 for SQL statements that return nothing
throws:
  SQLException - if a database access error occurs or the given SQL statement produces a ResultSet object



fixCase
public static String fixCase(ISession session, String identifier)(Code)
Uppercase / Lowercase / Mixedcase identifiers are a big problem. Some databases support mixing case (like McKoi) others force identifier case to all uppercase or all lowercase. Some (like MySQL) can be configured to care or not care about case as well as depending on the platform the database is on. This method attempt to use the metadata from the driver to "fix" the case of the identifier to be acceptable for the specified session.
Parameters:
  session - the session whose disposition on case we care about.
Parameters:
  identifier -



getCatSep
public static String getCatSep(ISession session)(Code)



getColumnCount
public static int getColumnCount(ISQLConnection sourceConn, ITableInfo ti) throws SQLException(Code)

Parameters:
  sourceConn -
Parameters:
  ti -
throws:
  SQLException -



getColumnList
public static String getColumnList(TableColumnInfo[] colInfoArr) throws SQLException(Code)

Parameters:
  con -
Parameters:
  ti -
throws:
  SQLException -



getColumnName
public static String getColumnName(ISQLConnection sourceConn, ITableInfo ti, int column) throws SQLException(Code)

Parameters:
  sourceConn -
Parameters:
  ti -
Parameters:
  column -
throws:
  SQLException -



getColumnNames
public static String[] getColumnNames(ISQLConnection sourceConn, ITableInfo ti) throws SQLException(Code)

Parameters:
  sourceConn -
Parameters:
  ti -
throws:
  SQLException -



getColumnSql
public static String getColumnSql(SessionInfoProvider prov, TableColumnInfo colInfo, String sourceTableName, String destTableName) throws UserCancelledOperationException, MappingException(Code)
Uses the column type mapper to get the column type and appends that to the name with an optional not null modifier.
Parameters:
  colInfo -
throws:
  UserCancelledOperationException -
throws:
  MappingException -



getColumnType
public static int getColumnType(ISQLConnection con, ITableInfo ti, String columnName) throws SQLException(Code)

Parameters:
  con -
Parameters:
  synonym -
Parameters:
  columnName -
throws:
  SQLException -



getColumnType
public static int getColumnType(ISQLConnection con, ITableInfo ti, int column) throws SQLException(Code)

Parameters:
  con -
Parameters:
  ti -
Parameters:
  column -
throws:
  SQLException -



getColumnTypes
public static int[] getColumnTypes(ISQLConnection con, ITableInfo ti, String[] colNames) throws SQLException(Code)



getColumnTypes
public static int[] getColumnTypes(ISQLConnection con, ITableInfo ti) throws SQLException(Code)



getCreateTableSql
public static String getCreateTableSql(SessionInfoProvider prov, ITableInfo ti) throws SQLException, MappingException, UserCancelledOperationException(Code)



getForeignKeySQL
public static Set<String> getForeignKeySQL(SessionInfoProvider prov, ITableInfo ti, ArrayList<ITableInfo> selectedTableInfos) throws SQLException, UserCancelledOperationException(Code)
Returns a List of SQL statements that add foreign key(s) to the table described in the specified ITableInfo.
Parameters:
  prov - used to see if the destination session connection FKs in the source session exist already
Parameters:
  ti - the table to get FK information on Set a set of SQL statements that can be used to create foreignkey constraints.
throws:
  SQLException -



getInsertSQL
public static String getInsertSQL(SessionInfoProvider prov, String columnList, ITableInfo ti, int columnCount) throws SQLException, UserCancelledOperationException(Code)

Parameters:
  sourceConn -
Parameters:
  columnList -
Parameters:
  ti -
throws:
  SQLException -



getLastStatement
public static String getLastStatement()(Code)
the lastStatement



getLastStatementValues
public static String getLastStatementValues()(Code)



getMaxColumnLengthSQL
public static String getMaxColumnLengthSQL(ISession sourceSession, TableColumnInfo colInfo, String tableName, boolean tableNameIsQualified) throws UserCancelledOperationException(Code)
Gets the SQL statement which can be used to select the maximum length of the current data found in tableName within the specified column.
Parameters:
  sourceSession -
Parameters:
  colInfo -
Parameters:
  tableName -
Parameters:
  tableNameIsQualified - TODO



getPKColumnString
public static String getPKColumnString(ISQLConnection sourceConn, ITableInfo ti) throws SQLException(Code)
Returns a string that looks like: (PK_COL1, PK_COL2, PK_COL3, ...) or null if there is no primary key for the specified table.
Parameters:
  sourceConn -
Parameters:
  ti -
throws:
  SQLException -



getQualifiedObjectName
public static String getQualifiedObjectName(ISession session, String catalogName, String schemaName, String objectName, int sessionType)(Code)
Decide whether or not the session specified needs fully qualified table names (schema.table). In most databases this is optional (Oracle). In others it is required (Progress). In still others it must not occur. (Axion, Hypersonic)
Parameters:
  session -
Parameters:
  catalogName -
Parameters:
  schemaName -
Parameters:
  objectName -
throws:
  UserCancelledOperationException -



getSelectQuery
public static String getSelectQuery(SessionInfoProvider prov, String columnList, ITableInfo ti) throws SQLException, UserCancelledOperationException(Code)

Parameters:
  columnList -
Parameters:
  ti -
throws:
  SQLException -



getTableCount
public static int getTableCount(ISession session, String catalog, String schema, String tableName, int sessionType) throws UserCancelledOperationException(Code)
Returns a count of the records in the specified table.
Parameters:
  con - the SQLConnection to use to execute the count query.
Parameters:
  tableName - the name of the table -1 if the table does not exist, otherwise the record count isreturned.



getTableInfo
public static ITableInfo getTableInfo(ISession session, String schema, String tableName) throws SQLException, MappingException, UserCancelledOperationException(Code)



getTables
public static ITableInfo[] getTables(ISession session, String catalog, String schema, String tableName)(Code)



isBinaryType
public static boolean isBinaryType(TableColumnInfo columnInfo)(Code)
Returns a boolean value indicating whether or not the specified TableColumnInfo represents a database column that holds binary type data.
Parameters:
  columnInfo - the TableColumnInfo to examine true if binary; false otherwise.



isKeyword
public static boolean isKeyword(ISession session, String data)(Code)
Check the specified session to determine if the specified data is a keyword.
Parameters:
  session -
Parameters:
  data -



replaceOtherDataType
public static int replaceOtherDataType(TableColumnInfo colInfo) throws MappingException(Code)
Takes the specified colInfo, gets the data type to see if it is 1111(OTHER). If so then get the type name and try to match a jdbc type with the same name to get it's type code.
Parameters:
  colInfo -
throws:
  MappingException -



sameDatabaseType
public static boolean sameDatabaseType(ISession session1, ISession session2)(Code)



sanityCheckPreferences
public static void sanityCheckPreferences(ISession destSession) throws MappingException(Code)
This will take into account any special needs that the destination session has with regard to user preferences, and throw a MappingException if any user preference isn't valid for the specified destination session.
Parameters:
  destSession -



setLastStatement
public static void setLastStatement(String lastStatement)(Code)

Parameters:
  lastStatement - the lastStatement to set



setLastStatementValues
public static void setLastStatementValues(String values)(Code)



setPreferences
public static void setPreferences(DBCopyPreferenceBean bean)(Code)



tableHasForeignKey
public static boolean tableHasForeignKey(String destCatalog, String destSchema, String destTableName, ForeignKeyInfo fkInfo, SessionInfoProvider prov)(Code)



tableHasPrimaryKey
public static boolean tableHasPrimaryKey(ISQLConnection con, ITableInfo ti) throws SQLException(Code)



typesAreEquivalent
public static boolean typesAreEquivalent(int sourceType, int destType)(Code)
Decides whether or not the specified column types (java.sql.Type constants) use the same java type to read from the source database as the one used to write to the destination database. For example, Types.DECIMAL and Types.NUMERIC both use BigDecimal java type to store the value in between reading and writing it. Therefore, even though these types are not equal, they are equivalent. This method has not yet been fully implemented with equivalences from the bindVariable method.
Parameters:
  sourceType - the column type as identified by the source databasejdbc driver.
Parameters:
  destType - the column type as identified by the destination databasejdbc driver. true if equivalent, false if not.



validateColumnNames
public static void validateColumnNames(ITableInfo ti, SessionInfoProvider prov) throws MappingException, UserCancelledOperationException(Code)



Methods inherited from net.sourceforge.squirrel_sql.plugins.dbcopy.I18NBaseObject
protected static String getMessage(String key)(Code)(Java Doc)
protected static String getMessage(String key, Object arg)(Code)(Java Doc)
protected static String getMessage(String key, Object[] args)(Code)(Java Doc)
public static void main(String[] args)(Code)(Java Doc)

Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.