/** * Initializes database <code>sandvigstore</code> by creating it if it does not already exist and * {@link #importData() imports data} if no tables are in it */ private void init() { jdbcTemplate.execute("CREATE DATABASE IF NOT EXISTS sandvigbookstore;"); dataSource.setDatabaseName("sandvigbookstore"); int tableCount = jdbcTemplate.queryForObject( "SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'sandvigbookstore';", Integer.class); if (tableCount == 0) { importData(); } }