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 8428347
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:01:48+00:00 2026-06-10T05:01:48+00:00

I would like to be able to support the following Sybase 15 ASE syntax

  • 0

I would like to be able to support the following Sybase 15 ASE syntax in my unit/integration tests that use HSQL…

create table #myTable (value varchar(12) NULL)

HSQL won’t recognise how the temp table is named, and baulks at the # character. Instead HSQL would like to use something like this…

create temporary table myTable (value varchar(12) NULL)

or, HSQL also supports most of ANSI-92 SQL according to their docs, however Sybase ASE 15 doesn’t have great support for ANSI-92 SQL including how temporary tables are created so the following won’t work in Sybase but does in HSQL…

DECLARE LOCAL TEMPORARY TABLE mytable (value varchar(12) NULL)

From everything I have tried I cannot come up with a common syntax that will work with both Sybase and HSQL. Does anyone know of a clean way around this?

The only option I think I have is to create separate DAO’s for each database dialect, and control which one is used in the Spring Application Context XML files.

I don’t use Hibernate for my datasource, only Spring’s JdbcTemplate.

  • 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-10T05:01:50+00:00Added an answer on June 10, 2026 at 5:01 am

    I chose to resolve this issue by implementing a couple of dialect helper classes for my DAO. My goals were to

    1. Execute tests against HSQL databse instead of Sybase
    2. Test as much of my production DAO as possible including the
      RowMapper and various SELECT/INSERT statements against the database schema as used in production (but implemented in HSQL)

    My DAO ended up looking like this (note the DialectHelper being injected) …

    @Repository
    public class MyDaoJdbc MyDao {
    
        private DialectHelper dialectHelper;
    
        /* the meat of the DAO removed for clarity */
    
        @Override
        public void createTemporaryTable() {        
            getSimpleJdbcTemplate().update(dialectHelper.getTempTableCreateSql());
        }
    
        @Autowired
        public final void setDialectHelper(DialectHelper dialectHelper) {
            this.dialectHelper = dialectHelper;
        }
    }
    

    … my production Spring configuration (spring-db.xml) looks like this and injects the Sybase dialect

    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
        <property name="driverClassName"    value="com.sybase.jdbc2.jdbc.SybDriver" />
        <property name="url"                    value="${jdbc.url}" />
        <property name="username"           value="${jdbc.username}" />
        <property name="password"           value="${jdbc.password}" />
    </bean>
    
    <bean id="dialectHelper" class="com.acme.myapp.jdbc.DialectHelperSybase" />
    

    … and my Test Spring configuration (spring-db-test.xml) looks like this and injects the HSQL dialect

    <jdbc:embedded-database id="dataSource" type="HSQL">
         <jdbc:script location="classpath:/resources/schema.sql"/>
         <jdbc:script location="classpath:/resources/test-data.sql"/>
    </jdbc:embedded-database>
    
    <bean id="dialectHelper" class="com.acme.myapp.dao.jdbc.DialectHelperHsql" />
    

    The DialectHelper classes provide a way of separating out the incompatible database syntax from the DAO …

    public class DialectHelperHsql implements DialectHelper {
        @Override
        public String getTempTableCreateSql() {
            return "create temporary table myTable (value varchar(12) NULL)";
        }
    }
    
    public class DialectHelperSybase implements DialectHelper {
        @Override
        public String getTempTableCreateSql() {
            return "create table #myTable (value varchar(12) NULL)";
        }
    }
    

    The Test class itself initialises Spring with the HSQL dialectHelper by loading the file spring-db-test.xml

    @RunWith(SpringJUnit4ClassRunner.class)
    @ContextConfiguration(locations={
        "classpath:resources/spring-context.xml",
        "classpath:resources/spring-db-test.xml"})
    @Transactional
    @TransactionConfiguration(defaultRollback = true)
    public class MyDaoIntegrationHsqlTest {
        ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to be able to create a variable that holds an instance
I have a site that supports localization. I would like to be able to
Would like to be able to set colors of headings and such, different font
I would like to be able to output the name of a variable, along
I would like to be able to print in the logs a message for
I would like to be able to show a personal message to abusers of
I would like to be able to go: sed s/^\(\w+\)$/leftside\1rightside/ and have the group
I would like to be able to define a function which accepts an argument
I would like to be able to redirect if a route constraint fails, rather
I would like to be able to add the help button onto my winform,

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.