View Javadoc
1 package com.fc.taglibs.castor.utils; 2 3 import tyrex.tm.TransactionDomain; 4 import tyrex.resource.Resources; 5 import tyrex.resource.Resource; 6 import tyrex.resource.ResourceException; 7 8 import tyrex.tm.DomainConfigurationException; 9 10 import javax.sql.DataSource; 11 import java.sql.Connection; 12 import java.sql.Statement; 13 import java.sql.ResultSet; 14 15 public class TyrexTest { 16 // your program begins with a call to main() 17 public static void main(String args[]){ 18 TransactionDomain domain; 19 Resources resources; 20 Resource resource; 21 DataSource dataSource; 22 Connection conn; 23 Statement s; 24 ResultSet r; 25 26 // Create a transaction domain using 27 // a domain configuration file 28 try 29 { 30 domain = TransactionDomain.createDomain( "etc/tyrex/domain-with-resources.xml" ); 31 resources = domain.getResources(); 32 resource = resources.getResource( "myDataSource3" ); 33 dataSource = (DataSource) resource; 34 conn = dataSource.getConnection(); 35 s = conn.createStatement(); 36 r = s.executeQuery("SELECT client.id,client.name,project.id FROM client LEFT OUTER JOIN project ON client.id=project.client_id"); 37 conn.close(); 38 39 } 40 catch ( DomainConfigurationException except ) 41 { 42 // Domain cannot be created, handle error 43 System.out.println("DomainConfigurationException: " + except.getMessage()); 44 except.printStackTrace(); 45 } 46 catch ( ResourceException except ) 47 { 48 // Resources couldn't be got 49 System.out.println("ResourceException: " + except.getMessage()); 50 except.printStackTrace(); 51 } 52 catch ( java.sql.SQLException except ) 53 { 54 // Domain cannot be created, handle error 55 System.out.println("java.sql.SQLException: " + except.getMessage()); 56 except.printStackTrace(); 57 } 58 } 59 }

This page was automatically generated by Maven