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

  • SEARCH
  • Home
  • 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 800619
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T23:19:01+00:00 2026-05-14T23:19:01+00:00

I am using JDBC to connect to MySQL for a small application. In order

  • 0

I am using JDBC to connect to MySQL for a small application. In order to test without altering the real database, I’m using HSQL in memory for JUnit tests.

I’m using Spring for DI and DAOs. Here is how I’m configuring my HSQL DataSource

<bean id="mockDataSource" class="org.springframework.jdbc.datasource.SingleConnectionDataSource">
    <property name="driverClassName" value="org.hsqldb.jdbcDriver"/>
    <property name="url" value="jdbc:hsqldb:mem:mockSeo"/>
    <property name="username" value="sa"/>
</bean>

This works fine for my JUnit tests which use the mock DB. But when I try to run a main method, I find the following error:

Error creating bean with name 'mockDataSource' defined in class path resource [beans.xml]: 
Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'driverClassName' threw exception; nested exception is java.lang.IllegalStateException: 
Could not load JDBC driver class [org.hsqldb.jdbcDriver]

I’m running from Eclipse, and I’m using the Maven plugin. Is there a reason why this would work as a Test, but not as a main()? I know that the main method itself is not the problem, because it works if I remove all references to the HSQL DataSource from my Spring Configuration file.

  • 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-05-14T23:19:02+00:00Added an answer on May 14, 2026 at 11:19 pm

    m2eclipse won’t add your test-scoped dependencies to the classpath when you run the application as ‘Java Application’. You will need to change the scope of the hsql dependency to ‘compile’ (the default) for that to happen.

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

Sidebar

Related Questions

I have a MySQL database and a java application using it thru JDBC. I
I'm trying to connect to MySQL using JDBC connection in a Servlet .I'm using
I am trying to connect to a MySQL Server using JDBC tool in java
How to connect to a Microsoft Access-based database in a Windows using JDBC code?
I am using jdbc to select data from a mysql database. I am performing
I am using JDBC to query a MySQL database for specific records from two
I have a java-application using JDBC for database interaction. I want to do a
I'm accessing public mySQL database using JDBC and mySQL java connector . exonCount is
I am using JDBC with proxool connection pool to connect to mysql DB. I
I have created a java SE application that uses the mysql database using mysql

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.