Import COM. xxx. config. configmanager; import COM. xxx. config. configs;/*** connection management class * @ author */public class connectionmanager {// Database Type Private Static int dbtype =-1; Private Static connectionfactory _ connfactory; /*** Oracle Database Type flag */public static int Oracle = 1;/*** MySQL database type flag */public static int MySQL = 2; /*** obtain database type * @ return Database Type flag */public static int getdbtype () {If (dbtype =-1) {string t Ype = configmanager. getkey (configkeys. dbtypekey); If ("oracle ". equals (type) {dbtype = ORACLE;} else if ("MySQL ". equals (type) {dbtype = MySQL;} elsedbtype = 0;} return dbtype;}/*** get the connectionfactory object based on the specified database configuration. * @ Return connectionfactory object */public static connectionfactory getconnectionfactory (configs conf) {connectionfactory FAC = NULL; string type = Conf. getconfig (configkeys. dbconntypekey); If ("JNDI ". equals (type) {FAC = new jndiconnectionfactory ();} else {string CLS = Conf. getconfig (configkeys. dbconnclasskey); If (CLS = NULL | Cls. length () = 0) {CLS = simpleconnectionfactory. class. getname ();} Cl Assloader Cl = connectionmanager. class. getclassloader (); try {FAC = (connectionfactory) Cl. loadclass (CLS ). newinstance ();} catch (exception ex) {ex. printstacktrace (); FAC = new simpleconnectionfactory () ;}} FAC. init (CONF); Return FAC;}/*** get the connectionfactory object and database operation entry according to the default database configuration. The default implementation class simpleconnectionfactory * @ return connectionfactory object */Public synchronized static connectionfactory getconnectionfactory () {If (_ connfactory = NULL) {configs conf = configmanager. getdefaconfigconfigs (); _ connfactory = getconnectionfactory (CONF);} return _ connfactory;} static class connectionclass; static connectionobject newconnectionobject () {If (connectionclass = NULL) {string CLS = configmana Ger. getdefaconfigconfigs (). getconfig ("connectionobjectclassname"); If (CLS! = NULL & Cls. length ()> 0) {classloader Cl = connectionmanager. class. getclassloader (); try {connectionclass = Cl. loadclass (CLS);} catch (exception ex) {}} if (connectionclass = NULL) {connectionclass = connectionobject. class; return New connectionobject () ;}try {return (connectionobject) connectionclass. newinstance () ;}catch (exception ex) {} return New connectionobject ();}}