{"id":26824,"date":"2021-05-02T23:10:06","date_gmt":"2021-05-03T03:10:06","guid":{"rendered":"http:\/\/bangla.salearningschool.com\/recent-posts\/some-simple-utilities-for-building-oracle-and-sybase-jdbc-connections-programming-code-examples-java-j2ee-j2me-jdbc\/"},"modified":"2021-05-02T23:10:06","modified_gmt":"2021-05-03T03:10:06","slug":"some-simple-utilities-for-building-oracle-and-sybase-jdbc-connections-programming-code-examples-java-j2ee-j2me-jdbc","status":"publish","type":"post","link":"http:\/\/bangla.sitestree.com\/?p=26824","title":{"rendered":"Some simple utilities for building Oracle and Sybase JDBC connections #Programming Code Examples #Java\/J2EE\/J2ME #JDBC"},"content":{"rendered":"<pre>\nDriverUtilities.java  Some simple utilities for building Oracle and Sybase JDBC connections. \nThis is not general-purpose code -- it is specific to our local setup.\n\npackage cwp;\n\n\/** Some simple utilities for building Oracle and Sybase\n *  JDBC connections. This is <i>not<\/i> general-purpose\n *  code -- it is specific to my local setup.\n *\/\n\npublic class DriverUtilities {\n  public static final int ORACLE = 1;\n  public static final int SYBASE = 2;\n  public static final int UNKNOWN = -1;\n\n  \/** Build a URL in the format needed by the\n   *  Oracle and Sybase drivers I am using.\n   *\/\n  \n  public static String makeURL(String host, String dbName,\n                               int vendor) {\n    if (vendor == ORACLE) {\n      return(&quot;jdbc:oracle:thin:@&quot; + host + &quot;:1521:&quot; + dbName);\n    } else if (vendor == SYBASE) {\n      return(&quot;jdbc:sybase:Tds:&quot; + host  + &quot;:1521&quot; +\n             &quot;?SERVICENAME=&quot; + dbName);\n    } else {\n      return(null);\n    }\n  }\n\n  \/** Get the fully qualified name of a driver. *\/\n  \n  public static String getDriver(int vendor) {\n    if (vendor == ORACLE) {\n      return(&quot;oracle.jdbc.driver.OracleDriver&quot;);\n    } else if (vendor == SYBASE) {\n      return(&quot;com.sybase.jdbc.SybDriver&quot;);\n    } else {\n      return(null);\n    }\n  }\n\n  \/** Map name to int value. *\/\n\n  public static int getVendor(String vendorName) {\n    if (vendorName.equalsIgnoreCase(&quot;oracle&quot;)) {\n      return(ORACLE);\n    } else if (vendorName.equalsIgnoreCase(&quot;sybase&quot;)) {\n      return(SYBASE);\n    } else {\n      return(UNKNOWN);\n    }\n  }\n}\n<\/pre>\n<p>Note: Brought from our old site: http:\/\/www.salearningschool.com\/example_codes\/ on Jan 2nd, 2017 From: http:\/\/sitestree.com\/?p=10201<br \/> Categories:Programming Code Examples, Java\/J2EE\/J2ME, JDBC<br \/>Tags:Java\/J2EE\/J2MEJDBC<br \/> Post Data:2017-01-02 16:04:23<\/p>\n<p>\t\tShop Online: <a href='https:\/\/www.ShopForSoul.com\/' target='new' rel=\"noopener\">https:\/\/www.ShopForSoul.com\/<\/a><br \/>\n\t\t(Big Data, Cloud, Security, Machine Learning): Courses: <a href='http:\/\/Training.SitesTree.com' target='new' rel=\"noopener\"> http:\/\/Training.SitesTree.com<\/a><br \/>\n\t\tIn Bengali: <a href='http:\/\/Bangla.SaLearningSchool.com' target='new' rel=\"noopener\">http:\/\/Bangla.SaLearningSchool.com<\/a><br \/>\n\t\t<a href='http:\/\/SitesTree.com' target='new' rel=\"noopener\">http:\/\/SitesTree.com<\/a><br \/>\n\t\t8112223 Canada Inc.\/JustEtc: <a href='http:\/\/JustEtc.net' target='new' rel=\"noopener\">http:\/\/JustEtc.net (Software\/Web\/Mobile\/Big-Data\/Machine Learning) <\/a><br \/>\n\t\tShop Online: <a href='https:\/\/www.ShopForSoul.com'> https:\/\/www.ShopForSoul.com\/<\/a><br \/>\n\t\tMedium: <a href='https:\/\/medium.com\/@SayedAhmedCanada' target='new' rel=\"noopener\"> https:\/\/medium.com\/@SayedAhmedCanada <\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>DriverUtilities.java Some simple utilities for building Oracle and Sybase JDBC connections. This is not general-purpose code &#8212; 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 &#8212; it is specific to my local setup. *\/ public class &hellip; <\/p>\n<p><a class=\"more-link btn\" href=\"http:\/\/bangla.sitestree.com\/?p=26824\">Continue reading<\/a><\/p>\n","protected":false},"author":8,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1917],"tags":[],"class_list":["post-26824","post","type-post","status-publish","format-standard","hentry","category-fromsitestree-com","item-wrap"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":10108,"url":"http:\/\/bangla.sitestree.com\/?p=10108","url_meta":{"origin":26824,"position":0},"title":"Some simple utilities for building Oracle and Sybase JDBC connections","author":"","date":"August 2, 2015","format":false,"excerpt":"\u098f\u0987 \u09b8\u09be\u09a7\u09be\u09b0\u09a3 \u0989\u09a6\u09cd\u09a6\u09c7\u09b6\u09cd\u09af\u09c7 \u09a4\u09c8\u09b0\u09bf\u0995\u09c3\u09a4\u00a0\u0995\u09cb\u09a1 \u09a8\u09df - \u098f\u099f\u09be \u0986\u09ae\u09be\u09a6\u09c7\u09b0 \u09b2\u09cb\u0995\u09be\u09b2 \u09b8\u09c7\u099f\u0986\u09aa \u098f\u09b0 \u0995\u09cd\u09b7\u09c7\u09a4\u09cd\u09b0\u09c7 \u09aa\u09cd\u09b0\u09af\u09cb\u099c\u09cd\u09af\u0964 \u00a0 \u00a0 package cwp; \/** Some simple utilities for building Oracle and Sybase \u00a0*\u00a0 JDBC connections. This is not general-purpose \u00a0*\u00a0 code -- it is specific to my local setup. \u00a0*\/ public class DriverUtilities { \u00a0 public\u2026","rel":"","context":"In &quot;Code . Programming Samples . \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae \u0989\u09a6\u09be\u09b9\u09b0\u09a8&quot;","block_context":{"text":"Code . Programming Samples . \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae \u0989\u09a6\u09be\u09b9\u09b0\u09a8","link":"http:\/\/bangla.sitestree.com\/?cat=1417"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":26826,"url":"http:\/\/bangla.sitestree.com\/?p=26826","url_meta":{"origin":26824,"position":1},"title":"FruitCreation.java:  Creates a simple table named fruits in either an Oracle or a Sybase database. #Programming Code Examples #Java\/J2EE\/J2ME #JDBC","author":"Author-Check- Article-or-Video","date":"May 2, 2021","format":false,"excerpt":"FruitCreation.java Creates a simple table named fruits in either an Oracle or a Sybase database. ************************************** package cwp; import java.sql.*; \/** Creates a simple table named \"fruits\" in either * an Oracle or a Sybase database. * *\/ public class FruitCreation { public static void main(String[] args) { if (args.length\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":26844,"url":"http:\/\/bangla.sitestree.com\/?p=26844","url_meta":{"origin":26824,"position":2},"title":"EmployeeTest.java:  A test case for the database utilities. Prints results in plain text. #Programming Code Examples #Java\/J2EE\/J2ME #JDBC","author":"Author-Check- Article-or-Video","date":"May 3, 2021","format":false,"excerpt":"package cwp; import java.sql.*; \/** Connect to Oracle or Sybase and print \"employees\" table. * *\/ public class EmployeeTest { public static void main(String[] args) { if (args.length < 5) { printUsage(); return; } String vendorName = args[4]; int vendor = DriverUtilities.getVendor(vendorName); if (vendor == DriverUtilities.UNKNOWN) { printUsage(); return; }\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":26846,"url":"http:\/\/bangla.sitestree.com\/?p=26846","url_meta":{"origin":26824,"position":3},"title":"EmployeeTest2.java:  A test case for the database utilities. Prints results formatted as an HTML table. #Programming Code Examples #Java\/J2EE\/J2ME #JDBC","author":"Author-Check- Article-or-Video","date":"May 3, 2021","format":false,"excerpt":"package cwp; import java.sql.*; \/** Connect to Oracle or Sybase and print \"employees\" table * as an HTML table. * *\/ public class EmployeeTest2 { public static void main(String[] args) { if (args.length < 5) { printUsage(); return; } String vendorName = args[4]; int vendor = DriverUtilities.getVendor(vendorName); if (vendor ==\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":26848,"url":"http:\/\/bangla.sitestree.com\/?p=26848","url_meta":{"origin":26824,"position":4},"title":"EmployeeCreation.java:  Make a simple &quot;employees&quot; table using the database utilities #Programming Code Examples #Java\/J2EE\/J2ME #JDBC","author":"Author-Check- Article-or-Video","date":"May 3, 2021","format":false,"excerpt":"package cwp; import java.sql.*; \/** Make a simple \"employees\" table using DatabaseUtilities. *\/ public class EmployeeCreation { public static Connection createEmployees(String driver, String url, String username, String password, boolean close) { String format = \"(id int, firstname varchar(32), lastname varchar(32), \" + \"language varchar(16), salary float)\"; String[] employees = {\"(1,\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":26822,"url":"http:\/\/bangla.sitestree.com\/?p=26822","url_meta":{"origin":26824,"position":5},"title":"FruitTest.java:  A class that connects to either an Oracle or a Sybase database and prints out the values of predetermined columns in the &quot;fruits&quot; table. #Programming Code Examples #Java\/J2EE\/J2ME #JDBC","author":"Author-Check- Article-or-Video","date":"May 2, 2021","format":false,"excerpt":"# FruitTest.java A class that connects to either an Oracle or a Sybase database and prints out the values of predetermined columns in the \"fruits\" table. package cwp; import java.sql.*; \/** A JDBC example that connects to either an Oracle or * a Sybase database and prints out the values\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/26824","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=26824"}],"version-history":[{"count":0,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/26824\/revisions"}],"wp:attachment":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=26824"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=26824"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=26824"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}