Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package esame;
- import javax.annotation.PostConstruct;
- import javax.annotation.PreDestroy;
- import javax.annotation.sql.DataSourceDefinition;
- import javax.ejb.Singleton;
- import javax.ejb.Startup;
- import javax.inject.Inject;
- /**
- *
- * @author Desi
- */
- @Singleton
- @Startup
- @DataSourceDefinition(
- user = "app",
- password = "app",
- databaseName = "EsameDB",
- className = "org.apache.derby.jdbc.EmbeddedDataSource",
- name = "java:global/jdbc/EsameDS",
- properties = {"connectionAttributes=;create=true"}
- )
- public class DatabasePopulator {
- @Inject
- private ViaggioEJB vejb;
- private Viaggio v1,v2,v3;
- @PostConstruct
- public void CreateDB(){
- v1 = new Viaggio("c1", "d1", 1, 1, 1, 1);
- v1 = new Viaggio("c2", "d2", 2, 2, 2, 2);
- v1 = new Viaggio("c3", "d3", 3, 3, 3, 3);
- vejb.create(v1);
- vejb.create(v2);
- vejb.create(v3);
- }
- @PreDestroy
- public void ClearDB(){
- vejb.remove(v1);
- vejb.remove(v2);
- vejb.remove(v3);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement