• 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:

Spring sample applications - Need Help

 
Ranch Hand
Posts: 1277
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 :

 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 1277
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry, I don't know hsqldb's jdbc url format. You'll have to search into Hsqldb's documentation (like here)
 
reply
    Bookmark Topic Watch Topic
  • New Topic