1 6 7 package org.jfox.jdbc.xa; 8 9 import javax.sql.XADataSource ; 10 11 import com.microsoft.jdbcx.sqlserver.SQLServerDataSource; 12 13 18 19 public class MICROSOFTXADataSource extends AbstractXADataSource { 20 21 public MICROSOFTXADataSource(String url) { 22 super(url); 23 } 24 25 public XADataSource init(String url) { 26 try { 28 SQLServerDataSource sqlXaDS = new SQLServerDataSource(); 29 30 URLProperties urlProp = parseSqlURL(url); 31 32 if(urlProp.containsKey("serverName")) { 33 sqlXaDS.setServerName(urlProp.getProperty("serverName")); 34 } 35 36 if(urlProp.containsKey("portNumber")) { 37 sqlXaDS.setPortNumber(Integer.parseInt(urlProp.getProperty("portNumber"))); 38 } 39 40 if(urlProp.containsKey("databaseName")) { 41 sqlXaDS.setDatabaseName(urlProp.getProperty("databaseName")); 42 } 43 44 if(urlProp.containsKey("embedded")) { 45 sqlXaDS.setEmbedded(new Boolean (urlProp.getProperty("embedded")).booleanValue()); 46 } 47 48 if(urlProp.containsKey("batchPerformanceWorkaround")) { 49 sqlXaDS.setBatchPerformanceWorkaround(new Boolean (urlProp.getProperty("portNumber")).booleanValue()); 50 } 51 52 if(urlProp.containsKey("selectMethod")) { 53 sqlXaDS.setSelectMethod(urlProp.getProperty("selectMethod")); 54 } 55 else { 56 sqlXaDS.setSelectMethod("cursor"); 58 } 59 return sqlXaDS; 60 } 61 catch(Exception e) { 62 e.printStackTrace(); 63 return null; 64 } 65 66 } 67 68 public static void main(String [] args) { 69 70 } 71 } | Popular Tags |