001/** 002 * 003 * Copyright (c) 2014, the Railo Company Ltd. All rights reserved. 004 * 005 * This library is free software; you can redistribute it and/or 006 * modify it under the terms of the GNU Lesser General Public 007 * License as published by the Free Software Foundation; either 008 * version 2.1 of the License, or (at your option) any later version. 009 * 010 * This library 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 GNU 013 * Lesser General Public License for more details. 014 * 015 * You should have received a copy of the GNU Lesser General Public 016 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 017 * 018 **/ 019package lucee.runtime.db; 020 021import java.util.TimeZone; 022 023import lucee.runtime.type.Struct; 024 025/** 026 * interface for a datasource 027 */ 028public interface DataSource extends Cloneable { 029 030 /** 031 * Field <code>ALLOW_SELECT</code> 032 */ 033 public static final int ALLOW_SELECT = 1; 034 035 /** 036 * Field <code>ALLOW_DELETE</code> 037 */ 038 public static final int ALLOW_DELETE = 2; 039 040 /** 041 * Field <code>ALLOW_UPDATE</code> 042 */ 043 public static final int ALLOW_UPDATE = 4; 044 045 /** 046 * Field <code>ALLOW_INSERT</code> 047 */ 048 public static final int ALLOW_INSERT = 8; 049 050 /** 051 * Field <code>ALLOW_CREATE</code> 052 */ 053 public static final int ALLOW_CREATE = 16; 054 055 /** 056 * Field <code>ALLOW_GRANT</code> 057 */ 058 public static final int ALLOW_GRANT = 32; 059 060 /** 061 * Field <code>ALLOW_REVOKE</code> 062 */ 063 public static final int ALLOW_REVOKE = 64; 064 065 /** 066 * Field <code>ALLOW_DROP</code> 067 */ 068 public static final int ALLOW_DROP = 128; 069 070 /** 071 * Field <code>ALLOW_ALTER</code> 072 */ 073 public static final int ALLOW_ALTER = 256; 074 075 /** 076 * Field <code>ALLOW_ALL</code> 077 */ 078 public static final int ALLOW_ALL = ALLOW_SELECT + ALLOW_DELETE 079 + ALLOW_UPDATE + ALLOW_INSERT + ALLOW_CREATE + ALLOW_GRANT 080 + ALLOW_REVOKE + ALLOW_DROP + ALLOW_ALTER; 081 082 /** 083 * @return Returns the dsn. 084 */ 085 public abstract String getDsnOriginal(); // FUTURE deprecated 086 // FUTURE public abstract String getConnectionStringOriginal(); 087 088 /** 089 * @return Returns the dsn. 090 */ 091 public abstract String getDsnTranslated(); // FUTURE deprecated 092 // FUTURE public abstract String getConnectionStringTranslated(); 093 094 095 096 /** 097 * @return Returns the password. 098 */ 099 public abstract String getPassword(); 100 101 /** 102 * @return Returns the username. 103 */ 104 public abstract String getUsername(); 105 106 /** 107 * @return Returns the readOnly. 108 */ 109 public abstract boolean isReadOnly(); 110 111 /** 112 * @param allow 113 * @return returns if given allow exists 114 */ 115 public abstract boolean hasAllow(int allow); 116 117 /** 118 * @return Returns the clazz. 119 */ 120 public abstract Class getClazz(); 121 122 /** 123 * @return Returns the database. 124 */ 125 public abstract String getDatabase(); 126 127 /** 128 * @return Returns the port. 129 */ 130 public abstract int getPort(); 131 132 /** 133 * @return Returns the host. 134 */ 135 public abstract String getHost(); 136 137 /** 138 * @return cloned Object 139 */ 140 public abstract Object clone(); 141 142 /** 143 * @return clone the DataSource as ReadOnly 144 */ 145 public abstract DataSource cloneReadOnly(); 146 147 /** 148 * @return Returns the blob. 149 */ 150 public abstract boolean isBlob(); 151 152 /** 153 * @return Returns the clob. 154 */ 155 public abstract boolean isClob(); 156 157 /** 158 * @return Returns the connectionLimit. 159 */ 160 public abstract int getConnectionLimit(); 161 162 /** 163 * @return Returns the connectionTimeout. 164 */ 165 public abstract int getConnectionTimeout(); 166 167 public long getMetaCacheTimeout(); 168 169 public TimeZone getTimeZone(); 170 171 /** 172 * @param key 173 * @return Returns matching custom value or null if not exist. 174 */ 175 public abstract String getCustomValue(String key); 176 177 /** 178 * @return returns all custom names 179 */ 180 public abstract String[] getCustomNames(); 181 182 /** 183 * @return returns custom 184 */ 185 public abstract Struct getCustoms(); 186 187 /** 188 * @return returns if database has a SQL restriction 189 */ 190 public abstract boolean hasSQLRestriction(); 191 192 /** 193 * @return Returns the name. 194 */ 195 public abstract String getName(); 196 197 /** 198 * @param clazz The clazz to set. 199 * @deprecated this method is no longer supported with no replacement 200 */ 201 public abstract void setClazz(Class clazz); 202 203 public abstract boolean isStorage(); 204 205 public abstract boolean validate(); 206 207 // public abstract int getMaxConnection(); 208 209// public String getDbDriver(); // FUTURE, for JIRA-569; return the dbdriver used in the Admin to edit this datasource 210}