public void testMasterUpdate() throws PersistenceException { Complex fullname = new Complex("First", "Person"); // 1. load master object, add a new dependent object and commit _db.begin(); TestLazyPerson loadPerson = (TestLazyEmployee) _db.load(TestLazyEmployee.class, fullname); TestLazyAddress address = new TestLazyAddress(); address.setId(201); address.setStreet("Halfpipe 1"); address.setCity("Skater Heaven"); address.setPerson(loadPerson); loadPerson.getAddress().add(address); _db.commit(); // 2. reuse master and commit. if we get a DuplicateIdentityException, // the dependent object (id=201) was created twice. _db.begin(); _db.update(loadPerson); try { _db.commit(); } catch (TransactionAbortedException e) { if (e.getException() instanceof DuplicateIdentityException) { stream.println("Error: The dependent object Address was just duplicated"); fail("The dependent object Address was just duplicated"); } else { throw e; } } // No DuplicateIdentityException means, that just one instance of Address (id=201) // was created in the database. That's what we want to have. }
/** * This method is called by the tests and preform the actual concurrent modification test. * * @param accessMode the access mode that is used in the concurrent modification tests */ private void testDirtyIgnored(final AccessMode accessMode) throws PersistenceException, SQLException { OQLQuery oql; Sample object; QueryResults enumeration; // Open transaction in order to perform JDO operations _db.begin(); // Determine if test object exists, if not create it. // If it exists, set the name to some predefined value // that this test will later override. oql = _db.getOQLQuery("SELECT object FROM " + Sample.class.getName() + " object WHERE id = $1"); oql.bind(Sample.DEFAULT_ID); enumeration = oql.execute(); if (enumeration.hasMore()) { object = (Sample) enumeration.next(); LOG.debug("Retrieved object: " + object); object.setValue1(Sample.DEFAULT_VALUE_1); object.setValue2(Sample.DEFAULT_VALUE_2); } else { object = new Sample(); LOG.debug("Creating new object: " + object); _db.create(object); } _db.commit(); // Open a new transaction in order to conduct test _db.begin(); oql.bind(new Integer(Sample.DEFAULT_ID)); object = (Sample) oql.execute(accessMode).nextElement(); object.setValue2(JDO_VALUE); // Perform direct JDBC access and override the value of that table if (accessMode != Database.DbLocked) { _conn .createStatement() .execute( "UPDATE tc0x_sample SET value2='" + JDBC_VALUE + "' WHERE id=" + Sample.DEFAULT_ID); LOG.debug("Updated test object from JDBC"); } // Commit JDO transaction, this should report object modified exception LOG.debug("Commit update: no dirty checking field not modified"); try { _db.commit(); LOG.debug("OK: ObjectModifiedException not thrown"); } catch (ObjectModifiedException ex) { if (_db.isActive()) { _db.rollback(); } LOG.error("Error: ObjectModifiedException thrown", ex); fail("ObjectModifiedException thrown"); } }
public void testCreateLoadUpdateDelete() throws Exception { Database database; // create product database = _category.getDatabase(); database.begin(); Product pc = new Product(1, "LCD", KindEnum.MONITOR); database.create(pc); database.commit(); database.close(); // load created product database = _category.getDatabase(); database.begin(); Product pl1 = new Product(1, "LCD", KindEnum.MONITOR); Product pl2 = (Product) database.load(Product.class, new Integer(1)); assertEquals(pl1, pl2); database.commit(); database.close(); // update product database = _category.getDatabase(); database.begin(); Product pu = (Product) database.load(Product.class, new Integer(1)); pu.setName("Laser"); pu.setKind(KindEnum.PRINTER); database.commit(); database.close(); // load updated product database = _category.getDatabase(); database.begin(); Product pl3 = new Product(1, "Laser", KindEnum.PRINTER); Product pl4 = (Product) database.load(Product.class, new Integer(1)); assertEquals(pl3, pl4); database.commit(); database.close(); // delete product database = _category.getDatabase(); database.begin(); Product pd = (Product) database.load(Product.class, new Integer(1)); database.remove(pd); database.commit(); database.close(); }
public void testCreateAndLoadLaptop() throws Exception { Database database = _category.getDatabase(); database.begin(); ProductDetail detail = new ProductDetail(); detail.setId(10); detail.setCategory("category 10"); detail.setLocation("location 10"); database.create(detail); database.commit(); database.begin(); Laptop laptop = new Laptop(); laptop.setId(10); laptop.setName("laptop 10"); laptop.setCpu("centrino"); laptop.setResolution("1600"); laptop.setWeight(2750); laptop.setDetail((ProductDetail) database.load(ProductDetail.class, new Integer(10))); database.create(laptop); Owner owner = new Owner(); owner.setId(new Integer(10)); owner.setName("owner 10"); owner.setProduct(laptop); database.commit(); database.begin(); laptop = (Laptop) database.load(Laptop.class, new Integer(10)); database.commit(); assertNotNull(laptop); assertEquals("ctf.jdo.tc9x.Laptop", laptop.getClass().getName()); assertEquals(10, laptop.getId()); assertEquals("laptop 10", laptop.getName()); database.begin(); database.remove(database.load(Laptop.class, new Integer(10))); database.remove(database.load(ProductDetail.class, new Integer(10))); database.commit(); database.begin(); try { laptop = (Laptop) database.load(Laptop.class, new Integer(10)); fail("Laptop with id 10 still exists."); } catch (ObjectNotFoundException e) { assertEquals( "The object of type ctf.jdo.tc9x.Laptop with identity <10(10)> " + "was not found in persistent storage", e.getMessage()); } database.commit(); database.close(); }
public void testCreateAndLoadCar() throws Exception { Database database = _category.getDatabase(); database.begin(); Order order = new Order(); order.setId(11); order.setName("order 11"); database.create(order); database.commit(); database.begin(); ProductDetail detail = new ProductDetail(); detail.setId(11); detail.setCategory("category 11"); detail.setLocation("location 11"); database.create(detail); database.commit(); database.begin(); Truck truck = new Truck(); truck.setId(11); truck.setName("truck 11"); truck.setKw(112); truck.setMake("Fiat"); truck.setMaxWeight(3750); truck.setDetail((ProductDetail) database.load(ProductDetail.class, new Integer(11))); database.create(truck); Collection orders = new LinkedList(); orders.add(database.load(Order.class, new Integer(11))); truck.setOrders(orders); database.commit(); database.begin(); Object object = database.load(Car.class, new Integer(11)); assertNotNull(object); assertEquals("ctf.jdo.tc9x.Truck", object.getClass().getName()); Truck loadedTruck = (Truck) object; database.commit(); assertNotNull(loadedTruck); assertEquals(11, loadedTruck.getId()); database.begin(); database.remove(database.load(Car.class, new Integer(11))); database.remove(database.load(ProductDetail.class, new Integer(11))); database.remove(database.load(Order.class, new Integer(11))); database.commit(); database.close(); }
public void testCreateAndLoadComputer() throws Exception { Database database = _category.getDatabase(); database.begin(); Order order = new Order(); order.setId(12); order.setName("order 12"); database.create(order); database.commit(); database.begin(); ProductDetail detail = new ProductDetail(); detail.setId(12); detail.setCategory("category 12"); detail.setLocation("location 12"); database.create(detail); database.commit(); database.begin(); Laptop laptop = new Laptop(); laptop.setId(12); laptop.setName("laptop 12"); laptop.setCpu("centrino"); laptop.setResolution("1600"); laptop.setWeight(2450); laptop.setDetail((ProductDetail) database.load(ProductDetail.class, new Integer(12))); database.create(laptop); Collection orders = new LinkedList(); orders.add(database.load(Order.class, new Integer(12))); laptop.setOrders(orders); database.commit(); database.begin(); Computer computer = (Computer) database.load(Computer.class, new Integer(12)); database.commit(); assertNotNull(computer); assertEquals("ctf.jdo.tc9x.Laptop", computer.getClass().getName()); assertEquals(12, computer.getId()); assertEquals("laptop 12", computer.getName()); database.begin(); computer = (Computer) database.load(Computer.class, new Integer(12)); database.remove(computer); database.remove(database.load(ProductDetail.class, new Integer(12))); database.remove(database.load(Order.class, new Integer(12))); database.commit(); database.close(); }
public void testQuery() throws Exception { Database database; // create some products database = _category.getDatabase(); database.begin(); database.create(new Product(1, "LCD", KindEnum.MONITOR)); database.create(new Product(2, "Laser", KindEnum.PRINTER)); database.create(new Product(3, "Desktop", KindEnum.COMPUTER)); database.create(new Product(4, "Notebook", KindEnum.COMPUTER)); database.commit(); database.close(); // query and delete all product database = _category.getDatabase(); database.begin(); Product pq; OQLQuery query = database.getOQLQuery( "select p from " + jdo.tc167.Product.class.getName() + " p order by p.id"); QueryResults results = query.execute(); pq = (Product) results.next(); assertEquals(pq, new Product(1, "LCD", KindEnum.MONITOR)); database.remove(pq); pq = (Product) results.next(); assertEquals(pq, new Product(2, "Laser", KindEnum.PRINTER)); database.remove(pq); pq = (Product) results.next(); assertEquals(pq, new Product(3, "Desktop", KindEnum.COMPUTER)); database.remove(pq); pq = (Product) results.next(); assertEquals(pq, new Product(4, "Notebook", KindEnum.COMPUTER)); database.remove(pq); assertFalse(results.hasMore()); results.close(); query.close(); database.commit(); database.close(); }
public void testOQLQueryWithParameter() throws Exception { Database database = _category.getDatabase(); database.begin(); OQLQuery query = database.getOQLQuery( "SELECT count(laptop.id) FROM " + Laptop.class.getName() + " laptop WHERE laptop.resolution = $1"); query.bind("1024"); QueryResults results = query.execute(); if (results.hasMore()) { Object obj = results.next(); Long count = null; if (obj instanceof Long) { count = (Long) obj; } else if (obj instanceof Integer) { count = new Long(((Integer) obj).intValue()); } else if (obj instanceof BigDecimal) { count = new Long(((BigDecimal) obj).longValue()); } assertNotNull(count); assertEquals(1, count.intValue()); } database.commit(); database.close(); }
public void testQueryComputers() throws Exception { String[] classNames = { "ctf.jdo.tc9x.Laptop", "ctf.jdo.tc9x.Laptop", "ctf.jdo.tc9x.Server", "ctf.jdo.tc9x.Server" }; Database database = _category.getDatabase(); database.begin(); OQLQuery query = database.getOQLQuery( "select computer from " + Computer.class.getName() + " as computer order by computer.id"); QueryResults results = query.execute(); if (results.hasMore()) { int counter = 1; while (results.hasMore()) { Computer computer = (Computer) results.next(); assertNotNull(computer); assertEquals(counter, computer.getId()); assertEquals(classNames[counter - 1], computer.getClass().getName()); counter += 1; } } else { fail("Query does not return any Computer instances."); } database.commit(); database.close(); }
public void testQueryProducts() throws Exception { String[] classNames = { "ctf.jdo.tc9x.Laptop", "ctf.jdo.tc9x.Laptop", "ctf.jdo.tc9x.Server", "ctf.jdo.tc9x.Server", "ctf.jdo.tc9x.Truck" }; Database database = _category.getDatabase(); database.begin(); OQLQuery query = database.getOQLQuery( "select product from " + Product.class.getName() + " as product order by product.id"); QueryResults results = query.execute(); if (results.hasMore()) { int counter = 1; while (results.hasMore()) { Product product = (Product) results.next(); assertNotNull(product); assertEquals(counter, product.getId()); assertEquals(classNames[counter - 1], product.getClass().getName()); counter += 1; } } else { fail("Query does not return any Product instances."); } database.commit(); database.close(); }
public void testQueryLaptops() throws Exception { Database database = _category.getDatabase(); database.begin(); OQLQuery query = database.getOQLQuery("select l from " + Laptop.class.getName() + " as l order by l.id"); QueryResults results = query.execute(); if (results.hasMore()) { int counter = 1; Laptop laptop = null; while (results.hasMore()) { laptop = (Laptop) results.next(); assertNotNull(laptop); assertEquals(counter, laptop.getId()); counter += 1; } } else { fail("Query does not return any Laptop instances."); } database.commit(); database.close(); }
/** * unlocks this instance for the given instance and state * * @param state state that have to be locked * @param user the locking user */ public void unlock(ProcessInstance instance, State state, User user) throws WorkflowException { Database db = null; try { // Get database connection db = WorkflowJDOManager.getDatabase(); // begin transaction db.begin(); // Re-load process instance UpdatableProcessInstance copyInstance = (UpdatableProcessInstance) db.load(ProcessInstanceImpl.class, instance.getInstanceId()); // Do workflow stuff try { // unlock instance for user copyInstance.unLock(state, user); } catch (WorkflowException we) { db.rollback(); throw new WorkflowException( "ProcessInstanceManagerImpl.unlock", "workflowEngine.EX_ERR_UNLOCK", we); } // commit db.commit(); } catch (PersistenceException pe) { throw new WorkflowException( "ProcessInstanceManagerImpl.unlock", "workflowEngine.EX_ERR_CASTOR_UNLOCK", pe); } finally { WorkflowJDOManager.closeDatabase(db); } }
/** * Removes a new process instance * * @param instanceId instance id */ public void removeProcessInstance(String instanceId) throws WorkflowException { SilverTrace.info( "worflowEngine", "ProcessInstanceManagerImpl.removeProcessInstance()", "root.MSG_GEN_ENTER_METHOD", "InstanceId=" + instanceId); ProcessInstanceImpl instance; Database db = null; try { // Delete forms data associated with this instance removeProcessInstanceData(instanceId); // Constructs the query db = WorkflowJDOManager.getDatabase(); db.begin(); instance = (ProcessInstanceImpl) db.load(ProcessInstanceImpl.class, instanceId); db.remove(instance); db.commit(); } catch (PersistenceException pe) { throw new WorkflowException( "ProcessInstanceManagerImpl.removeProcessInstance", "EX_ERR_CASTOR_REMOVE_INSTANCE", pe); } finally { WorkflowJDOManager.closeDatabase(db); } WorkflowHub.getErrorManager().removeErrorsOfInstance(instanceId); SilverTrace.info( "worflowEngine", "ProcessInstanceManagerImpl.removeProcessInstance()", "root.MSG_GEN_EXIT_METHOD"); }
public void runTest() throws PersistenceException, SQLException { OQLQuery oql; TestObject object; QueryResults enumeration; _db.begin(); // Determine if test object exists, if not create it. // If it exists, set the name to some predefined value // that this test will later override. oql = _db.getOQLQuery("SELECT object FROM jdo.TestObject object WHERE id = $1"); oql.bind(50); enumeration = oql.execute(); if (enumeration.hasMore()) { object = (TestObject) enumeration.next(); stream.println("Retrieved object: " + object); object.setValue1(TestObject.DefaultValue1); object.setValue2(TestObject.DefaultValue2); } else { object = new TestObject(); object.setId(50); stream.println("Creating new object: " + object); _db.create(object); } oql.close(); _db.commit(); try { stream.println("CALL SQL query"); _db.begin(); oql = _db.getOQLQuery( "CALL SQL SELECT ID,VALUE1,VALUE2 FROM TEST_TABLE WHERE (ID = $1) AS jdo.TestObject"); oql.bind(50); enumeration = oql.execute(); if (enumeration.hasMore()) { object = (TestObject) enumeration.next(); stream.println("Retrieved object: " + object); } else { fail("test object not found"); } oql.close(); _db.commit(); } catch (Exception e) { fail("Exception thrown " + e); } }
/** Get a JDO database */ public void setUp() throws Exception { _db = getJDOManager(DBNAME, MAPPING).getDatabase(); _db.begin(); LOG.info("Delete everything"); Statement stmt = _db.getJdbcConnection().createStatement(); stmt.executeUpdate("delete from test77_depend2"); stmt.executeUpdate("delete from test77_master"); stmt.executeUpdate("delete from test77_depend1"); _db.commit(); }
public void testDepends() throws Exception { Database db = null; MasterObjectNoKeyGen master = new MasterObjectNoKeyGen(); master.setId(100); master.setDescrip("This is the descrip."); db = _category.getDatabase(); db.begin(); db.create(master); db.commit(); assertTrue(master.getId() != 0); assertEquals(100, master.getId()); // THIS Part Works! db.begin(); DependentObjectNoKeyGen depends = new DependentObjectNoKeyGen(); depends.setId(101); depends.setDescrip("Description"); master.setDepends(depends); db.update(master); db.commit(); assertTrue(master.getId() != 0); assertEquals(100, master.getId()); int masterId = master.getId(); db.begin(); master = (MasterObjectNoKeyGen) db.load(MasterObjectNoKeyGen.class, new Integer(masterId)); assertNotNull(master.getDepends()); master.setDepends(null); db.commit(); db.begin(); master = (MasterObjectNoKeyGen) db.load(MasterObjectNoKeyGen.class, new Integer(masterId)); assertNull(master.getDepends()); db.commit(); // THIS part doesn't! db.begin(); master = (MasterObjectNoKeyGen) db.load(MasterObjectNoKeyGen.class, new Integer(masterId)); depends = new DependentObjectNoKeyGen(); depends.setId(102); depends.setDescrip("Description"); master.setDepends(depends); db.commit(); db.begin(); master = (MasterObjectNoKeyGen) db.load(MasterObjectNoKeyGen.class, new Integer(masterId)); assertNotNull(master.getDepends()); db.commit(); db.begin(); master = (MasterObjectNoKeyGen) db.load(MasterObjectNoKeyGen.class, new Integer(masterId)); assertNotNull(master); db.remove(master); db.commit(); }
/** * Test method. * * @throws Exception For any exception thrown. */ public void testQueryEntityOne() throws Exception { Database db = _category.getDatabase(); db.begin(); Parent entity = (Parent) db.load(Parent.class, new Integer(1)); assertNotNull(entity); assertEquals(new Integer(1), entity.getId()); db.commit(); db.close(); }
public void test() throws Exception { Database db = getJDOManager(DBNAME, MAPPING).getDatabase(); db.begin(); LOG.info("Begin transaction to query log entries"); OQLQuery oql = db.getOQLQuery("SELECT e FROM " + LogEntry.class.getName() + " e"); QueryResults results = oql.execute(); while (results.hasMore()) { LogEntry entry = (LogEntry) results.next(); int id = entry.getId().intValue(); boolean isRefering = (entry instanceof ReferingLogEntry); boolean isException = (entry.getException() != null); if (LOG.isDebugEnabled()) { LOG.debug(id + "/" + isRefering + "/" + isException); } switch (id) { case 1: case 2: case 7: case 9: case 10: case 12: case 15: assertFalse(isRefering); assertFalse(isException); break; case 3: case 4: case 8: case 13: assertFalse(isRefering); assertTrue(isException); break; case 5: case 6: case 11: case 14: assertTrue(isRefering); assertFalse(isException); break; default: fail(); } } LOG.info("End transaction to query log entries"); db.commit(); db.close(); }
public void testLoadTruck() throws Exception { Database database = _category.getDatabase(); database.begin(); Truck truck = (Truck) database.load(Truck.class, new Integer(5)); database.commit(); assertNotNull(truck); assertEquals(5, truck.getId()); database.close(); }
/** * Test method. * * @throws Exception For any exception thrown. */ public void testLoadChild() throws Exception { Database db = _category.getDatabase(); db.begin(); Child child = (Child) db.load(Child.class, new Integer(1)); assertNotNull(child); assertEquals(new Integer(1), child.getId()); db.commit(); db.close(); }
public void test(final Database db) throws Exception { db.begin(); String s = "SELECT e FROM " + Employee.class.getName() + " e " + "WHERE e.holiday > $1"; OQLQuery qry = db.getOQLQuery(s); qry.bind(50.0); QueryResults rst = qry.execute(); while (rst.hasMore()) { Employee emp = (Employee) rst.next(); emp.setHoliday(50.0f); } rst.close(); qry.close(); db.commit(); }
public void testLoadComputer() throws Exception { Database database = _category.getDatabase(); database.begin(); Computer computer = (Computer) database.load(Computer.class, new Integer(2)); database.commit(); assertNotNull(computer); assertEquals("ctf.jdo.tc9x.Laptop", computer.getClass().getName()); assertEquals(2, computer.getId()); assertEquals("laptop 2", computer.getName()); database.close(); }
public void testQueryFinalize() throws Exception { LOG.info("Create many master objects"); _db.begin(); for (int i = 0; i < 100; i++) { Master master = new Master(); _db.create(master); } _db.commit(); LOG.info("query master objects"); try { _db.begin(); QueryResults results = getResults(_db); LOG.info("query can be garbage collected"); while (results.hasMore()) { Master master = (Master) results.next(); LOG.info(master.getId()); } _db.commit(); } catch (Exception e) { fail("Exception thrown iterating over results : " + e); } }
public void testLoadLaptop() throws Exception { Database database = _category.getDatabase(); database.begin(); Laptop laptop = (Laptop) database.load(Laptop.class, new Integer(1)); database.commit(); assertNotNull(laptop); assertEquals("ctf.jdo.tc9x.Laptop", laptop.getClass().getName()); assertEquals(1, laptop.getId()); assertEquals("laptop 1", laptop.getName()); database.close(); }
public void testLoadServer() throws Exception { Database database = _category.getDatabase(); database.begin(); Server server = (Server) database.load(Server.class, new Integer(3)); database.commit(); assertNotNull(server); assertEquals("ctf.jdo.tc9x.Server", server.getClass().getName()); assertEquals(3, server.getId()); assertEquals("server 3", server.getName()); database.close(); }
public void testManyToMany() throws PersistenceException, SQLException { stream.println("Running testManyToMany..."); _db.begin(); String key = "a1"; TestLazyNToNA a1 = (TestLazyNToNA) _db.load(TestLazyNToNA.class, key); // The object a1 should have two TestLazyNToNB objects in its // "refs" collection Collection lazyRefs = a1.getRefs(); if (lazyRefs.size() != 2) { stream.println("Error: incorrect initial collection size in testManyToMany"); fail("Error: incorrect initial collection size in testManyToMany"); } lazyRefs.clear(); _db.commit(); // Now if we re-load the object in a new transaction, there should // be no objects in the "refs" collection _db.begin(); a1 = (TestLazyNToNA) _db.load(TestLazyNToNA.class, key); // The object a1 should have two TestLazyNToNB objects in its // "refs" collection lazyRefs = a1.getRefs(); if (lazyRefs.size() > 2) { stream.println("Error: incorrect final collection size in testManyToMany"); fail("Error: incorrect final collection size in testManyToMany"); } _db.commit(); }
/** * Test method. * * @throws Exception For any exception thrown. */ public void testLoadEntityWithCompoundId() throws Exception { Database db = _category.getDatabase(); db.begin(); ParentWithCompoundId child = (ParentWithCompoundId) db.load(ParentWithCompoundId.class, new Complex(new Integer(1), new Integer(1))); assertNotNull(child); assertEquals(new Integer(1), child.getId1()); assertEquals(new Integer(1), child.getId2()); db.commit(); db.close(); }
public void testLoadCar() throws Exception { Database database = _category.getDatabase(); database.begin(); Object object = database.load(Car.class, new Integer(5)); assertNotNull(object); assertEquals("ctf.jdo.tc9x.Truck", object.getClass().getName()); Truck truck = (Truck) object; database.commit(); assertNotNull(truck); assertEquals(5, truck.getId()); database.close(); }
public void testReadOnlyOidEmpty() throws Exception { long start = System.currentTimeMillis(); _db = _jdo.getDatabase(); _db.getCacheManager().expireCache(); _db.begin(); long begin = System.currentTimeMillis(); OQLQuery query = _db.getOQLQuery( "CALL SQL select PTF_LOCKED.ID as ID " + "from PTF_LOCKED order by PTF_LOCKED.ID " + "AS ptf.jdo.rel1toN.OID"); QueryResults results = query.execute(Database.ReadOnly); long result = System.currentTimeMillis(); initIterateQueriesOID(); int count = 0; while (results.hasMore()) { OID oid = (OID) results.next(); iterateStatesOID( (Locked) _db.load(Locked.class, oid.getId(), Database.ReadOnly), Database.ReadOnly); count++; } long iterate = System.currentTimeMillis(); _db.commit(); long commit = System.currentTimeMillis(); _db.close(); long close = System.currentTimeMillis(); LOG.info( format( "ReadOnlyOidEmpty", DF.format(begin - start), DF.format(result - begin), DF.format(iterate - result), DF.format(commit - iterate), DF.format(close - commit))); }
public void testLoadComputerMulti() throws Exception { Database database = _category.getDatabase(); database.begin(); ComputerMulti computer = (LaptopMulti) database.load(ComputerMulti.class, new Identity(new Integer(1), new Integer(1))); database.commit(); assertNotNull(computer); assertEquals(1, computer.getId1()); assertEquals(1, computer.getId2()); assertEquals("laptop 1", computer.getName()); database.close(); }