wood burning stoves*
The moose likes Other Application Frameworks and the fly likes Spring sample applications - Need Help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "Spring sample applications - Need Help" Watch "Spring sample applications - Need Help" New topic
Author

Spring sample applications - Need Help

Niranjan Deshpande
Ranch Hand

Joined: Oct 16, 2005
Posts: 1277
Hi all,

I am following Sprign in Action 2.0 Though I am trying to read most of it, the problem is, the book does not have sample code, independent for each concept. It has a huge application called the Road Rantz, which if you try to configure, you end up getting annoyed as you never know what all jars it needs in it's build path. Also, you cannot touch the application unless you finish the comple book.

So far for chapters 1,2,4 I have been trying some sample independent code, targeted to the sections, as I read them. But chapter 5 onwards I am not able to do so. Like in chapter 5 for example, I am trying to use a jdbc template and a DAO object, and the spring's jdbc classes, data source for these templates. But I am not sure what to do and in which class? The code so far I wrote is:

package com.springinaction.db;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;





package com.springinaction.db;

import org.springframework.jdbc.core.support.JdbcDaoSupport;







After I run this application I can see this on the console.
INFO: Loaded JDBC driver: org.hsqldb.jdbcDriver

I want to connect to HSQL, and I am aware of starting this database's server and opening the HSQL's database manager window to create tables.

I want to try out the template and the jdbc stuff in spring using the above design/setup. HAve I written code at the correct places? Also, what should be the url property's value in above XML. My java application DbApplication is just going to insert a Employee object into the database, and read them

Please guide me on this.


SCJP 1.4 - 95% [ My Story ] - SCWCD 1.4 - 91% [ My Story ]
Performance is a compulsion, not a option, if my existence is to be justified.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

Why don't you just try to use the DAO to see if the employee is saved ? It looks to me that you have an unnecessary TestJdbcTemplate, and an unused DAO. You could remove the TestJdbcTemplate, and use your DAO instead :



[My Blog]
All roads lead to JavaRanch
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

To make it a bit more Springy, I'd make the DAO implement an interface, and use a separate class to access it. You'll understand its importance when you start sudying transactions.


[ March 07, 2008: Message edited by: Christophe Verre ]
Niranjan Deshpande
Ranch Hand

Joined: Oct 16, 2005
Posts: 1277
How about the value attribute of the URL property when I configure the data source? I want to use HSQL. Please help.


In case I use MS Access, I know that once can configure the ODBC source in Windows control panel, and link that name in the URL's vlaue field.

But how to do that for HSQL??
[ March 07, 2008: Message edited by: Niranjan Deshpande ]
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

Sorry, I don't know hsqldb's jdbc url format. You'll have to search into Hsqldb's documentation (like here)
 
 
subject: Spring sample applications - Need Help