Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Config
- H2 database, server mode
- C3P0 pool
- Hibernate 3.6
- // In hibernate.cfg.xml
- <mapping class="com.company.model.User"/>
- // Class
- @Entity
- @Table(name="USER")
- public class User {
- private String login;
- private String password;
- private String role;
- }
- // Code to generate schema
- Configuration config = new Configuration();
- config.configure();
- SchemaExport schemaExport = new SchemaExport(config);
- schemaExport.create(true, true);
- // Log
- 18:49:14,509 INFO SchemaExport:262 - exporting generated schema to database
- 18:49:14,513 INFO ConnectionProviderFactory:173 - Initializing connection provider: org.hibernate.connection.C3P0ConnectionProvider
- 18:49:14,514 INFO C3P0ConnectionProvider:103 - C3P0 using driver: org.h2.Driver at URL: jdbc:h2:tcp://localhost/resanet
- 18:49:14,514 INFO C3P0ConnectionProvider:104 - Connection properties: {user=sa, password=****}
- 18:49:14,514 INFO C3P0ConnectionProvider:107 - autocommit mode: false
- 18:49:14,771 INFO SchemaExport:281 - schema export complete
Add Comment
Please, Sign In to add comment