Announcement Announcement Module
Collapse
No announcement yet.
How Initialize a not embedded database with JavaConfig? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How Initialize a not embedded database with JavaConfig?

    Hello Guys

    If I can add a script and therefore initialize an embedded database
    like below

    Code:
    @Bean
    public DataSource dataSource(){
    		
    	EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
    		
    	EmbeddedDatabase db = builder.
    			              setType(EmbeddedDatabaseType.HSQL).
    			              addScript("classpath:/com/manuel/hsql/scripts/hsql-creation-script.sql").
    			              build();
    		
    	//db.shutdown();
    	return db;
    }
    How I would do the same approach but for a *not* embedded database?

    Code:
    @Bean
    public DataSource dataSource() throws Exception{
    		
    	ComboPooledDataSource comboPooledDataSource = new ComboPooledDataSource();
    		
    	...
    		
    	return comboPooledDataSource;
    		
    }
    Thank You...

  • #2
    BTW:

    Is possible initialize a not embedded database with XML..

    Code:
    <context:property-placeholder location="classpath:/com/manuel/jordan/springframework/properties/*-production.properties" />
    		
    <bean id="dataSource" 
              class="com.mchange.v2.c3p0.ComboPooledDataSource" 
    	  destroy-method="close">		 		
    		  <property name="user" value="${database.user}" />
              ....
    </bean>
    
    <jdbc:initialize-database data-source="dataSource">
      	  <jdbc:script location="classpath:/com/manuel/jordan/mysql/scripts/mysql-delete-script.sql"/>    										   
    </jdbc:initialize-database>
    Therefore what is the equivalent of jdbc:initialize-database in JavaConfig...

    Thank You.

    Comment

    Working...
    X