• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Connection time out error while deploying Spring app

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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="jdbc:odbc: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

 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"javagurl java

Please check your private messages for an important administrative matter
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic