cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From h...@apache.org
Subject cvs commit: xml-cocoon2/scratchpad/src/org/apache/cocoon/acting/ModularDatabaseAccess MysqlAutoIncrementHelper.java
Date Wed, 05 Dec 2001 09:36:54 GMT
haul        01/12/05 01:36:54

  Added:       scratchpad/src/org/apache/cocoon/acting/ModularDatabaseAccess
                        MysqlAutoIncrementHelper.java
  Log:
  Patch from Tim Myers <phantom@stserv.hcf.jhu.edu>
  AutoIncrementHelper for mysql
  
  Revision  Changes    Path
  1.1                  xml-cocoon2/scratchpad/src/org/apache/cocoon/acting/ModularDatabaseAccess/MysqlAutoIncrementHelper.java
  
  Index: MysqlAutoIncrementHelper.java
  ===================================================================
  /*****************************************************************************
   * Copyright (C) The Apache Software Foundation. All rights reserved.        *
   * ------------------------------------------------------------------------- *
   * This software is published under the terms of the Apache Software License *
   * version 1.1, a copy of which has been included  with this distribution in *
   * the LICENSE file.                                                         *
   *****************************************************************************/
  package org.apache.cocoon.acting.ModularDatabaseAccess;
  
  import java.lang.Integer;
  import java.sql.PreparedStatement;
  import java.sql.Connection;
  import java.sql.ResultSet;
  import java.sql.Statement;
  import java.sql.SQLException;
  import org.apache.cocoon.environment.Request;
  import org.apache.avalon.framework.configuration.Configuration;
  import org.apache.avalon.framework.configuration.ConfigurationException;
  import org.apache.avalon.framework.thread.ThreadSafe;
  
  /**
   * Abstraction layer to encapsulate different DBMS behaviour for autoincrement columns.
   *
   * Here: MYSQL AUTO_INCREMENT columns
   * {@link http://www.mysql.com}
   *
   * @author <a href="mailto:phantom@stserv.hcf.jhu.edu">Tim Myers</a>
   * @version CVS $Id: MysqlAutoIncrementHelper.java,v 1.1 2001/12/05 09:36:54 haul Exp $
   */
  public class MysqlAutoIncrementHelper implements AutoIncrementHelper, ThreadSafe {
      
      public Object getPostValue( Configuration tableConf, Configuration columnConf, Configuration
modeConf, 
                                  Connection conn, Statement stmt, Request request )  throws
SQLException, ConfigurationException {
  
          Integer id = null;
          /*
            // if mysql did support callable statements ...  i'm not sure what what would
go here, maybe:
  
            CallableStatement callStmt = conn.prepareCall("? = {CALL LAST_INSERT_ID()}");
            callStmt.registerOutParameter(1, Types.INTEGER);
            ResultSet resultSet = callStmt.executeQuery();
          */
          
          PreparedStatement pstmt = conn.prepareStatement("SELECT LAST_INSERT_ID()");
          ResultSet resultSet = pstmt.executeQuery();
          while ( resultSet.next() ) {
              id = new Integer(resultSet.getInt(1));
          }
          resultSet.close();
          
          return id;
      }
      
  
      public boolean includeInQuery() { return false; }
  
  
      public boolean includeAsValue() { return false; }
  
  
      public Object getPreValue( Configuration tableConf, Configuration columnConf, Configuration
modeConf, 
                                 Connection conn, Request request ) throws SQLException, ConfigurationException
{
  
          return null;
      }
  
  
      public String getSubquery( Configuration tableConf, Configuration columnConf, Configuration
modeConf ) 
          throws ConfigurationException {
  
          return null;
      }
  }
  
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org


Mime
View raw message