my dog learned polymorphism*
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
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
Author

Connection time out error while deploying Spring app

Pratyusha jag
Greenhorn

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 java.net.ConnectException: Connection timed out: connect

java.net.ConnectException: Connection timed out: connect
.....
......





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

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

<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd">

<beans>

<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" />

</bean>

</beans>


The code to access the db is as below:

<pre><code>
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 });

System.out.println(rowsInserted);

}

public void setDataSource(DataSource dataSource) {

this.dataSource = dataSource;

}

}

</code></pre>

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.



Thanks,

Neetu

Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10170
    
    8

"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!]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Connection time out error while deploying Spring app
 
Similar Threads
Error: Error creating bean with name 'dataSource'
Spring Framework configuration
Spring - MySql Connectivity Error
DataSource null in DWR
Spring Struts implementation for Database conncetion problem in Login module