/** * Creates a JDBCDataSource object using the location or reference information specified. * * <p>The Reference object should support the properties, database, user, password. * * @param obj The reference information used in creating a JDBCDatasource object. * @param name ignored * @param nameCtx ignored * @param environment ignored * @return A newly created JDBCDataSource object; null if an object cannot be created. * @exception Exception never */ public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable environment) throws Exception { String dsClass = "org.hsqldb.jdbc.JDBCDataSource"; Reference ref = (Reference) obj; if (ref.getClassName().equals(dsClass)) { JDBCDataSource ds = new JDBCDataSource(); ds.setDatabase((String) ref.get("database").getContent()); ds.setUser((String) ref.get("user").getContent()); ds.setPassword((String) ref.get("password").getContent()); return ds; } else { return null; } }
public static DataSource createDataSource(Properties paramProperties) throws Exception { JDBCDataSource localJDBCDataSource = (JDBCDataSource) Class.forName("org.hsqldb.jdbc.JDBCDataSource").newInstance(); String str = paramProperties.getProperty("database"); if (str == null) str = paramProperties.getProperty("url"); localJDBCDataSource.setDatabase(str); str = paramProperties.getProperty("user"); if (str == null) str = paramProperties.getProperty("username"); localJDBCDataSource.setUser(str); str = paramProperties.getProperty("password"); localJDBCDataSource.setPassword(str); str = paramProperties.getProperty("loginTimeout"); if (str != null) { str = str.trim(); if (str.length() > 0) try { localJDBCDataSource.setLoginTimeout(Integer.parseInt(str)); } catch (NumberFormatException localNumberFormatException) { } } return localJDBCDataSource; }
public void testHookUpDataSourceToParentType() throws Exception { testRead(); JDBCDataSource ds = target.getDataSource(FUN_DATASOURCE_NAME, JDBCDataSource.class); assertNotNull(ds); assertNotNull(ds.getParentType()); }