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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T14:02:59+00:00 2026-06-05T14:02:59+00:00

I have this working java code that serve as the datasource: public final class

  • 0

I have this working java code that serve as the “datasource”:

public final class PMF {
        static Driver driver = null;
    static String url = "jdbc:jiql://local";

    static Properties props = new Properties();

    static {
       String password = "jiql";
       String user = "admin";
       props.put("user",user);
       props.put("password",password);
       try {
           Class clazz = Class.forName("org.jiql.jdbc.Driver");
           driver = (Driver) clazz.newInstance();
       } catch (Exception e){
           e.printStackTrace();
       }
    }

    public static Connection get() {
        try{
            return driver.connect(url,props);
        } catch (java.sql.SQLException e){
            e.printStackTrace();
        }
        return null;
    }
}

When I tried to adapt this code for Spring with the code below:

jdbc.properties

jdbc.driverClassName=org.jiql.jdbc.Driver

# development
jdbc.url=jdbc:jiql://local
jdbc.username=admin
jdbc.password=jiql

applicationContext.xml

<!-- placeholders -->
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="locations" value="/WEB-INF/jdbc.properties"/>
</bean>

<!-- data source -->
<bean id="dataSource" destroy-method="close" class="org.apache.commons.dbcp.BasicDataSource">
    <property name="driverClassName" value="${jdbc.driverClassName}"/>
    <property name="url" value="${jdbc.url}"/>
    <property name="username" value="${jdbc.username}"/>
    <property name="password" value="${jdbc.password}"/>
</bean> 

The “datasource” gets null when I do this in the DAO:

@Autowired
private DataSource dataSource;

What could be causing the datasource to be null?

  • 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-05T14:03:00+00:00Added an answer on June 5, 2026 at 2:03 pm

    It looks like it was a DAO issue and not JDBC issue. I re-created the app using Spring STS and everything went working.

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

Sidebar

Related Questions

I have this working code, but now i need to be able to change
I currently have this working but it requires me to have a static method
I am working on a java program that is essentially a chat room. This
I have a bit of Java code that outputs an XML file to a
I have been working on a java application that has a connection to a
I have written some code in Java that will decode a SHOUTcast stream and
I am working on a Java Web Application that exposes a web service. This
[I have this working, but I don't understand why my fix to make it
I have this working on local setup (with jquery.1.6.4) but it is not working
I have this working great, but I'd like a deeper understanding of what is

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.