1 16 package org.apache.juddi.datastore.jdbc; 17 18 import java.sql.Connection ; 19 20 import org.apache.juddi.datatype.publisher.Publisher; 21 import org.apache.juddi.util.Config; 22 import org.apache.juddi.util.jdbc.Transaction; 23 24 27 public class TestPublisherTable 28 { 29 public static void main(String [] args) 30 throws Exception 31 { 32 Config.setStringProperty("juddi.useConnectionPool","true"); 35 36 Connection conn = null; 37 try { 38 conn = Database.aquireConnection(); 39 test(conn); 40 } 41 finally { 42 if (conn != null) 43 conn.close(); 44 } 45 } 46 47 public static void test(Connection connection) 48 throws Exception 49 { 50 Transaction txn = new Transaction(); 51 52 if (connection != null) 53 { 54 try 55 { 56 txn.begin(connection); 58 59 Publisher publisher = new Publisher(); 61 publisher.setPublisherID("bcrosby"); 62 publisher.setName("Bing Crosby"); 63 publisher.setEmailAddress("bcrosby@juddi.org"); 64 publisher.setAdmin(false); 65 publisher.setEnabled(false); 66 PublisherTable.insert(publisher,connection); 67 68 System.out.println(PublisherTable.select("bcrosby",connection)); 70 71 publisher.setName("Barthalomue Crosby"); 72 publisher.setEnabled(true); 73 PublisherTable.update(publisher,connection); 74 75 System.out.println(PublisherTable.select("bcrosby",connection)); 77 78 PublisherTable.delete("bcrosby",connection); 80 81 System.out.println(PublisherTable.select("bcrosby",connection)); 83 System.out.println(""); 84 85 txn.commit(); 87 } 88 catch(Exception ex) 89 { 90 try { txn.rollback(); } 91 catch(java.sql.SQLException sqlex) { sqlex.printStackTrace(); } 92 throw ex; 93 } 94 } 95 } 96 } | Popular Tags |