/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.juddi.datastore.jdbc;
import java.sql.Connection;
import java.util.Vector;
import org.apache.juddi.util.Config;
import org.apache.juddi.util.jdbc.Transaction;
/**
* @author Steve Viens (sviens@apache.org)
*/
class TestFindServiceByBusinessKeyQuery
{
public static void main(String[] args)
throws Exception
{
// make sure we're using a DBCP DataSource and
// not trying to use JNDI to aquire one.
Config.setStringProperty("juddi.useConnectionPool","true");
Connection conn = null;
try {
conn = Database.aquireConnection();
test(conn);
}
finally {
if (conn != null)
conn.close();
}
}
public static void test(Connection connection)
throws Exception
{
String businessKey = "740d75b1-3cde-4547-85dd-9578cd3ea1cd";
Vector keysIn = new Vector();
keysIn.add("740d75b1-3cde-4547-85dd-9578cd3ea1cd");
keysIn.add("c311085b-3277-470d-8ce9-07b81c484e4b");
keysIn.add("6b368a5a-6a62-4f23-a002-f11e22780a91");
keysIn.add("45994713-d3c3-40d6-87b5-6ce51f36001c");
keysIn.add("901b15c5-799c-4387-8337-a1a35fceb791");
keysIn.add("80fdae14-0e5d-4ea6-8eb8-50fde422056d");
keysIn.add("e1996c33-c436-4004-9e3e-14de191bcc6b");
keysIn.add("3ef4772f-e04b-46ed-8065-c5a4e167b5ba");
Transaction txn = new Transaction();
if (connection != null)
{
try
{
// begin a new transaction
txn.begin(connection);
keysIn = FindServiceByBusinessKeyQuery.select(businessKey,keysIn,null,connection);
keysIn = FindServiceByBusinessKeyQuery.select(businessKey,null,null,connection);
// commit the transaction
txn.commit();
}
catch(Exception ex)
{
try { txn.rollback(); }
catch(java.sql.SQLException sqlex) { sqlex.printStackTrace(); }
throw ex;
}
}
}
}