1 19 25 26 package org.netbeans.modules.j2ee.sun.sunresources.beans; 27 28 import java.util.HashMap ; 29 import java.util.Iterator ; 30 import java.util.Set ; 31 32 36 public class DatabaseUtils { 37 38 private static HashMap driverMap; 39 private static HashMap dsClassMap; 40 41 42 private DatabaseUtils() { 43 } 44 45 public static String getDriverName(String url){ 46 String driverName = null; 47 Set urlKeys = driverMap.keySet(); 48 Iterator it = urlKeys.iterator(); 49 while(it.hasNext()){ 50 String urlPrefix = (String )it.next(); 51 if(url.startsWith(urlPrefix)){ 52 driverName = (String )driverMap.get(urlPrefix); 53 return driverName; 54 } 55 } 56 return driverName; 57 } 58 59 public static String getDSClassName(String url){ 60 String dsClass = null; 61 Set urlKeys = dsClassMap.keySet(); 62 Iterator it = urlKeys.iterator(); 63 while(it.hasNext()){ 64 String urlPrefix = (String )it.next(); 65 if(url.startsWith(urlPrefix)){ 66 dsClass = (String )dsClassMap.get(urlPrefix); 67 return dsClass; 68 } 69 } 70 return dsClass; 71 } 72 73 74 79 public static String getUrlPrefix(String inClass){ 80 String prefix = null; 81 Set urlKeys = dsClassMap.keySet(); 82 Iterator it = urlKeys.iterator(); 83 while(it.hasNext()){ 84 String urlPrefix = (String )it.next(); 85 String dsClass = (String )dsClassMap.get(urlPrefix); 86 if(dsClass.equalsIgnoreCase(inClass)) 87 return urlPrefix; 88 } 89 return prefix; 90 } 91 92 static { 93 driverMap = new HashMap (); 94 95 driverMap.put("jdbc:db2:", "COM.ibm.db2.jdbc.net.DB2Driver"); 97 driverMap.put("jdbc:odbc:", "sun.jdbc.odbc.JdbcOdbcDriver"); 99 driverMap.put("jdbc:weblogic:mssqlserver4:", "weblogic.jdbc.mssqlserver4.Driver"); 101 102 driverMap.put("jdbc:oracle:thin:", "oracle.jdbc.driver.OracleDriver"); 104 driverMap.put("jdbc:oracle:oci8:", "oracle.jdbc.driver.OracleDriver"); 106 driverMap.put("jdbc:oracle:oci:", "oracle.jdbc.driver.OracleDriver"); 108 109 driverMap.put("jdbc:pointbase:", "com.pointbase.jdbc.jdbcUniversalDriver"); 111 driverMap.put("jdbc:cloudscape:", "COM.cloudscape.core.JDBCDriver"); 113 driverMap.put("jdbc:derby:", "org.apache.derby.jdbc.ClientDriver"); 115 driverMap.put("jdbc:firebirdsql:", "org.firebirdsql.jdbc.FBDriver"); 117 driverMap.put("jdbc:dbcp:", "COM.FirstSQL.Dbcp.DbcpDriver"); 119 driverMap.put("jdbc:dbcp:", "COM.FirstSQL.Dbcp.DbcpDriver"); 121 122 driverMap.put("jdbc:datadirect:db2:", "com.ddtek.jdbc.db2.DB2Driver"); 124 driverMap.put("jdbc:datadirect:informix:", "com.ddtek.jdbc.informix.InformixDriver"); 126 driverMap.put("jdbc:datadirect:oracle:", "com.ddtek.jdbc.oracle.OracleDriver"); 128 driverMap.put("jdbc:datadirect:sqlserver:", "com.ddtek.jdbc.sqlserver.SQLServerDriver"); 130 driverMap.put("jdbc:datadirect:sybase:", "com.ddtek.jdbc.sybase.SybaseDriver"); 132 133 driverMap.put("jdbc:ids:", "ids.sql.IDSDriver"); 135 driverMap.put("jdbc:informix-sqli:", "com.informix.jdbc.IfxDriver"); 137 driverMap.put("jdbc:idb:", "jdbc.idbDriver"); 139 driverMap.put("jdbc:idb:", "org.enhydra.instantdb.jdbc.idbDriver"); 141 driverMap.put("jdbc:interbase:", "interbase.interclient.Driver"); 143 driverMap.put("jdbc:hsqldb:hsql:", "org.hsqldb.jdbcDriver"); 145 driverMap.put("jdbc:hsqldb:http:", "org.hsqldb.jdbcDriver"); 147 driverMap.put("jdbc:HypersonicSQL:", "hSql.hDriver"); 149 driverMap.put("jdbc:HypersonicSQL:", "org.hsql.jdbcDriver"); 151 driverMap.put("jdbc:jtds:sqlserver:", "net.sourceforge.jtds.jdbc.Driver"); 153 driverMap.put("jdbc:jtds:sybase:", "net.sourceforge.jtds.jdbc.Driver"); 155 driverMap.put("jdbc:mckoi:", "com.mckoi.JDBCDriver"); 157 driverMap.put("jdbc:mckoi:local:", "com.mckoi.JDBCDriver"); 159 driverMap.put("jdbc:JTurbo:", "com.ashna.jturbo.driver.Driver"); 161 driverMap.put("jdbc:inetdae:", "com.inet.tds.TdsDriver"); 165 driverMap.put("jdbc:microsoft:sqlserver:", "com.microsoft.jdbc.sqlserver.SQLServerDriver"); 167 driverMap.put("jdbc:sqlserver:", "com.microsoft.sqlserver.jdbc.SQLServerDriver"); driverMap.put("jdbc:mysql:", "com.mysql.jdbc.Driver"); 170 driverMap.put("jdbc:mysql:", "org.gjt.mm.mysql.Driver"); 172 173 driverMap.put("jdbc:postgresql:", "org.postgresql.Driver"); 177 driverMap.put("jdbc:qed:", "com.quadcap.jdbc.JdbcDriver"); 179 driverMap.put("jdbc:sybase:Tds:", "com.sybase.jdbc2.jdbc.SybDriver"); 183 184 driverMap.put("jdbc:sun:sqlserver:", "com.sun.sql.jdbc.sqlserver.SQLServerDriver"); 187 driverMap.put("jdbc:sun:db2:", "com.sun.sql.jdbc.db2.DB2Driver"); 189 driverMap.put("jdbc:sun:oracle:", "com.sun.sql.jdbc.oracle.OracleDriver"); 191 driverMap.put("jdbc:sun:sybase:", "com.sun.sql.jdbc.sybase.SybaseDriver"); 193 194 } 195 196 static { 197 dsClassMap = new HashMap (); 198 199 dsClassMap.put("jdbc:db2:", "com.ibm.db2.jcc.DB2DataSource"); 201 dsClassMap.put("jdbc:odbc:", "sun.jdbc.odbc.JdbcOdbcDriver"); 203 206 dsClassMap.put("jdbc:oracle:thin:", "oracle.jdbc.pool.OracleDataSource"); 208 dsClassMap.put("jdbc:oracle:oci8:", "oracle.jdbc.pool.OracleDataSource"); 210 dsClassMap.put("jdbc:oracle:oci:", "oracle.jdbc.pool.OracleDataSource"); 212 213 dsClassMap.put("jdbc:pointbase:", "com.pointbase.jdbc.jdbcDataSource"); 215 dsClassMap.put("jdbc:cloudscape:", "com.cloudscape.core.BasicDataSource"); 217 dsClassMap.put("jdbc:derby:", "org.apache.derby.jdbc.ClientDataSource"); 219 226 dsClassMap.put("jdbc:datadirect:db2:", "com.ddtek.jdbcx.db2.DB2DataSource"); 228 dsClassMap.put("jdbc:datadirect:informix:", "com.ddtek.jdbcx.informix.InformixDataSource"); 230 dsClassMap.put("jdbc:datadirect:oracle:", "com.ddtek.jdbcx.oracle.OracleDataSource"); 232 dsClassMap.put("jdbc:datadirect:sqlserver:", "com.ddtek.jdbcx.sqlserver.SQLServerDataSource"); 234 dsClassMap.put("jdbc:datadirect:sybase:", "com.ddtek.jdbcx.sybase.SybaseDataSource"); 236 237 dsClassMap.put("jdbc:ids:", "ids.sql.IDSDriver"); 239 dsClassMap.put("jdbc:informix-sqli:", "com.informix.jdbcx.IfxDataSource"); 241 dsClassMap.put("jdbc:jtds:sqlserver:", "net.sourceforge.jtds.jdbcx.JtdsDataSource"); 257 dsClassMap.put("jdbc:jtds:sybase:", "net.sourceforge.jtds.jdbcx.JtdsDataSource"); 259 dsClassMap.put("jdbc:JTurbo:", "com.newatlanta.jturbo.driver.DataSource"); 267 dsClassMap.put("jdbc:inetdae:", "com.inet.tds.TdsDataSource"); 269 dsClassMap.put("jdbc:microsoft:sqlserver:", "com.microsoft.jdbc.sqlserver.SQLServerDataSource"); 271 dsClassMap.put("jdbc:sqlserver:", "com.microsoft.sqlserver.jdbc.SQLServerDataSource"); dsClassMap.put("jdbc:mysql:", "com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource"); 276 277 dsClassMap.put("jdbc:postgresql:", "org.postgresql.ds.PGSimpleDataSource"); 281 dsClassMap.put("jdbc:sybase:Tds:", "com.sybase.jdbc2.jdbc.SybDataSource"); 287 288 dsClassMap.put("jdbc:sun:sqlserver:", "com.sun.sql.jdbcx.sqlserver.SQLServerDataSource"); 291 dsClassMap.put("jdbc:sun:db2:", "com.sun.sql.jdbcx.db2.DB2DataSource"); 293 dsClassMap.put("jdbc:sun:oracle:", "com.sun.sql.jdbcx.oracle.OracleDataSource"); 295 dsClassMap.put("jdbc:sun:sybase:", "com.sun.sql.jdbcx.sybase.SybaseDataSource"); 297 298 } 299 } 300 | Popular Tags |