1 14 package org.compiere.db; 15 16 22 public class Database 23 { 24 25 public static String DB_ORACLE = "Oracle"; 26 27 public static String DB_POSTGRESQL = "PostgreSQL"; 28 29 30 public static String [] DB_NAMES = new String [] { 31 DB_ORACLE 32 }; 34 35 36 protected static Class [] DB_CLASSES = new Class [] { 37 DB_Oracle.class 38 }; 40 41 42 public static int CONNECTION_TIMEOUT = 10; 43 44 45 46 47 private static CompiereDatabase s_db = null; 48 49 54 public static void setDatabase (String databaseName) throws Exception 55 { 56 for (int i = 0; i < DB_NAMES.length; i++) 57 { 58 if (DB_NAMES[i].equals(databaseName)) 59 { 60 s_db = (CompiereDatabase)DB_CLASSES[i].newInstance(); 61 return; 62 } 63 } 64 throw new IllegalArgumentException ("Database.setDatabase - Database invalid: " + databaseName); 65 } 67 72 public static void setDatabase (CompiereDatabase database) throws Exception 73 { 74 if (database == null) 75 throw new IllegalArgumentException ("Database.setDatabase - Database is NULL"); 76 s_db = database; 77 } 79 83 public static CompiereDatabase getDatabase() 84 { 85 return s_db; 86 } 88 } | Popular Tags |