View Javadoc
1 /* 2 * $Header: /cvsroot/ebxmlrr/ebxmlrr/src/share/com/sun/ebxml/registry/persistence/rdb/UsageParameterDAO.java,v 1.7 2003/05/30 22:42:39 waikei Exp $ 3 */ 4 5 package com.sun.ebxml.registry.persistence.rdb; 6 7 import java.util.*; 8 import java.sql.*; 9 10 import org.oasis.ebxml.registry.bindings.rim.*; 11 import org.oasis.ebxml.registry.bindings.rim.types.*; 12 13 import com.sun.ebxml.registry.*; 14 15 /*** 16 * DAO for UsageParameter 17 * 18 * @see <{User}> 19 * @author Farrukh S. Najmi 20 */ 21 public class UsageParameterDAO { 22 protected UsageParameterDAO(){} 23 24 public static String getTableNameStatic() { 25 return "UsageParameter"; 26 } 27 28 public String getTableName() { 29 return getTableNameStatic(); 30 } 31 32 /*** 33 * Does a bulk insert of a Collection of objects that match the type for this persister. 34 * 35 */ 36 public void insert(java.sql.Connection connection, String parentId, ArrayList usageParams) throws RegistryException { 37 38 Statement stmt = null; 39 40 if (usageParams.size()==0) { 41 return; 42 } 43 44 try { 45 stmt = connection.createStatement(); 46 47 Iterator iter = usageParams.iterator(); 48 while (iter.hasNext()) { 49 String value = (String)iter.next(); 50 51 52 String str = "INSERT INTO UsageParameter " + 53 "VALUES( " + 54 "'" + value + "', " + 55 "'" + parentId + "' )"; 56 stmt.addBatch(str); 57 } 58 59 if (usageParams.size() > 0) { 60 int [] updateCounts = stmt.executeBatch(); 61 //stmt.close(); 62 } 63 } 64 catch (java.sql.SQLException e) { 65 RegistryException exception = new RegistryException(e); 66 throw exception; 67 } finally { 68 try { 69 if (stmt != null) 70 stmt.close(); 71 } catch (SQLException sqle) { 72 sqle.printStackTrace(); 73 } 74 } 75 } 76 77 78 /*** 79 * Does a bulk delete of a Collection of objects that match the type for this persister. 80 * 81 */ 82 public void delete(java.sql.Connection connection, ArrayList parentIds) throws RegistryException { 83 84 Statement stmt = null; 85 try 86 { 87 stmt = connection.createStatement(); 88 89 Iterator iter = parentIds.iterator(); 90 while (iter.hasNext()) { 91 String parentId = (String)iter.next(); 92 93 94 stmt.addBatch("DELETE from UsageParameter WHERE parent = '" + 95 parentId + "' "); 96 } 97 98 int [] updateCounts = stmt.executeBatch(); 99 //stmt.close(); 100 } 101 catch (java.sql.SQLException e) { 102 RegistryException exception = new RegistryException(e); 103 throw exception; 104 } finally { 105 try { 106 if (stmt != null) 107 stmt.close(); 108 } catch (SQLException sqle) { 109 sqle.printStackTrace(); 110 } 111 } 112 } 113 114 115 public void loadObjectFromResultSet(java.sql.Connection conn, Object obj, ResultSet rs) throws RegistryException { 116 try { 117 if (!(obj instanceof java.lang.String)) { 118 throw new RegistryException("Unexpected object " + obj + ". Was expecting java.lang.String."); 119 } 120 121 String value = (String)obj; 122 value.concat(rs.getString("value")); 123 } 124 catch (SQLException e) { 125 e.printStackTrace(); 126 throw new RegistryException(e); 127 } 128 } 129 130 ArrayList getUsageParameteresByParent(java.sql.Connection conn, String parentId) throws RegistryException { 131 ArrayList usageParams = new ArrayList(); 132 Statement stmt = null; 133 134 try { 135 stmt = conn.createStatement(); 136 ResultSet rs = stmt.executeQuery("SELECT * FROM UsageParameter WHERE parent = '" + parentId + "'"); 137 138 while (rs.next()) { 139 String usageParam = new String(); 140 loadObjectFromResultSet(conn, usageParam, rs); 141 usageParams.add(usageParam); 142 } 143 } 144 catch (SQLException e) { 145 e.printStackTrace(); 146 throw new RegistryException(e); 147 } finally { 148 try { 149 if (stmt != null) 150 stmt.close(); 151 } catch (SQLException sqle) { 152 sqle.printStackTrace(); 153 } 154 } 155 156 return usageParams; 157 } 158 }

This page was automatically generated by Maven