1 package com.quantum.sql;
 
   3 import java.sql.Connection;
 
   4 import java.sql.SQLException;
 
   5 import java.util.Vector;
 
   7 import com.quantum.adapters.DatabaseAdapter;
 
   8 import com.quantum.view.LogProxy;
 
  10 public class SQLHelper {
 
  12         public static Vector getSchemas(Connection connection) {
 
  13                 return MultiSQLServer.getInstance().getSchemas(connection);
 
  15     public static int getSize(Connection connection, String tableName, DatabaseAdapter adapter) throws SQLException {
 
  16         SQLResults results = MultiSQLServer.getInstance().execute( 
 
  17                 connection, adapter.getCountQuery(tableName));
 
  18         if (results.getRowCount() > 0 && results.getColumnCount() > 0) {
 
  19             return Integer.parseInt(results.getElement(1, 1).toString());
 
  25         public static SQLResults getResults(Connection connection, String query, int start, int end, int maxLength, String encoding) {
 
  27                         return MultiSQLServer.getInstance().execute(connection, 
 
  28                             query, start, end, maxLength, encoding);
 
  29                 } catch (SQLException e) {
 
  30                         LogProxy log = LogProxy.getInstance();
 
  33                                 "Error Executing: " + query + ":" + e.toString(), e); //$NON-NLS-1$ //$NON-NLS-2$
 
  35                 SQLResults results = new SQLResults();
 
  36                 results.setIsError(true);
 
  41          * True if the type is Real (numeric and with decimal part) according to java.sql.Types
 
  45         public static boolean isReal(int type) {
 
  46                 return (type == java.sql.Types.DECIMAL || type == java.sql.Types.DOUBLE || type ==java.sql.Types.FLOAT || 
 
  47                         type == java.sql.Types.NUMERIC || type == java.sql.Types.REAL );
 
  51          * True if the type is Numeric according to java.sql.Types
 
  55         public static boolean isNumeric(int type) {
 
  56                 return (type == java.sql.Types.DECIMAL || type == java.sql.Types.DOUBLE || type ==java.sql.Types.FLOAT || 
 
  57                         type == java.sql.Types.NUMERIC || type == java.sql.Types.REAL || type == java.sql.Types.BIGINT ||
 
  58                         type == java.sql.Types.TINYINT || type == java.sql.Types.SMALLINT || type == java.sql.Types.INTEGER );
 
  61          * True if the type is textual according to java.sql.Types
 
  65         public static boolean isText(int type) {
 
  66                 return (type == java.sql.Types.CLOB || type == java.sql.Types.VARBINARY || type ==java.sql.Types.VARCHAR
 
  67                                 || type == java.sql.Types.CHAR || type == java.sql.Types.LONGVARCHAR );
 
  70         public static String getQualifiedName(String schema, String name) {
 
  71                 return (schema != null && schema.length() > 0) ? schema + "." + name : name;