1 30 31 32 package org.hsqldb; 33 34 import java.sql.Connection ; 35 import java.sql.Driver ; 36 import java.sql.DriverManager ; 37 import java.sql.DriverPropertyInfo ; 38 import java.sql.SQLException ; 39 import java.util.Properties ; 40 41 import org.hsqldb.jdbc.jdbcConnection; 42 import org.hsqldb.persist.HsqlDatabaseProperties; 43 import org.hsqldb.persist.HsqlProperties; 44 45 51 78 79 122 public class jdbcDriver implements Driver { 123 124 159 public Connection connect(String url, 160 Properties info) throws SQLException { 161 return getConnection(url, info); 162 } 163 164 public static Connection getConnection(String url, 165 Properties info) 166 throws SQLException { 167 168 HsqlProperties props = DatabaseURL.parseURL(url, true); 169 170 if (props == null) { 171 172 throw new SQLException ( 174 Trace.getMessage(Trace.INVALID_JDBC_ARGUMENT)); 175 } else if (props.isEmpty()) { 176 177 return null; 179 } 180 181 props.addProperties(info); 182 183 return new jdbcConnection(props); 184 } 185 186 194 195 public boolean acceptsURL(String url) { 197 198 return url != null 199 && url.regionMatches(true, 0, DatabaseURL.S_URL_PREFIX, 0, 200 DatabaseURL.S_URL_PREFIX.length()); 201 } 202 203 228 public DriverPropertyInfo [] getPropertyInfo(String url, Properties info) { 229 230 String [] choices = new String [] { 231 "true", "false" 232 }; 233 DriverPropertyInfo [] pinfo = new DriverPropertyInfo [6]; 234 DriverPropertyInfo p; 235 236 p = new DriverPropertyInfo ("user", null); 237 p.value = info.getProperty("user"); 238 p.required = true; 239 pinfo[0] = p; 240 p = new DriverPropertyInfo ("password", null); 241 p.value = info.getProperty("password"); 242 p.required = true; 243 pinfo[1] = p; 244 p = new DriverPropertyInfo ("get_column_name", null); 245 p.value = info.getProperty("get_column_name", "true"); 246 p.required = false; 247 p.choices = choices; 248 pinfo[2] = p; 249 p = new DriverPropertyInfo ("ifexists", null); 250 p.value = info.getProperty("ifexists"); 251 p.required = false; 252 p.choices = choices; 253 pinfo[3] = p; 254 p = new DriverPropertyInfo ("default_schema", null); 255 p.value = info.getProperty("default_schema"); 256 p.required = false; 257 p.choices = choices; 258 pinfo[4] = p; 259 p = new DriverPropertyInfo ("shutdown", null); 260 p.value = info.getProperty("shutdown"); 261 p.required = false; 262 p.choices = choices; 263 pinfo[5] = p; 264 265 return pinfo; 266 } 267 268 273 public int getMajorVersion() { 274 return HsqlDatabaseProperties.MAJOR; 275 } 276 277 282 public int getMinorVersion() { 283 return HsqlDatabaseProperties.MINOR; 284 } 285 286 313 public boolean jdbcCompliant() { 314 315 316 return false; 317 } 318 319 static { 320 try { 321 DriverManager.registerDriver(new jdbcDriver()); 322 } catch (Exception e) {} 323 } 324 } 325 | Popular Tags |