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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:38:48+00:00 2026-05-28T07:38:48+00:00

Lost in the multitude of Java API’s and XML configuration. I am trying to

  • 0

Lost in the multitude of Java API’s and XML configuration.

I am trying to create an app with the Spring MVC but struggling with the XML configuration.

I want to be able to connect to a mysql database… but I am struggling to find any concise way of how to do it. I do not want to use Hibernate or any additional frameworks, the JDBC will be adequate on it’s own.

I would just like to be able to create a database connection and access to a String variable that can change the query as necessary. I think the problem lies within the xml configuration, but I may be wrong.

I have pasted the details shown below in the application-context.xml file, but the server cannot be built unless I remove them. I am not sure if I am missing something simple!

<bean id="JdbcDao" class="com.bcash.DbAccess.JdbcDao">
    <property name="dataSource" ref="dataSource"/>
</bean>      

<bean id="dataSource"
      class="org.springframework.jdbc.datasource.DriverManagerDataSource"
      p:driverClassName="com.mysql.jdbc.Driver"
      p:url="jdbc:mysql://localhost:3306/db_name"
      p:username="root"
      p:password=""
      destroy-method="close" />

This is the associated class that I wrote for the xml declaration

package com.bcash.DbAccess;

import javax.sql.DataSource;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.JdbcTemplate;

public class JdbcDao {

private JdbcTemplate jdbcTemplate;
protected String query = "INSERT INTO    user('username','email','password','access_level') VALUES ('admin','test@test.com','testPassWord','admin')";


public void insertUser(){

    try{
        jdbcTemplate.update(query);

    } catch(DataAccessException e){

       String error =  e.getMessage();
       System.out.println(error);

    }

}

}

The only error that I get is that the server could not be deployed on line 726 of the ant build script

<target if="netbeans.home" name="-run-deploy-nb">
    <nbdeploy clientUrlPart="${client.urlPart}" debugmode="false" forceRedeploy="${forceRedeploy}"/>
</target>

Although, I am okay with PHP, I am a little confused as I am fairly new to Java.

Thanks in advance

  • 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-28T07:38:49+00:00Added an answer on May 28, 2026 at 7:38 am

    I don’t know that I really follow the question you are asking about the build, but looking at the code and how you have things setup I do see one thing that looks like a problem. It looks like you never instantiate your JdbcTemplate and associate it with the dataSource.

    You should create your JdbcTemplate instance as a bean like this:

      <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
        <property name="dataSource">
          <ref bean="dataSource" />
        </property>
      </bean>
    

    Then make sure you have a set method for your jdbcTemplate variable and pass the reference to the template into your bean instead of the dataSource.

    <bean id="JdbcDao" class="com.bcash.DbAccess.JdbcDao">
        <property name="jdbcTemplate" ref="jdbcTemplate"/>
    </bean>  
    

    Doing this your JdbcTemplate will have a reference to your dataSource and you should then be able to perform queries.

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

Sidebar

Related Questions

I lost last 3 hours trying to do this. Im making an app that
I am lost. I am trying to release my first iPhone app, and the
I'm kind of lost about writing my information to an XML file. I want
I have lost my sources but I have my executable .jar file. I want
I am a little lost being new to databases. I am trying to create
I am a bit lost at the moment in trying to determine why JBOSS
I am so lost on this. I am trying to use the publishUserAction feature
We lost some data due to a data corruption issue, and we're trying to
I'm kinda lost on CentOS. I'm trying to run a Tomcat server in remote
I'm a bit lost right now, what I'm trying to do: build a 1.5

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.