DriverUtilities.java Some simple utilities for building Oracle and Sybase JDBC connections.
This is not general-purpose code -- it is specific to our local setup.
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);
}
}
}
Note: Brought from our old site: http://www.salearningschool.com/example_codes/ on Jan 2nd, 2017 From: http://sitestree.com/?p=10201
Categories:Programming Code Examples, Java/J2EE/J2ME, JDBC
Tags:Java/J2EE/J2MEJDBC
Post Data:2017-01-02 16:04:23
Shop Online: https://www.ShopForSoul.com/
(Big Data, Cloud, Security, Machine Learning): Courses: http://Training.SitesTree.com
In Bengali: http://Bangla.SaLearningSchool.com
http://SitesTree.com
8112223 Canada Inc./JustEtc: http://JustEtc.net (Software/Web/Mobile/Big-Data/Machine Learning)
Shop Online: https://www.ShopForSoul.com/
Medium: https://medium.com/@SayedAhmedCanada
