1 16 17 package org.apache.cocoon.components.modules.database; 18 19 import java.sql.Connection ; 20 import java.sql.PreparedStatement ; 21 import java.sql.ResultSet ; 22 import java.sql.SQLException ; 23 import java.sql.Statement ; 24 import java.util.Map ; 25 26 import org.apache.avalon.framework.configuration.Configuration; 27 import org.apache.avalon.framework.configuration.ConfigurationException; 28 import org.apache.avalon.framework.thread.ThreadSafe; 29 30 38 public class HsqlIdentityAutoIncrementModule implements AutoIncrementModule, ThreadSafe { 39 40 public Object getPostValue( Configuration tableConf, Configuration columnConf, Configuration modeConf, 41 Connection conn, Statement stmt, Map objectModel ) throws SQLException , ConfigurationException { 42 43 Integer id = null; 44 51 52 PreparedStatement pstmt = conn.prepareStatement("CALL IDENTITY()"); 53 ResultSet resultSet = pstmt.executeQuery(); 54 while ( resultSet.next() ) { 55 id = new Integer (resultSet.getInt(1)); 56 } 57 resultSet.close(); 58 59 return id; 60 } 61 62 63 public boolean includeInQuery() { return false; } 64 65 66 public boolean includeAsValue() { return false; } 67 68 69 public Object getPreValue( Configuration tableConf, Configuration columnConf, Configuration modeConf, 70 Connection conn, Map objectModel ) throws SQLException , ConfigurationException { 71 72 return null; 73 } 74 75 76 public String getSubquery( Configuration tableConf, Configuration columnConf, Configuration modeConf ) 77 throws ConfigurationException { 78 79 return null; 80 } 81 } 82 | Popular Tags |