Announcement Announcement Module
Collapse
No announcement yet.
spring MVC step by step Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • spring MVC step by step

    Rightnow I am learning with developing spring MVC application page-4 database persistence.

    I included some targets for create, load, print table.

    Build file:

    Code:
    <target name="createTables">
            <echo message="CREATE TABLES USING: ${db.driver} ${db.url}"/>
            <sql driver="${db.driver}"
                 url="${db.url}"
                 userid="${db.user}"
                 password="${db.pw}"
                 onerror="continue">  
                <classpath refid="master-classpath"/>
    
            CREATE TABLE products (
              id INTEGER NOT NULL PRIMARY KEY,
              description varchar(255),
              price decimal(15,2)
            );
            CREATE INDEX products_description ON products(description);
    
            </sql> 
        </target>
    
        <target name="dropTables">
            <echo message="DROP TABLES USING: ${db.driver} ${db.url}"/>
            <sql driver="${db.driver}"
                 url="${db.url}"
                 userid="${db.user}"
                 password="${db.pw}"
                 onerror="continue">  
                <classpath refid="master-classpath"/>
    
            DROP TABLE products;
    
            </sql> 
        </target>
    
        <target name="loadData">
            <echo message="LOAD DATA USING: ${db.driver} ${db.url}"/>
            <sql driver="${db.driver}"
                 url="${db.url}"
                 userid="${db.user}"
                 password="${db.pw}"
                 onerror="continue">  
                <classpath refid="master-classpath"/>
    
            INSERT INTO products (id, description, price) values(1, 'Lamp', 5.78);
            INSERT INTO products (id, description, price) values(2, 'Table', 75.29);
            INSERT INTO products (id, description, price) values(3, 'Chair', 22.81);        COMMIT;        SHUTDOWN        </sql> 
        </target>
    
        <target name="printData">
            <echo message="PRINT DATA USING: ${db.driver} ${db.url}"/>
            <sql driver="${db.driver}"
                 url="${db.url}"
                 userid="${db.user}"
                 password="${db.pw}"
                 onerror="continue"
                 print="true">  
                <classpath refid="master-classpath"/>
    
            SELECT * FROM products;
    
            </sql> 
        </target>
    
        <target name="clearData">
            <echo message="CLEAR DATA USING: ${db.driver} ${db.url}"/>
            <sql driver="${db.driver}"
                 url="${db.url}"
                 userid="${db.user}"
                 password="${db.pw}"
                 onerror="continue">  
                <classpath refid="master-classpath"/>
    
            DELETE FROM products;
    
            </sql> 
        </target>
    Run with eclipse::

    Run target createTable:

    Code:
    Buildfile: C:\Projects_D\springapp\build.xml
    createTables:
         [echo] CREATE TABLES USING: org.hsqldb.jdbcDriver jdbc:hsqldb:db/test
          [sql] Executing commands
          [sql] 2 of 2 SQL statements executed successfully
    BUILD SUCCESSFUL
    Total time: 672 milliseconds
    Run target loadData:

    Code:
    Buildfile: C:\Projects_D\springapp\build.xml
    loadData:
         [echo] LOAD DATA USING: org.hsqldb.jdbcDriver jdbc:hsqldb:db/test
          [sql] Executing commands
          [sql] Failed to execute:  INSERT INTO products (id, description, price) values(1, 'Lamp', 5.78)
          [sql] java.sql.SQLException: Table not found in statement [ INSERT INTO products]
          [sql] Failed to execute:  INSERT INTO products (id, description, price) values(2, 'Table', 75.29)
          [sql] java.sql.SQLException: Table not found in statement [ INSERT INTO products]
          [sql] Failed to execute:  INSERT INTO products (id, description, price) values(3, 'Chair', 22.81);        COMMIT;        SHUTDOWN
          [sql] java.sql.SQLException: Table not found in statement [ INSERT INTO products]
          [sql] 0 of 3 SQL statements executed successfully
    BUILD SUCCESSFUL
    Total time: 641 milliseconds

    Run target printData:

    Code:
    Buildfile: C:\Projects_D\springapp\build.xml
    printData:
         [echo] PRINT DATA USING: org.hsqldb.jdbcDriver jdbc:hsqldb:db/test
          [sql] Executing commands
          [sql] Failed to execute:  SELECT * FROM products
          [sql] java.sql.SQLException: Table not found in statement [ SELECT * FROM products]
          [sql] 0 of 1 SQL statements executed successfully
    BUILD SUCCESSFUL
    Total time: 672 milliseconds

    Why is this happening?Where am i wrong?

    Pl suggest

    Regards

  • #2
    Now when I close eclipse window and then try, It loads and print data.But I am not getting why that happened.
    Ok whatever

    Comment

    Working...
    X