এই সাধারণ উদ্দেশ্যে তৈরিকৃত কোড নয় – এটা আমাদের লোকাল সেটআপ এর ক্ষেত্রে প্রযোজ্য।
package cwp;
/** Some simple utilities for building Oracle and Sybase
* JDBC connections. This is not general-purpose
* code -- it is specific to my local setup.
*/
public class DriverUtilities {
public static final int ORACLE = 1;
public static final int SYBASE = 2;
public static final int UNKNOWN = -1;
/** Build a URL in the format needed by the
* Oracle and Sybase drivers I am using.
*/
public static String makeURL(String host, String dbName,
int vendor) {
if (vendor == ORACLE) {
return("jdbc:oracle:thin:@" + host + ":1521:" + dbName);
} else if (vendor == SYBASE) {
return("jdbc:sybase:Tds:" + host + ":1521" +
"?SERVICENAME=" + dbName);
} else {
return(null);
}
}
/** Get the fully qualified name of a driver. */
public static String getDriver(int vendor) {
if (vendor == ORACLE) {
return("oracle.jdbc.driver.OracleDriver");
} else if (vendor == SYBASE) {
return("com.sybase.jdbc.SybDriver");
} else {
return(null);
}
}
/** Map name to int value. */
public static int getVendor(String vendorName) {
if (vendorName.equalsIgnoreCase("oracle")) {
return(ORACLE);
} else if (vendorName.equalsIgnoreCase("sybase")) {
return(SYBASE);
} else {
return(UNKNOWN);
}
}
}
