home *** CD-ROM | disk | FTP | other *** search
/ Java 1.2 How-To / JavaHowTo.iso / 3rdParty / jbuilder / TRIAL / JBUILDER / JVISBRKR.Z / CreditApprovalDB.java < prev    next >
Encoding:
Java Source  |  1998-05-08  |  3.3 KB  |  87 lines

  1. /*
  2.  * Copyright (c) 1997-1998 Borland International, Inc. All Rights Reserved.
  3.  * 
  4.  * This SOURCE CODE FILE, which has been provided by Borland as part
  5.  * of a Borland product for use ONLY by licensed users of the product,
  6.  * includes CONFIDENTIAL and PROPRIETARY information of Borland.  
  7.  *
  8.  * USE OF THIS SOFTWARE IS GOVERNED BY THE TERMS AND CONDITIONS 
  9.  * OF THE LICENSE STATEMENT AND LIMITED WARRANTY FURNISHED WITH
  10.  * THE PRODUCT.
  11.  *
  12.  * IN PARTICULAR, YOU WILL INDEMNIFY AND HOLD BORLAND, ITS RELATED
  13.  * COMPANIES AND ITS SUPPLIERS, HARMLESS FROM AND AGAINST ANY CLAIMS
  14.  * OR LIABILITIES ARISING OUT OF THE USE, REPRODUCTION, OR DISTRIBUTION
  15.  * OF YOUR PROGRAMS, INCLUDING ANY CLAIMS OR LIABILITIES ARISING OUT OF
  16.  * OR RESULTING FROM THE USE, MODIFICATION, OR DISTRIBUTION OF PROGRAMS
  17.  * OR FILES CREATED FROM, BASED ON, AND/OR DERIVED FROM THIS SOURCE
  18.  * CODE FILE.
  19.  */
  20. //--------------------------------------------------------------------------------------------------
  21. // CORBA Reference Application
  22. // Copyright (c) 1997 by Borland International, All Rights Reserved
  23. //
  24. // Conatins DataModule responsible for issuing Credit Cards.
  25. //--------------------------------------------------------------------------------------------------
  26.  
  27. package borland.reference.creditapproval.server;
  28.  
  29. import borland.jbcl.dataset.*;
  30. public class CreditCardDB implements DataModule{
  31.   private static CreditCardDB myDM;
  32.   Database CreditCardDB;// = new Database();
  33.  
  34.   public CreditCardDB() {
  35.     try {
  36.       jbInit();
  37.     }
  38.     catch (Exception e) {
  39.       e.printStackTrace();
  40.     }
  41.   }
  42.  
  43.   private void jbInit() throws Exception{
  44.  
  45.     long nextNumber;
  46.     java.sql.Driver icDriver = new borland.interclient.Driver();
  47.     java.sql.Connection TracedConnection;
  48.     java.util.Properties properties = new java.util.Properties();
  49.     properties.put ("user", "SYSDBA");
  50.     properties.put ("password", "masterkey" );
  51.  
  52.     // Turn on all of the trace options
  53.     ((borland.interclient.Driver)icDriver).getMonitor().setTraceStream(System.out);
  54.     ((borland.interclient.Driver)icDriver).getMonitor().enableAllTraces(true);
  55.  
  56.     TracedConnection = icDriver.connect("jdbc:interbase://localhost/C:/CorbaReferenceApplication/DB/Cliffhanger Credit Card.gdb", properties );
  57.     CreditCardDB = new Database( TracedConnection );
  58.  
  59.     // Turn off autoCommit!
  60.     CreditCardDB.setAutoCommit( false );
  61.  
  62.     //CreditCardDB.setConnection(new borland.jbcl.dataset.ConnectionDescriptor("jdbc:interbase://localhost/C:/CorbaReferenceApplication/DB/Cliffhanger Credit Card.gdb", "SYSDBA", "masterkey", false, "borland.interclient.Driver"));
  63.     CreditCardDB.setSQLDialect(borland.jbcl.dataset.SQLDialect.INTERBASE);
  64.     //CreditCardDB.openConnection();
  65.     java.sql.Statement statement = CreditCardDB.createStatement() ;
  66.     statement.executeUpdate("UPDATE CARD_NUMBER SET NUMBER = NUMBER + 1");
  67.     java.sql.ResultSet results = statement.executeQuery("SELECT CARD_NUMBER.NUMBER FROM CARD_NUMBER");
  68.  
  69.     // Move to first row in the result set!
  70.     results.next();
  71.     nextNumber = results.getLong("NUMBER");
  72.     CreditCardDB.commit();
  73.     System.out.println( "Number Returned is: " + nextNumber);
  74.  
  75.   }
  76.  
  77.   static public CreditCardDB getDataModule() {
  78.     if (myDM == null)
  79.       myDM = new CreditCardDB();
  80.     return myDM;
  81.   }
  82.   public void IssueCreditCard() {
  83.   }
  84.  
  85.  
  86. }
  87.