Your browser does not support JavaScript and this site utilizes JavaScript to build content and provide links to additional information. You should either enable JavaScript in your browser settings or use a browser that supports JavaScript in order to take full advantage of this site.
1 16 package org.apache.juddi.util.jdbc; 17 18 import java.sql.Connection ; 19 import java.sql.PreparedStatement ; 20 import java.sql.SQLException ; 21 import java.util.Vector ; 22 23 26 public class DynamicQuery 27 { 28 31 private Vector values = null; 32 private StringBuffer sql = null; 33 34 37 public DynamicQuery() 38 { 39 this.values = new Vector (); 40 this.sql = new StringBuffer (); 41 } 42 43 public DynamicQuery(String sql) 44 { 45 this.values = new Vector (); 46 this.sql = new StringBuffer (sql); 47 } 48 49 public void append(String sql) 50 { 51 this.sql.append(sql); 52 } 53 54 public void addValue(Object obj) 55 { 56 this.values.addElement(obj); 57 } 58 59 public PreparedStatement buildPreparedStatement(Connection connection) 60 throws SQLException ![JavaDoc](../../../../../../cmn/javadoc.gif) 61 { 62 PreparedStatement stmt = connection.prepareStatement(sql.toString()); 63 for (int i=0; i<values.size(); i++) 64 stmt.setObject(i+1,values.elementAt(i)); 65 66 return stmt; 67 } 68 69 public String toString() 70 { 71 StringBuffer buffer = new StringBuffer (sql.toString()); 72 buffer.append("\n\n"); 73 74 for (int i=0; i<values.size(); i++) 75 { 76 Object obj = values.elementAt(i); 77 78 buffer.append(i+1); 79 buffer.append("\t"); 80 buffer.append(obj.getClass().getName()); 81 buffer.append("\t"); 82 buffer.append(obj.toString()); 83 buffer.append("\n"); 84 } 85 86 return buffer.toString(); 87 } 88 } 89
| Popular Tags
|