Plands.com Logo  Business Internet Services 
Main Menu
Home
Planetary CRM
  Benefits
  Features
  Demo
E-Mail Services
  E-mail Hosting
  Newsletters
  Discussion Lists
Web Hosting
Server Co-location
and Administration
Web Applications
Technical Support
Contact Us
DXP Samples
 
DxpHome  ||   Samples  ||   Details  ||   Docs  ||   Trees  ||   xml-xsl  ||   Links
// DbStmt.java

The DbStmt node executes an SqlStmt using a database Connection. The SqlStmt is containing runtime parameter values is provided by the first Parameter tag enclosed by the DbStmt. This may be an SqlStmt, Rp, Cp or any other tag the implements the Parameter interface.

Here is and example that uses an SqlStmt tag to provide a stmt to execute. The runtime values that are inserted into the stmt are provided by children of the SqlStmt tag below. The DbStmt tag itself only has one child.

  
<dxp:DbStmt action="query" dbcon="member" store="record">
   <dxp:SqlStmt>
      <dxp:Cp name="sql">select from member where lastname='?' and company='?'</dxp:Cp>
      <dxp:SqlParam name="lastname" type="CHAR" require="true"/>
      <dxp:SqlParam name="company" type="CHAR" require="true"/>
   </dxp:SqlStmt>
</dxp:DbStmt>

The action attribute specifies the type of stmt to execute. Currently support types are:

  • query - Query result formatted as StringRecordSet for html output
  • getValue - Query for col value formatted as String
  • getPosValue - Query for pos int formatted as String. Returns neg if not found
  • getFirstRow - Query for the first record formatted as StringRecordSet
  • getMultValues - Query for the first record and store as numbered values store.n
  • upate - Update and return the the count as a String
  • autoid - Insert into a table that has an auto_increment field, then select LAST_INSERT_ID() This is supported by MySQL but other DBs may not support it.
  • queryObjects - Query result formatted as ObjectRecordSet to feed into other tags or methods
  • getObject - Query for col Object

The dbcon attribute specifies the name of a DbPool to get a connection from. DbPools are managed by the DbManager which is stored in the ServletContext.


@see com.plands.dbutil.DbManager.

When a DbStmt is being used inside a DbTransaction tag the Connection is obtained by specifying a dbkey attribute rather than a dbcon attribute. A dbkey should have the same value as that specified by the parent DbTransaction tag which stores a Connection in the request using the dbkey. The DbTransaction will remove the key from the reqeust when it has finished running it's children.


@see com.plands.dxp.DbTransaction
@author Mark Ashworth
@version 0.2, 2001-06-05

Return to Index

Note: We have tried to test all of the code examples but they may contain errors. Any questions, comments, suggestions, or problems should be sent to info@plands.com.