Wednesday 22 February 2012

SPRING DEMO FOR JDBC DAO ( Console)





note
====
     1)  set path=c:\windows\command;c:\jdk1.5\bin


     2)  set classpath=g:\springdemos\jdbc\mysqljdbc:
                       spring.jar;
                       commons-logging.jar;
                       mysqldriver.jar
        ( all the jar files have been placed in this folder)
     --------------------------------------------------------
     3)   I created a database in mysql ( xampp)
          named 'springcontacts'.
          I created a table ( table1)
          with key, name and place
          ( key assigned and String type)


        Created a few records.
        'select * from table1'
        I got expected readings.
        I left it running
     -------------------------------------------------------


     4)  I began with an interface  ( dbinter)
         I wrote an impementation   ( dbinterimpl)


         I created a configuration file in xml


         ( spring-config.xml)


     Then I wrote a console program ( demo)


     ------------------------------------------------------------
         setpath
         setcpath
         javac dbinter.java
         javac dbinterimpl.java
         ---
         java demo  "104"  "jacob"  "kanpur"  "add"
         ---
        I then checked up by a query in mysql window.
        I got correct result.


        This is an illustration for Spring DAO  support. (jdbc)
******************************************************
In my next blog, I will write about Hibernate through Spring in console.


In the third of the series, I will integrate JPA and Spring.