1 package net.sourceforge.phpdt.sql.sql;
3 import net.sourceforge.phpdt.sql.bookmarks.Bookmark;
5 public class SQLHelper {
7 public static int getSize(Bookmark current, String tableName) {
8 SQLResults results = MultiSQLServer.getInstance().execute(
9 current.getConnection(), "SELECT COUNT(*) FROM " + tableName); //$NON-NLS-1$
10 return Integer.parseInt(results.getElement(1, 1).toString());
12 public static SQLResults getResults(Bookmark current, String query, int start, int end, int maxLength, String encoding) {
13 return MultiSQLServer.getInstance().execute(current.getConnection(),
14 query, start, end, maxLength, encoding);
16 public static String getFullTableName(Bookmark current, String table) {
17 String schema = current.getSchema();
18 if (schema == null) return table;
19 if (schema.equals("")) return table; //$NON-NLS-1$
20 return schema + "." + table; //$NON-NLS-1$
24 * True if the type is Real (numeric and with decimal part) according to java.sql.Types
28 public static boolean isReal(int type) {
29 return (type == java.sql.Types.DECIMAL || type == java.sql.Types.DOUBLE || type ==java.sql.Types.FLOAT ||
30 type == java.sql.Types.NUMERIC || type == java.sql.Types.REAL );
34 * True if the type is Numeric according to java.sql.Types
38 public static boolean isNumeric(int type) {
39 return (type == java.sql.Types.DECIMAL || type == java.sql.Types.DOUBLE || type ==java.sql.Types.FLOAT ||
40 type == java.sql.Types.NUMERIC || type == java.sql.Types.REAL || type == java.sql.Types.BIGINT ||
41 type == java.sql.Types.TINYINT || type == java.sql.Types.SMALLINT || type == java.sql.Types.INTEGER );
44 * True if the type is textual according to java.sql.Types
48 public static boolean isText(int type) {
49 return (type == java.sql.Types.CLOB || type == java.sql.Types.VARBINARY || type ==java.sql.Types.VARCHAR );