File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Spring and the fly likes Connection time out error while deploying Spring app Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Connection time out error while deploying Spring app" Watch "Connection time out error while deploying Spring app" New topic

Connection time out error while deploying Spring app

Pratyusha jag

Joined: Feb 21, 2010
Posts: 1
Hello all,

I’ve just started learning Spring and I’m using Spring MVC framework to create a simple webapp to take a name in a text field in one page and on submit the value is inserted in an MS access database and a greeting is displayed in another page saying “hello, <name>!”. While trying to deploy my simple Spring web app, I am getting the following errors.

SEVERE: Context initialization failed

org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is Connection timed out: connect Connection timed out: connect

My applicationContext.xml and web.xml files are as follows:

<?xml version="1.0" encoding="UTF-8"?>



<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource" scope="singleton" destroy-method="close">

<property name="driverClassName" value="sun.jdbc.odbc.JdbcOdbcDriver" />

<property name="url" value="jdbcdbc:jdbcodbcdriver:;DRIVER=Microsoft Access Driver (*.accdb);DBQ=D:\206132\usernamedb.accdb;" />

<property name="username" value="admin" />

<property name="password" value="password" />



The code to access the db is as below:

package SpringClasses;

import javax.sql.DataSource;

import org.springframework.jdbc.core.JdbcTemplate;

public class Profile {

private String username;

private JdbcTemplate jt;

private DataSource dataSource;

public Profile() {

public Profile(String username) {

this.username = username;


public String getUsername() {

System.out.println("username " + username);

return username;


public void setUsername(String username) {

int rowsInserted;

jt = new JdbcTemplate(dataSource);

rowsInserted = jt.update("insert into usernamedb (username) values(?)",new Object[] { username });



public void setDataSource(DataSource dataSource) {

this.dataSource = dataSource;




I am unable to figure out the reason for the connection timed error. I have also added this data base under control panel -> administrative tools -> Data Sources (ODBC) -> both User DSN and System DSN.

Help is much appreciated.



Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10768

"javagurl java

Please check your private messages for an important administrative matter

[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
wood burning stoves
subject: Connection time out error while deploying Spring app
It's not a secret anymore!