Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8268013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T05:43:58+00:00 2026-06-08T05:43:58+00:00

Context.xml <jdbc:initialize-database data-source=dataSource ignore-failures=ALL> <jdbc:script location=classpath:scrubd.sql/> </jdbc:initialize-database> <bean id=dataSource class=org.springframework.jdbc.datasource.DriverManagerDataSource> <property name=driverClassName value=org.hsqldb.jdbc.JDBCDriver/> <property

  • 0

Context.xml

<jdbc:initialize-database data-source="dataSource" ignore-failures="ALL">
    <jdbc:script location="classpath:scrubd.sql"/>
</jdbc:initialize-database>

<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">  
    <property name="driverClassName" value="org.hsqldb.jdbc.JDBCDriver"/>
    <property name="url" value="jdbc:hsqldb:mem:mydb"/>
    <property name="username" value="sa"/>
    <property name="password" value=""/>
</bean>

<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"
      depends-on="dataSource"
      name="_sessFac"> 
    <property name="dataSource" ref="dataSource"/>      
    <property name="configLocation" value="hibernate.cfg.xml.incDTD"/>
    <property name="hibernateProperties">
        <props>
            <prop key="hibernate.dialect">org.hibernate.dialect.HSQLDialect</prop>
            <prop key="hibernate.hbm2ddl.auto">create</prop>
            <prop key="hibernate.show_sql">true</prop>
            <prop key="hibernate.connection.shutdown">true</prop>
        </props>
    </property>
</bean>

When I am running my ant target on my unit tests, after spring gets initialized the first time, I get an out of memory error. Yet, when I populate my tables by simply naming my database import.sql and letting hibernate handle it, I do not get this out of memory error.

Why does this happen?

Also, it takes Spring about a second longer to load the data in the database than hibernate. Bonus points to anyone that can explain why.

StackTrace (from ant)

Caused by: java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOfRange(Arrays.java:2694)
at java.lang.String.<init>(String.java:234)
at java.lang.StringBuffer.toString(StringBuffer.java:561)
at org.apache.tools.ant.util.StringUtils.replace(StringUtils.java:92)
at org.apache.tools.ant.util.DOMElementWriter.encodedata(DOMElementWriter.java:501)
at org.apache.tools.ant.util.DOMElementWriter.write(DOMElementWriter.java:236)
at org.apache.tools.ant.util.DOMElementWriter.write(DOMElementWriter.java:221)

And the bean causing it has got to be my session factory, since I wouldn’t call <jdbc:initialize-database/> a ‘bean’.

I want to say based on the stack trace that it is reading the entirety of my sql script into a string, since it is quite large; ~38K lines.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T05:43:59+00:00Added an answer on June 8, 2026 at 5:43 am

    Ended up just saying screw it, and letting hibernate populate my tables. The fact that I am now reading in a 20mB file when doing my unit tests, and I am still not getting an out of memory error with hibernate makes me think that if you want to populate your tables before doing unit tests on them, don’t let spring do it. Live and learn.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is my Resource element in context.xml :: <Resource name=jdbc/myoracle auth=Container type=javax.sql.DataSource driverClassName=oracle.jdbc.driver.OracleDriver url=jdbc:oracle:thin:@localhost:1521:XE
PersistenceHelper-context.xml <bean id=dataSource class=org.springframework.jdbc.datasource.DriverManagerDataSource> <!----> <property name=driverClassName value=org.hsqldb.jdbc.JDBCDriver/> <property name=url value=jdbc:hsqldb:mem:mydb/> <property name=username value=sa/>
I am using JNDI to read database configuration from my application's context.xml. The way
I just have a test. Config jndi in $CATALINA_HOME/conf/context.xml like below: <Resource name=jdbc/db auth=Container
First, a bit of context: web.xml: I match all /app/* requests to my dispatcher:
I am using Spring Jdbc template and for that I have context.xml <property name=driverClassName
I am used to configuring web application in context.xml , including jdbc resorces, and
I'm using Spring and struts and have the following entry in 'C:/source/webapp/WebContent/META-INF/context.xml' with tokens
I am using tomcat connection pool, jpa, hibernate. The datasource i created in context.xml
I am using below statement for database in tomcat context.xml. Some time it works

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.