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)”; …
Category: Code . Programming Samples . প্রোগ্রাম উদাহরন
Code . Programming Samples . প্রোগ্রাম উদাহরন
Aug 06
extract relevant data from a DBResults
# QueryViewer.java An interactive database query viewer. Connects to the specified Oracle or Sybase database, executes a query, and presents the results in a JTable. Uses the following file: * DBResultsTableModel.java Simple class that tells a JTable how to extract relevant data from a DBResults object (which is used to store the results from …
Aug 05
EmployeeTest2.java: A test case for the database utilities. Prints results formatted as an HTML table.
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); …
Aug 05
DBResults.java: Class to store completed results of a JDBC Query. Differs from a ResultSet in several ways
# DBResults.java Class to store completed results of a JDBC Query. Differs from a ResultSet in several ways: * ResultSet doesn?t necessarily have all the data; reconnection to database occurs as you ask for later rows. * This class stores results as strings, in arrays. * This class includes DatabaseMetaData (database product …
Aug 04
DatabaseUtilities.java: Several general-purpose utilities discussed and used in the chapter.
package cwp; import java.sql.*; /** Three database utilities: * 1) getQueryResults. Connects to a database, executes * a query, retrieves all the rows as arrays * of strings, and puts them inside a DBResults * object. Also places the database product name, * database version, and the names of all the columns * into the …
Aug 04
EmployeeTest.java: A test case for the database utilities. Prints results in plain text.
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) …
Aug 03
Example Java Programs
HelloWorld.java public class HelloWorld { // method main(): ALWAYS the APPLICATION entry point public static void main (String[] args) { System.out.println (“Hello World!”); } } // Print Today’s Date import java.util.*; public class HelloDate { public static void main (String[] args) { System.out.println (“Hello, it’s: “); System.out.println(new Date()); …
Aug 03
FruitCreation.java: Creates a simple table named fruits in either an Oracle or a Sybase database.
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 < 5) { …
Aug 02
Example illustrating inheritance and abstract classes
illustrating inheritance এবং abstract classes এর উদাহরণ Shape.java সব, বদ্ধ খোলা, বাঁকা, এবং সোজা পার্শ্বে ধারবিশিষ্ট আকার এর জন্য প্যারেন্ট ক্লাস (সারাংশ)। Curve.java একটি (সারাংশ) বাঁকা আকার (খোলা বা বন্ধ)। StraightEdgedShape.java সরাসরি ধার সম্বলিত একটি আকৃতি (খোলা বা বন্ধ)। Measurable.java পরিমাপযোগ্য এলাকায় ইন্টারফেস ডিফাইনিং ক্লাস। Circle.java একটি বৃত্ত যা আকার প্রসারিত করে এবং পরিমাপ প্রয়োগ …
Aug 02
Some simple utilities for building Oracle and Sybase JDBC connections
এই সাধারণ উদ্দেশ্যে তৈরিকৃত কোড নয় – এটা আমাদের লোকাল সেটআপ এর ক্ষেত্রে প্রযোজ্য। 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 = …