Java Derby - Usage of seg0 .dat files

Hello,
I created a remote application and stored my data in the Java Derby DB. For testing I did frequently copy the db directory to my local PC, changed a few things and copied the data back to the server.
Unfortunalety I did not always delete the directory before pasting the copied files.
I assume that some .dat files are not used anymore by the database and are only there due to my copy process.
Can you please point me to a description how to find which .dat files are used in Java Derby?
Best regards, Lars

well,
according to the 3.0 spec
"21.1.2. Programming restrictions
The file system APIs are not well-suited for business components to access data. Business components should use a resource manager API such as JDBC to store data."
as an alternative you can delegate the writing process another component that could be for example a socket server.
regards,
Fabian

Similar Messages

  • Java Derby. How my data are saved?

    Hello,
    I am following this tutorial : [http://netbeans.org/kb/docs/java/gui-db.html] .
    I want to create an apllication in Java, using as database Java DB (Derby).
    Does someone know how the data are saved? I need this apllication for a customer, and i woud like if data could be saved in a single file, pretty much like access do.
    Secondly, does anyone know if there is an easy way to start Derby?
    And, last but not least, following the tutorial mentioned above, i can't use NEW button to create a new record in my database. I can modify a record that is already saved in my database, but i can't create a new one.
    Anyone that has an answer at any of my questions please feel free to instruct me.

    >My data are not gettitng enterted in the data
    base
    no real surprise to me.Can u please help me ??How? There's no connection and prepared staments anywhere in your code. Do you think the database will update itself automagically?

  • I would like to programatically enable Java Plugin in Firefox 19. I do not want to use pluginreg.dat file in Appdata Folder

    I have a need to enable Java Plug-in 6U20 6.0.200.2 in Firefix 19. This version of Java is disabled by Firefox by default since it has few security issues. But still i need that to be enabled. Do we have a method to do it. I do not want to use %Application Data%\Mozilla\Firefox\Profiles\<Random Profile Name>\pluginreg.dat file as this is created under a random profile. Thanks in advance for any help.

    Hi David, Thanks for the quick reply. But i have already gone through the solution that you provided. My requirement here is to automate this. User machines are already installed with the Java 6 U20 which they need it anyway. When i install Firefox, this Plug in should be enabled to the users. I need to use some script / commands to make this happen.

  • Java.sql.SQLException: ORA-01157: cannot identify/lock data file 7 - see DB

    I am deploying my application components on Oracle RAC database, when i install my app component i will run a script which creates a user and tablespace on bot rac-nodes(node1 and node2)
    as database is clustered, the user are created on 2 nodes and tablespace is stored in a shared location for two rac nodes
    i am able to successfully run my script on rac-node1 and and installed my component and when i started installing the app component on node2 getting error
    java.sql.SQLException: ORA-01157: cannot identify/lock data file 7 - see DBWR trace file
    ORA-01110: data file 7: '/db/db/db/ora10g/10.2.0/admin/dbadmin_01.dbf'
    ORA-06512: at "ADMIN.XL_SP_DBCHECK", line 48
    ORA-06512: at line 1
    "dbadmin_01.dbf is the custom tablespace which created by me"
    i a mgetting error while installing the app component on rac-node2

    You should not create database files outside of the ASM.
    I'm not sure you can move the datafile, I would export the data from the tablespace (if there is data you need there), delete the tablespace and recreate it in the ASM, then import the data back.
    If you want to move the datafile, you can try using RMAN (from node1).
    First connect to the database with sqlplus and execute:
    alter tablespace <tbs_name> offline;Then start RMAN: rman target /
    BACKUP AS COPY DATAFILE '<file>' FORMAT '+<ASM_DG>';Then in sqlplus, execute:
    alter tablespace <tbs_name> online;I'm not sure it will work, and I hope I got the commands right because I can't check it right now.
    Good luck
    Liron Amitzi
    Senior DBA consultant
    [www.dbsnaps.com]
    [www.orbiumsoftware.com]

  • Java.sql.SQLException: ORA-01157: cannot identify/lock data file : PLz Help

    My datafiles are in ASM file system, however the only one file ACIPEN_DATA is the one, which is not in ASM file system, and this the file which is in concern.
    We are getting the following exception in the lxkratgas1.lex1.lexmark.com when connecting to ACIPEN_DATA.
    This exception is coming up sometimes and the sometimes the file is getting processed successfully
    Caused by: java.sql.SQLException: ORA-01157: cannot identify/lock data file 9 - see DBWR trace file
    ORA-01110: data file 9: '/oracle/SE/product/10.2.0/db_1/dbs/ACIPEN_DATA'
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
    at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
    at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
    at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:743)
    at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:216)
    at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:955)
    at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1169)
    at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3285)
    at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:3368)
    at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.executeUpdate(WrappedPreparedStatement.java:278)
    at atg.adapter.gsa.SQLStatement.executeUpdate(SQLStatement.java:725)
    at atg.adapter.gsa.Table.insert(Table.java:1378)
    at atg.adapter.gsa.GSAItemDescriptor.addItem(GSAItemDescriptor.java:6272)
    ... 61 more
    ====================================================================
    We have checked the datafile, it is absolutely online.
    Can some expert jump in and resolve this issue Please.

    01157, 00000, "cannot identify/lock data file %s - see DBWR trace file"
    // *Cause:  The background process was either unable to find one of the data
    //         files or failed to lock it because the file was already in use.
    //         The database will prohibit access to this file but other files will
    //         be unaffected. However the first instance to open the database will
    //         need to access all online data files. Accompanying error from the
    //         operating system describes why the file could not be identified.
    // *Action: Have operating system make file available to database. Then either
    //         open the database or do ALTER SYSTEM CHECK DATAFILES.is this a RAC database?

  • SQL Server 2008 R2 Disk Usage report showing incorrect data file

    When I go to ANY database (System, AdventureWorks*, user) in Managemant Studio, I right-click on the db, select Reports, select Standard Reports, and select Disk Usage.  The disk usage report shows the correct db on top, but always only shows AdventureWorks_Data.mdf
    when I expand Disk Space Used by Data Files section.  This happens to any db I try.  When I look at Database Properties/Files for that database, the logical and physical file names are correct.
    Since the correct files appear in Database Properties/Files, I'm hoping it's just a bug in the report.  Same thing happens if I run a Disk Usage by Table report for ANY database,  The tables for AdventureWorks always only appear,
    Thanks,  Mike

    Thanks Tibor!
    I looked at the Properties for my login under Security/Logins and it shows my default db to be master.  Not sure if this is correct, but it sounds plausible.  I'll see if I can report the problem.
    The only issue I can think of that was out of the ordinary for the install of 2008 R2 EE was this:
    I originally installed 2005 DE, since it wouldn't expire.  After the install of 2005 DE, I decided to uninstall it and install 2008 R2 EE.  In between the installs of 2005 DE and 2008 R2 EE, I installed/uninstalled stupid stuff like 2008
    Express, 2008 Express with Advanced Services (?), and 2008 EE.  After each uninstall I also did a system restore to be safe.
    Now each time I open Management Studio, i get a pop-up stating that there are SQL Server 2005 registered servers on my sytem and asks me if I want to add them into Management Studio.  I always say no.
    The AdventureWorks db is from 2005 and was installed automatically with 2005.  I installed the 2005, 2008, and 2008 R2 AdventureWorks databases to my R2 for class.  I'm not sure now if the Disk Usage report is showing me AdventureWorks_Data.mdf
    because of my install into 2008 R2 EE or my previous install of 2005 DE.
    Hope this kind of makes sense...
    -Mike

  • XML data file links java and sap

    Hi ,
    Please help me this
    How to connect xml file to java into sap
    please send me sample scenario.
    in java i call the this sap function module  'BAPI_MAT_BOM_EXISTENCE_CHECK'.
    1. Check BOM existence with BAPI_MAT_BOM_EXISTENCE_CHECK
    2. Exit BOM diff if BOM doesn’t exist
    3. Read BOM structure with CSAP_MAT_BOM_READ
    4. Compare SAP BOM items incl. subitems to XML BOM items and subitems

    currently I use following methods tu opload and to transfor the xml into a string.
    * Method to create XML from data file
      CALL METHOD instance->import_from_file
        EXPORTING
          filename = gf_filename
        RECEIVING
          retcode  = ch_retcode.
    * Convert into XML-Stream
      CALL METHOD instance->render_2_string
    *  EXPORTING
    *    pretty_print = 'X'
        IMPORTING
        retcode      = ch_retcode
          stream       = lf_string .
    *    size         = .
    When I use read dataset the output of the xml is into an internal table where I have many lines depending on the XML data file, this means if my xml has 10lines the internal table of read dataset has also 10 lines but I need a string to make the transformation of the xml.

  • Opening a binary data file with a local java application from a weblink...

    I don't know if this is the right forum for my query, but I would like to be able to click on a data file from a download link on a webpage and be able to have the file "open" into the java application that processes the particular file (as opposed to selecting the "save to disk" option or having the browser display a bunch of funky characters). If the application is not already running, have an instance start up and process the data file and display the information. What steps would I need to take to get this to happen? The application is executed in a windows environment through executing a .bat file and not an executable .jar file. Any thoughts? TIA!

    This is entirely a matter of configuring the Windows file associations so that files with that extension are started using your designated process. Depending on the particulars you may be able to establish the association from the context (right-click) menu, or you may need to use Folder Options rom the Control Panel.
    In any case, this is a not a Java question, but Windows; if further help is needed you should go to a Windows help site.

  • Data file produced by Java application

    A application developed with pure Java should work on any platform with Java VM. But what about the data file produced by such application? For example: if i developed an application with pure java on PC(windows), then i ran the application and the application produced some data files on PC. Then if i copy both the application and the data files to other platforms (sun work-station, Apple, IBM mainframe, Vax 11, ...), will the application be able to continue load these data files? Is there any difference between java.io 'character stream' and 'byte stream' in terms of data file transfer among different platforms?
    Thanks for your consideration.

    generally speaking text data files can be used on different systems, but it would depend on the encoding used.
    if data portability is a big concern for you then the solution does already exist, it is XML.

  • Cgicmd.dat file usage

    Hi,
    I am generating my reports using the cgicmd.dat file in pdf format and my application is in web-based html.
    I have a report which passes 4 paramters and 2 of it is considered imortant (and dynamic according to user interaction in the begining) and should not be changed by the users. I have found out that by using the parameter forms like %P, %PT and %PC entry in the cgicmd.dat file would means that I cannot use other user parameters in the file entry, and so also in the reverse situation.
    But when I tried to put both of them (%P and %1..%4 for user parameters) together, then call up the reports with the parameter values included in the entry (like http://server/repserver/?repname+value1+v2+v3+v4), I seems to be able to pass the important values to the displayed parameter form while hiding them and asking the users to enter only the other 2 parameters which they may change.
    But then, when I submit the form, it gave me an error:
    ======================================================
    Error: The requested URL was not found, or cannot be served at this time.
    Oracle Reports Server CGI - Error occurred while parsing the Reports Server command line.
    ======================================================
    May anyone assist me on how I can make use of the parameter form and also passing in some values that are dynamic and cannot be changed by the users?
    Thank you in advance for your assistance!

    FYI...
    Our dev and prod are at the same levels. I was able to narrow the problem down further, however. It appears to be a row size problem. If I force a rownum < 1500 in my report's query, then it works fine on dev and prod. If I force a rownum < 2000, then it crashes the engine on prod. The reason it works on dev and not on prod is that the amount of data on dev is far less than prod. Also, I ran the report locally on my PC against the prod database and it gave me a little more info. The report appears to query all of the rows fine, but it gets an ArrayIndexOutOfBounds exception. Since the report comes back with all rows just fine using a DESFORMAT other than DELIMITED, I believe it's a bug with applying the delimiter when formatting the report. The admins say that we are a few patchsets behind, so I'm guessing it is a fixed bug already.
    Thanks.

  • How to parse ".dat" file using java?

    Hi experts/friends,
    I need to parse the ".dat" files such as "history.dat" of Firefox history and "index.dat" of IE history...
    I cannot able to parse those files.
    Can anyone suggest me or help me....

    Google ( [url http://www.google.com/search?q=firefox+history+file+format]firefox history file format )
    Google ( [url http://www.google.com/search?q=internet+explorer+history+file+format]internet explorer history file format )

  • Best way for Java/C++/C# to share data in a cache?

    I have an order processing application which listens for Order objects to be inserted in a cache. If I want Java, C# and C++ apps to be able to submit orders to that cache, what's the best way to set up that Order object? Orders currently have many Enum member variables. What happens when a C# or C++ app needs to put an Order object in the cache? how would it set those java enums? Also, the java Enum classes have a lot of Java specific code in 'em for convenience. I imagine for cross platform simplicity it might have been best if the Order object were just an array of Strings or a Map of Strings to values but I have too much code depending on the Order object being how it is currently. Should I extract an Order Interface? What about the Enums? My java enums aren't simple {RED,GREEN,BLUE} type enums, they contain references to other Enums, etc. - see below...
    A portion of my Order class looks like:
    public class Order implements Cloneable, Comparable, java.io.Serializable {
      private static Logger logger = Logger.getLogger(Order.class);
      private boolean clearedFromOpenOrdersTable = false; 
      private boolean trading_opened = false;
      private static Random generator = new Random();
      private static int nextID = generator.nextInt(1000000); //just for testing
      private int quantity = 0;
      private int open = 0;
      private int executed = 0;
      private int last = 0;
      private int cancelPriority = 0;
      private Integer sendPriority = 0;
    //enums
      private OrderSide side = OrderSide.BUY;
      private OrderType orderType = OrderType.MARKET;
      private OrderTIF tif = OrderTIF.DAY;
      private OrderStatus orderStatus = OrderStatus.PENDING_NEW;
      private OrderExchange orderExchange = null;
      private OOType ooType = OOType.NOTOO;
      private OOLevel ooLevel = OOLevel.NONE;
      private Float limit = new Float(0);
      private Float stop = null;
      private float avgPx = 0.0f;
      private float lastPx = 0.0f;
      private String account = null;
      private String symbol = null;
      private long submitTimestamp;
      private long fillTime = 0;
      private long ackTime = 0;
      private Timestamp submitSqlTimestamp;
      public /*final*/ static NamedCache cache;
      private ArrayList<OrderStatusChangeListener> statusChangeListeners =
        new ArrayList<OrderStatusChangeListener>();
      transient private Format formatter = new SimpleDateFormat("hh:mm:ss a");
      public static void connectToCache() {
        cache = CacheFactory.getCache("orders");
      public void send() {
        this.submitTimestamp = System.currentTimeMillis() ;
        this.submitSqlTimestamp = new Timestamp(submitTimestamp);
        cache.put(this.ID, this);
      public void setCancelCount(int i) {
        cancelCount = i;
      public int getCancelCount() {
        return cancelCount;
      public static class CancelProcessor extends AbstractProcessor {
        public Object process(InvocableMap.Entry entry) {
          Order o = (Order)entry.getValue();
          if (o.cancelCount == 0) {
            o.cancelCount = 1;
          } else {
            logger.info("ignoring dup. cancel req on " + o.symbol + " id=" + o.ID);
          return o.cancelCount;
      public void cancel() {
          // cache.invoke(this.ID, new CancelProcessor() ); // must this be a 'new' one each time?
          Filter f = new EqualsFilter("getCancelCount", 0);
          UpdaterProcessor up = new UpdaterProcessor("setCancelCount",new Integer(1) );
          ConditionalProcessor cp = new ConditionalProcessor(f, up);
          cache.invoke(ID, cp);
      NumberIncrementor ni1 = new NumberIncrementor("CancelCount", 1, false);
      public void cancelAllowingMultipleCancelsOfThisOrder() {
        System.out.println("cancelAllowingMultipleCancelsOfThisOrder symbol=" + symbol + " id=" + ID);
        cache.invoke(this.getID(), ni1);
      public Timestamp getSubmitSqlTimestamp(){
        return submitSqlTimestamp;
      boolean isWorking( ) {
           // might need to write an extractor to get this from the cache atomically
           if (orderStatus != null &&
                (orderStatus == OrderStatus.NEW || orderStatus == OrderStatus.PARTIALLY_FILLED ||
                    // including PENDING_CANCEL breaks order totals from arcadirect
                    // because they send a pending cancel unlike foc
                    // os.getValue() == OrdStatus.PENDING_CANCEL ||
                    orderStatus == OrderStatus.PENDING_NEW ||
                    orderStatus == OrderStatus.PENDING_REPLACE)) {
              return true;
            } else {
              return false;
      public long getSubmitTimestamp(){
        return submitTimestamp;
      private void fireStatusChange( ) {
              for (OrderStatusChangeListener x:statusChangeListeners) {
                    try {
                         x.dispatchOrderStatusChange(this );
                    } catch (java.util.ConcurrentModificationException e) {
                         logger.error("** fireStatusChange: ConcurrentModificationException "+e.getMessage());
                         logger.error(e.getStackTrace());
                         e.printStackTrace();
      public Order() {
          ID = generateID();
          originalID = ID;
      public Object clone() {
          try {
            Order order = (Order)super.clone();
            order.setOriginalID(getID());
            order.setID(order.generateID());
            return order;
          } catch (CloneNotSupportedException e) {
          return null;
        class ReplaceProcessor extends AbstractProcessor {
          // this is executed on the node that owns the data,
          // no network access required
          public Object process(InvocableMap.Entry entry) {
            Order o = (Order)entry.getValue();
            int counter=0;
            float limit=0f;
            float stop=0f;
            int qty=o.quantity;
            boolean limitChanged=false, qtyChanged=false, stopChanged=false;
            for (Replace r:o.replaceList) {
              if (r.pending) {
                counter++;
                if (r.limit!=null) {limit=r.limit; limitChanged=true;}
                if (r.qty!=null) {qty=r.qty; qtyChanged=true;}
                if (r.stop!=null) {stop=r.stop; stopChanged=true;}
            if (limitChanged) o.limit=limit;
            if (qtyChanged) o.quantity=qty;
            if (stopChanged) o.stop=stop;
            if (limitChanged || qtyChanged || stopChanged)
            entry.setValue(o);
            return counter;
      public void applyPendingReplaces() {
         cache.invoke(this.ID, new ReplaceProcessor());
      private List <Replace>replaceList;
      public boolean isReplacePending() {
        if (replaceList==null) return false; 
        for (Replace r:replaceList) {
          if (r.pending==true) return true;
        return false;
      class ReplaceAddProcessor extends AbstractProcessor {
        // this is executed on the node that owns the data,
        // no network access required
        Replace r;
        public ReplaceAddProcessor(Replace r){
          this.r=r;
        public Object process(InvocableMap.Entry entry) {
          Order o = (Order)entry.getValue();
          if (o.replaceList==null) o.replaceList = new LinkedList();
          o.replaceList.add(r);
          return replaceList.size();
      public void replaceOrder(Replace r) {
          //  Order.cache.invoke(this.ID, new ReplaceAddProcessor(r));
          Order o = (Order)Order.cache.get(this.ID);
          if (o.replaceList==null) o.replaceList = new LinkedList();
          o.replaceList.add(r);
          Order.cache.put(this.ID, o);
      public boolean isCancelRequestedOrIsCanceled() {
        // change to cancelrequested lock, not ack lock
        if (canceled) return true;
    //  ValueExtractor extractor = new ReflectionExtractor("getCancelCount");
    //  int cc = (Integer)cache.invoke( this.ID , extractor );
        Order o = (Order)cache.get(this.ID);
        int cc = o.getCancelCount();
        return cc > 0 || o.isCanceled();
        class Replace implements Serializable{
        boolean pending=true;
        public Float limit=null;
        public Float stop=null;
        public Integer qty=null;
        public Replace() {
      }and then a portion of my OrderExchange.java Enum looks like this:
    class SymbolPair implements java.io.Serializable {
      String symbol;
      String suffix;
      SymbolPair(String symbol, String suffix) {
        this.symbol = symbol;
        this.suffix = suffix;
      public boolean equals(Object o) {
        SymbolPair x = (SymbolPair)o;
        return (this.symbol == x.symbol && this.suffix == x.suffix);
      public int hashCode() {
        return (symbol + "." + suffix).hashCode();
      public String toString() {
        if (suffix == null)
          return symbol;
        return symbol + "." + suffix;
    public enum OrderExchange implements java.io.Serializable {
      SIM("S", false, '.', OrderTIF.DAY) {
        public String getStandardizedStockSymbol(String symbol, String suffix) {
          return symbol + "." + suffix;
        public SymbolPair getExchangeSpecificStockSymbol(String symbol) {
          return new SymbolPair(symbol, null);
      TSX("c", false, '.', OrderTIF.DAY) {
        public String getStandardizedStockSymbol(String symbol, String suffix) {
          String x = externalSymbolPairToInternalSymbolMap_GS.get(new SymbolPair(symbol, suffix));
          return x == null ? symbol : x;
        public SymbolPair getExchangeSpecificStockSymbol(String symbol) {
          SymbolPair sa = internalSymbolToExternalSymbolPairMap_GS.get(symbol);
          return sa == null ? new SymbolPair(symbol, null) : sa;
      NYSE("N", false, '.', OrderTIF.DAY) {
        public String getStandardizedStockSymbol(String symbol, String suffix) {
          String x = externalSymbolPairToInternalSymbolMap_GS.get(new SymbolPair(symbol, suffix));
          return x == null ? symbol : x;
        public SymbolPair getExchangeSpecificStockSymbol(String symbol) {
          SymbolPair sa = internalSymbolToExternalSymbolPairMap_GS.get(symbol);
          return sa == null ? new SymbolPair(symbol, null) : sa;
      ARCA("C", false, '.', OrderTIF.GTD) {
        public String getStandardizedStockSymbol(String symbol, String suffix) {
          String x = externalSymbolPairToInternalSymbolMap_GS.get(new SymbolPair(symbol, suffix));
          return x == null ? symbol : x;
        public SymbolPair getExchangeSpecificStockSymbol(String symbol) {
          SymbolPair sa = internalSymbolToExternalSymbolPairMap_GS.get(symbol);
          return sa == null ? new SymbolPair(symbol, null) : sa;
      public abstract String getStandardizedStockSymbol(String symbol, String suffix);
      public abstract SymbolPair getExchangeSpecificStockSymbol(String symbol);
      private static Map<SymbolPair, String> externalSymbolPairToInternalSymbolMap_GS = new HashMap<SymbolPair, String>();
      private static Map<SymbolPair, String> externalSymbolPairToInternalSymbolMap_ARCA = new HashMap<SymbolPair, String>();
      private static Map<String, SymbolPair> internalSymbolToExternalSymbolPairMap_GS = new HashMap<String, SymbolPair>();
      private static Map<String, SymbolPair> internalSymbolToExternalSymbolPairMap_ARCA = new HashMap<String, SymbolPair>();
      private static Object[] toArrayOutputArray = null;
      static {
        String SQL = null;
        try {
          Connection c = MySQL.connectToMySQL("xxx", "xxx", "xxx", "xxx");
          SQL = "SELECT symbol, ARCASYMBOL, INETSYMBOL, ARCASYMBOLSUFFIX, INETSYMBOLSUFFIX from oms.tblsymbolnew";
          Statement stmt = c.createStatement();
          ResultSet rs = stmt.executeQuery(SQL);
          while (rs.next()) {
            String symbol = rs.getString("symbol");
            if (rs.getString("ARCASYMBOL") != null) {
              if (!symbol.equals(rs.getString("ARCASYMBOL")) || rs.getString("ARCASYMBOLSUFFIX") != null) {
                String suffix = rs.getString("ARCASYMBOLSUFFIX");
                SymbolPair sp = new SymbolPair(rs.getString("ARCASYMBOL"), suffix);
                internalSymbolToExternalSymbolPairMap_ARCA.put(symbol, sp);
                externalSymbolPairToInternalSymbolMap_ARCA.put(sp, symbol);
        } catch (Exception e) {
          System.out.println(SQL);
          e.printStackTrace();
          System.exit(0);
      static {
        populateSymbolToDestination();
      static Logger logger = Logger.getLogger(OrderExchange.class);
      private static HashMap<String, OrderExchange> symbolToDestination = new HashMap<String, OrderExchange>();
      private final String tag100;
      private final boolean usesSymbolSuffixTag;
      private final char symbolSuffixSeparator;
      private final OrderTIF defaultTif;
      private static final String soh = new String(new char[] { '\u0001' });
      private OrderExchange(String tag100, boolean usesSymbolSuffixTag, char symbolSuffixSeparator, OrderTIF defaultTif) {
        this.tag100 = tag100;
        this.defaultTif = defaultTif;
        this.usesSymbolSuffixTag = usesSymbolSuffixTag;
        this.symbolSuffixSeparator = symbolSuffixSeparator;
      public OrderTIF getDefaultTif() {
        return defaultTif;
      public String getTag100() {
        return tag100;
      public char getSymbolSuffixSeparator() {
        return symbolSuffixSeparator;
      public static OrderExchange getOrderExchangeByExchangeName(String name) {
        for (OrderExchange d : OrderExchange.values()) {
          if (d.toString().equalsIgnoreCase(name.trim())) {
            return d;
        return null;
      Thanks,
    Andrew

    Hi Andrew
    The only way to serialize object, so that they can be used by other languages than Java is to use the Portable Object Format.
    The implementation of this requires you to implement the PortableObject interface in Java. PortableObject defines two methods
    public void readExternal(PofReader reader);
    public void writeExternal(PofWriter writer);
    Also you need to add a POF config file that ties the type to a type id.
    In C++ each type needs two template methods implemented to seralize and deserialize. But first it needs to register the data type with the same type id as for the Java type using the COH_REGISTER_MANAGED_CLASS macro.
    Secondly analogs to Java implement the serializer stubs
    template<> void serialize<Type>(PofWriter::Handle hOut, const Type& type);
    template<> Type deserialize<Type>(PofReader::Handle hIn);
    For C# your serializable types need to implement IPortableObject, with it's two methods:
    void IPortableObject.ReadExternal(IPofReader reader);
    void IPortableObject.WriteExternal(IPofWriter writer);
    Similar to Java C# uses a POF configuration file, the same type id should bind to the corresponding C# type.
    For more information see
    POF Configuation: http://coherence.oracle.com/display/COH34UG/POF+User+Type+Configuration+Elements
    C++: http://coherence.oracle.com/display/COH34UG/Integrating+user+data+types
    C#: http://wiki.tangosol.com/display/COHNET33/Configuration+and+Usage#ConfigurationandUsage-PofContext
    Hope that helps!
    /Charlie
    Edited by: Charlie Helin on Apr 30, 2009 12:31 PM

  • Diagnostics Workload Analysis - Java Memory Usage gives BI query input

    Dears
    I have set up diagnostics (aka root cause analysis) at a customer side and I'm bumping into the problem that on the Java Memory Usage tab in Workload analyis the BI query input overview is given
    Sol Man 7.0 EHP1 SPS20 (ST component SP19)
    Wily Introscope 8.2.3.5
    Introscope Agent 8.2.3.5
    Diagnostics Agent 7.20
    When I click on the check button there I get the following:
    Value "JAVA MEMORY USAGE" for variable "E2E Metric Type Variable" is invalid
    I already checked multiple SAP Notes like the implementation of the latest EWA EA WA xml file for the Sol Man stack version.
    I already reactivated BI content using report CCMS_BI_SETUP_E2E and it gave no errors.
    The content is getting filled in Wily Introscope, extractors on Solution Manager are running and capturing records (>0).
    Did anyone come accross this issue already?
    ERROR MESSAGE:
    Diagnosis
    Characteristic value "JAVA MEMORY USAGE" is not valid for variable E2E Metric Type Variable.
    Procedure
    Enter a valid value for the characteristic. The value help, for example, provides you with suggestions. If no information is available here, then perhaps no characteristic values exist for the characteristic.
    If the variable for 0DATE or 0CALDAY has been created and is being used as a key date for a hierarchy, check whether the hierarchies used are valid for this characteristic. The same is valid for variables that refer to the hierarchy version.
      Notification Number BRAIN 643 
    Kind regards
    Tom
    Edited by: Tom Cenens on Mar 10, 2011 2:30 PM

    Hello Paul
    I checked the guide earlier on today. I also asked someone with more BI knowledge to take a look with me but it seems the root cause analysis data fetching isn't really the same as what is normally done in BI with BI cubes so it's hard to determine why the data fetch is not working properly.
    The extractors are running fine, I couldn't find any more errors in the diagnostics agent log files (in debug mode) and I don't find other errors for the SAP system.
    I tried reactivating the BI content but it seems to be fine (no errors). I reran the managed system setup which also works.
    One of the problems I did notice is the fact that the managed SAP systems are half virtualized. They aren't completely virtualized (no seperate ip address) but they are using virtual hostnames which also causes issues with Root Cause Analysis as I cannot install only one agent because I cannot assign it to the managed systems and when I install one agent per SAP system I have the message that there are already agents reporting to the Enterprise Manager residing on the same host. I don't know if this could influence the data extractor. I doubt it because in Wily the data is being fetched fine.
    The only thing that it not working at the moment is the workload analysis - java memory analysis tab. It holds the Key Performance Indicators for the J2EE engine (garbage collection %). I can see them in Wily Introscope where they are available and fine.
    When I looked at the infocubes together with a BI team member, it seemed the infocube for daily stats on performance was getting filled properly (through RSA1) but the infocube for hourly stats wasn't getting filled properly. This is also visible in the workload analysis, data from yesterday displays fine in workload analysis overview for example but data from an hour ago doesn't.
    I do have to state the Solution Manager doesn't match the prerequisites (post processing notes are not present after SP-stack update, SLD content is not up to date) but I could not push through those changes within a short timeframe as the Solution Manager is also used for other scenarios and it would be too disruptive at this moment.
    If I can't fix it I will have to explain to the customer why some parts are not working and request them to handle the missing items so the prerequisites are met.
    One of the notes I found described a similar issue and noted it could be caused due to an old XML file structure so I updated the XML file to the latest version.
    The SAPOscol also throwed errors in the beginning strange enough. I had the Host Agent installed and updated and the SAPOscol service was running properly through the Host Agent as a service. The diagnostics agent tries to start SAPOscol in /usr/sap/<SID>/SMDA<instance number>/exe which does not hold the SAPOscol executable. I suppose it's a bug from SAP? After copying the SAPOscol from the Host Agent to the location of the SMD Agent the error disappeared. Instead the agent tries to start SAPOscol but then notices SAPOscol is already running and writes in the log that SAPOscol is already running properly and a startup is not neccesary.
    To me it comes down the point where I have little faith in the scenario if the Solution Manager and the managed SAP systems are not maintained and up to date 100%. I could open a customer message but the first advice will be to patch the Solution Manager and meet the prerequisites.
    Another pain point is the fact that if the managed SAP systems are not 100% correct in transaction SMSY it also causes heaps of issues. Changing the SAP system there isn't a fast operation as it can be included in numerous logical components, projects, scenario's (CHARM) and it causes disruption to daily work.
    All in all I have mixed feelings about the implementation, I want to deliver a fully working scenario but it's near impossible due to the fact that the prerequisites are not met. I hope the customer will still be happy with what is delivered.
    I sure do hope some of these issues are handled in Solution Manager 7.1. I will certainly mail my concerns to the development team and hope they can handle some or all of them.
    Kind regards
    Tom

  • Where did these .dat files come from?

    A couple days ago, while in Ghana, I was suddenly unable to send Microsoft file attachments; the files show up at my recipients as .dat files. How can I fix this?

    I will try to put keywords so people find this thread.
    Thanks to liaoyunhe we found "fast" the origin of our problem.
    The problem is itself related to the usage of Microsoft's JDBC driver for SQL 2000 service pack 3 (�why to use M$-$QL on java?).
    We currently use the same code with Postgres and also with JTDS drivers and there is no such problem.
    What liaoyunhe says is absolutely true: you have to close ALL resultsets and ALL statements so there is no problem with the srt scb files.
    We were stressing the application and after a while we got an "Too many files open" exception and we were able to count 39.000 srt+scb files with lsof.
    After carefully reviewing our code, we found that we were not closing one resultset on a connection we re-use and the tmps were created and not released.
    Thanks again liaoyunhe.
    Thanks Micro$oft for giving us some extra work :-)

  • Using the Insert statement in a Java program without hardcoding the data

    hello.
    this is james mcfadden. i have developed a program called Demo.java, which is used with another program called QueryTableModel.java (a program that allows data to be viewed in a JTable). The Demo.java program displays a menu, connects to a database, allows the user to add data into the database and allows the user to view data that is already in the database. I have a problem with the Demo.java program. I have hardcoded the Insert statement in it. How do you use the Insert statement to put data into a database without hardcoding the data?
    import java.awt.*;//Contains all of the classes for creating user interfaces and for painting graphics and images
    import java.awt.event.*;//Provides interfaces and classes for dealing with different types of events fired by AWT components
    import javax.swing.*;//Provides a set of lightweight components that, to the maximum degree possible, work the same on all platforms
    import javax.swing.table.*;//Provides classes and interfaces for dealing with javax.swing.JTable
    import javax.swing.JOptionPane;//provides a class that makes it easy to pop up a standard dialog box that prompts users for a value or informs them of something
    import java.sql.*;//Provides the API for accessing and processing data stored in a data source using the Java programming language
    public class Demo extends JFrame{
       static String url = "jdbc:odbc:VideoLibrary";//a static variable that allows a connection to be made to a database called VideoLibrary
       static Statement stmt;//a static variable that allows a statement to be made once a connection is set up
       static Connection con;//a static interface that allows a connection to be made to a database
         //global variables
         JTextField hostField;//a class that allows a line of text to be changed
       JTextField queryField;//a class that allows a line of text to be changed
       QueryTableModel qtm;//a class that shows and changes regular two-dimensional tables of cells
       JComboBox comboBox;//a class that puts a button or editable field and a drop-down list together 
       public static void main(String args[]){     
          int choice=-1;//a variable of type int that is set to -1
              do{
             choice=getChoice();//invokes the method getChoice()
             if(choice!=0){
                getSelected(choice);//invokes the method getSelected(choice)
             }//end if
                   //if the user chooses 5, it will cause him or her to exit the system
          }while(choice!=5);//end do-while
          System.exit(0);//closes down the menu screen
       }//end main
       public static int getChoice(){
          String choice;//a variable of type string
          int ch;//a variable of type int
          choice = JOptionPane.showInputDialog(null,"1. Maintain product details\n"+"2. Maintain member details\n"+"3. Maintain rental details\n"+"4. View product, member and rental details\n"+"5. Log Off\n\n"+"Enter your choice");//asks the user for some input   
              ch = Integer.parseInt(choice);//a class that wraps a value of the primitive type int in an object     
              return ch;//a method that returns an integer value
       }//end getChoice
       public static void getSelected(int choice){   
              if(choice==1){
             maintainProductDetails();//invokes the method maintainProductDetails()
          }//end if
          if(choice==2){
             maintainMemberDetails();//invokes the method maintainMemberDetails()
          }//end if
              if(choice==3){
             maintainRentalDetails();//invokes the method maintainRentalDetails()
          }//end if
              if(choice==4){
                 Demo test = new Demo();//invokes the constructor Demo()
             test.setVisible(true);//shows the JTable component by marking it as visible
              }//end if
       }//end getSelected
       public static Connection getConnection(){
          try {
             Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");//used to create a JDBC connection using a database
          }//end try
              catch(java.lang.ClassNotFoundException e){//causes an exception to be thrown when an application tries to load in a class through its string name
             System.err.print("ClassNotFoundException: ");//displays an error message
             System.err.println(e.getMessage());//returns the exception that was raised if an error occurred while attempting to load the ClassNotFoundException class
          }//end catch
          try {
             con=DriverManager.getConnection(url,"","");//tries to create a connection with the database using the DriverManager class
          }//end try
              catch(SQLException ex) {
             System.err.println("SQLException: " + ex.getMessage());//returns an SQL error message
          }//end catch
          return con;
       }//end getConnection
       public static void maintainProductDetails(){
          Connection con = getConnection();//creates a connection with the database
          String  addProduct1, addProduct2, addProduct3, addProduct4, addProduct5, addProduct6, addProduct7, addProduct8, addProduct9, addProduct10;//string variables that represent information about the different types of product data that will be stored in the database
          addProduct1 = "insert into Product values (110001, 'The Killers - Sams Town', 5.00, 'G', 'CD', 2006)";
          addProduct2 = "insert into Product values (110002, 'Robbie Williams - Rudebox', 5.00, 'G', 'CD', 2006)";
          addProduct3 = "insert into Product values (110003, 'Razorlight - Razorlight', 5.00, 'G', 'CD', 2006)";
          addProduct4 = "insert into Product values (110004, 'My Chemical Romance - The Black Parade', 5.00, 'G', 'CD', 2006)";
          addProduct5 = "insert into Product values (110005, 'Snow Patrol - Eyes Open', 5.00, 'G', 'CD', 2006)";
          addProduct6 = "insert into Product values (110006, 'Scissor Sisters - Ta-Dah!', 5.00, 'G', 'CD', 2006)";
              addProduct7 = "insert into Product values (110007, 'Lovesounds - Justin Timberlake', 5.00, 'G', 'CD', 2006)";
          addProduct8 = "insert into Product values (110008, 'Director - We thrive on big cities', 5.00, 'G', 'CD', 2006)";
          addProduct9 = "insert into Product values (110009, 'Roxette - Roxette hits', 5.00, 'G', 'CD', 2006)";
          addProduct10 = "insert into Product values (110010, 'Pussy Cat Dolls - PCD', 5.00, 'G', 'CD', 2006)";
              try {
             stmt = con.createStatement();//Creates a Statement object for sending SQL statements to the database
                 //statements are allowed to be made once a connection is set up
                 stmt.executeUpdate(addProduct1);
             stmt.executeUpdate(addProduct2);
             stmt.executeUpdate(addProduct3);
             stmt.executeUpdate(addProduct4);
                   stmt.executeUpdate(addProduct5);
             stmt.executeUpdate(addProduct6);
                 stmt.executeUpdate(addProduct7);
             stmt.executeUpdate(addProduct8);
             stmt.executeUpdate(addProduct9);
             stmt.executeUpdate(addProduct10);
             stmt.close();//closes the Statement object
             con.close();//terminates the connection with the database
          }//end try
              catch(SQLException ex) {
             System.err.println("SQLException: " + ex.getMessage());//returns an SQL error message
          }//end catch
       }//end maintainProductDetails
       public static void maintainMemberDetails(){
          Connection con = getConnection();//creates a connection with the database
          String addMember1, addMember2, addMember3, addMember4, addMember5, addMember6, addMember7, addMember8, addMember9, addMember10;//string variables that represent information about the member data that will be stored in the database
          addMember1 = "insert into Member values (1234, 'Ann', 'Smyth', 'Upper Killult, Falcarragh, Co. Donegal', '(074)-9135210', '(087)-2030172', #5/11/85#, #5/12/06#)";
          addMember2 = "insert into Member values (2345, 'John', 'Murphy', 'Lower Killult, Falcarragh, Co. Donegal', '(074)-9135211', '(087)-2030173', #4/12/85#, #6/13/06#)";
          addMember3 = "insert into Member values (1324, 'James', 'McFadden', 'Lower Ardsbeg, Gortahork, Co. Donegal', '(074)-9165314', '(087)-2030171', #4/11/85#, #6/14/06#)";
          addMember4 = "insert into Member values (1235, 'Frankie', 'Ferry', 'Ardsmore, Gortahork, Co. Donegal', '(074)-9165325', '(087)-2031234', #6/13/60#, #6/15/06#)";
          addMember5 = "insert into Member values (1236, 'Daniel', 'McKimm', 'Ballyness, Falcarragh, Co. Donegal', '(074)-9135212', '(087)-2030184', #5/14/73#, #6/16/06#)";
          addMember6 = "insert into Member values (2346, 'Stephen', 'Doohan', 'Ballyness, Falcarragh, Co. Donegal', '(074)-9135213', '(087)-2030185', #6/13/85#, #5/13/06#)";
          addMember7 = "insert into Member values (2347, 'James', 'Ferry', 'Meenlaragh, Gortahork, Co.Donegal', '(074)-9165360', '(087)-2031345', #9/12/85#, #5/14/06#)";
          addMember8 = "insert into Member values (2348, 'Liam', 'Cannon', 'Derryconner, Gortahork, Co.Donegal', '(074)-9165324', '(087)-2031456', #4/11/86#, #5/15/06#)";
          addMember9 = "insert into Member values (2401, 'Ciaran', 'Ferry', 'Brinalack, Gweedore, Co.Donegal', '(074)-9176425', '(087)-2030282', #9/12/85#, #5/16/06#)";
          addMember10 = "insert into Member values (2402, 'Ciaran', 'McGee', 'Derrybeg, Gweedore, Co.Donegal', '(074)-9176536', '(087)-2030393', #9/14/85#, #5/18/06#)";
          try{
             stmt = con.createStatement();//Creates a Statement object for sending SQL statements to the database
                   //statements are allowed to be made once a connection is set up
                   stmt.executeUpdate(addMember1);
             stmt.executeUpdate(addMember2);
             stmt.executeUpdate(addMember3);
                   stmt.executeUpdate(addMember4);
                   stmt.executeUpdate(addMember5);
                   stmt.executeUpdate(addMember6);
                   stmt.executeUpdate(addMember7);
                   stmt.executeUpdate(addMember8);
                   stmt.executeUpdate(addMember9);
                   stmt.executeUpdate(addMember10);
             stmt.close();//closes the Statement object
             con.close();//terminates the connection with the database
          }//end try
              catch(SQLException ex) {
             System.err.println("SQLException: " + ex.getMessage());//returns an SQL error message
          }//end catch
       }//end maintainMemberDetails
         public static void maintainRentalDetails(){
          Connection con = getConnection();//creates a connection with the database
          String addRental1, addRental2, addRental3, addRental4, addRental5, addRental6, addRental7, addRental8, addRental9, addRental10;//string variables that represent information about the loan data that will be stored in the database
          addRental1 = "insert into Rental values (110001, 'The Killers - Sams Town', 1234, 'Ann', 'Smyth', #9/01/06#, #9/10/06#, 'Yes', 2.00)";
          addRental2 = "insert into Rental values (120001, 'Mission Impossible 3', 2345, 'John', 'Murphy', #9/02/06#, #9/09/06#, 'No', 0.00)";
          addRental3 = "insert into Rental values (130001, 'Need for Special Carbon', 1324, 'James', 'McFadden', #9/03/06#, #9/12/06#, 'Yes', 2.00)";
          addRental4 = "insert into Rental values (110002, 'Robbie Williams - Rudebox', 1235, 'Frankie', 'Ferry', #9/04/06#, #9/11/06#, 'No', 0.00)";
          addRental5 = "insert into Rental values (120015, 'Prime', 1236, 'Daniel', 'McKimm', #9/05/06#, #9/14/06#, 'Yes', 2.00)";
          addRental6 = "insert into Rental values (130015, 'FIFA 07', 2346, 'Stephen', 'Doohan', #9/06/06#, #9/13/06#, 'No', 0.00)";
          addRental7 = "insert into Rental values (110009, 'Roxette - Roxette hits', 2347, 'James', 'Ferry', #9/07/06#, #9/16/06#, 'Yes', 2.00)";
          addRental8 = "insert into Rental values (120003, 'The Break Up', 2348, 'Liam', 'Cannon', #9/08/06#, #9/15/06#, 'No', 0.00)";
          addRental9 = "insert into Rental values (130027, 'Gears of War', 2401, 'Ciaran', 'Ferry', #9/09/06#, #9/18/06#, 'Yes', 2.00)";
          addRental10 = "insert into Rental values (110021, 'Scooter - Mind the Gap', 2402, 'Ciaran', 'McGee', #9/10/06#, #9/17/06#, 'No', 0.00)";
          try{
             stmt = con.createStatement();//Creates a Statement object for sending SQL statements to the database
                   //statements are allowed to be made once a connection is set up
                   stmt.executeUpdate(addRental1);
             stmt.executeUpdate(addRental2);
             stmt.executeUpdate(addRental3);
                   stmt.executeUpdate(addRental4);
                   stmt.executeUpdate(addRental5);
                   stmt.executeUpdate(addRental6);
                   stmt.executeUpdate(addRental7);
                   stmt.executeUpdate(addRental8);
                   stmt.executeUpdate(addRental9);
                   stmt.executeUpdate(addRental10);
             stmt.close();//closes the Statement object
             con.close();//terminates the connection with the database
          }//end try
              catch(SQLException ex) {
             System.err.println("SQLException: " + ex.getMessage());//returns an SQL error message
          }//end catch
       }//end maintainRentalDetails
       public Demo(){//a constructor
          super("Demo Test Frame");//overrides the constructor
          setSize(350, 200);//Resizes this component so that it has width of 350 and height of 200 
          comboBox = new JComboBox();//invokes the class JComboBox
          comboBox.addItem("jdbc:odbc:VideoLibrary");//adds the specified item to the end of the scrolling list
          qtm = new QueryTableModel();//invokes the class QueryTableModel
          JTable table = new JTable(qtm);//a class that shows and changes regular two-dimensional tables of cells
          JScrollPane scrollpane = new JScrollPane(table);//a class that provides a scrollable view of a lightweight component
          JPanel p1 = new JPanel();//a class that puts the combo box and query field in a panel
          p1.setLayout(new GridLayout(3, 2));//Sets the layout manager for this container
          p1.add(comboBox);//Appends the specified component to the end of this container
          p1.add(new JLabel("Enter your query: "));//Appends the specified component to the end of this container
          p1.add(queryField = new JTextField());//Appends the specified component to the end of this container
          p1.add(new JLabel("Click here to send: "));//Appends the specified component to the end of this container
          JButton jb = new JButton("Search");//a class that is an implementation of a "push" button
          jb.addActionListener(new ActionListener(){//Adds an ActionListener to the button
             public void actionPerformed(ActionEvent e){
                qtm.setHostURL();//invokes the method setHostURL
                qtm.setQuery(queryField.getText().trim());//invokes the method setQuery; and returns the text that is presented by this text component and returns a copy of the string, with leading and trailing whitespaces omitted
          } );//end addActionListener
          p1.add(jb);//Appends the specified component to the end of this container
          getContentPane().add(p1, BorderLayout.NORTH);//Returns the content pane
          getContentPane().add(scrollpane, BorderLayout.CENTER);//Returns the content pane
       }//end Demo
    }//end class Demo
    import java.sql.*;//Provides the API for accessing and processing data stored in a data source using the Java programming language
    import java.io.*;//Provides for system input and output through data streams, serialization and the file system
    import java.util.Vector;//provides a class that implements a growable array of objects
    import javax.swing.*;//Provides a set of lightweight components that, to the maximum degree possible, work the same on all platforms
    import javax.swing.table.*;//Provides classes and interfaces for dealing with javax.swing.JTable
    public class QueryTableModel extends AbstractTableModel{
         Vector cache;//a class that constructs an empty vector so that its internal data array has size 10 and its standard capacity increment is zero 
         int colCount;//a variable that counts the number of columns in the three tables
         String[] headers;//a class that represents character strings and all string literals in this program are implemented as instances of the String class
         Connection db;//an interface that allows a connection to be made to a database
         Statement statement;//an interface that allows executes the given SQL statement, which returns a single ResultSet object
         String currentURL;//a variable that allows the URL to be displayed in a combo box
         public QueryTableModel(){//a constructor
              cache=new Vector();//constructs an empty vector so that its internal data array has size 10 and its standard capacity increment is zero
              try{
             Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");//used by opening a JDBC connection using an URL
              }//end try
              catch(Exception e){
                   System.out.println("problem loading the driver ");//an error message
              }//end catch
         }//end QueryTableModel
         public String getColumnName(int i){//Returns the designated column's name
            return headers;//returns the name of each column in the three table
         }//end getColumnName
         public int getColumnCount(){//Returns the number of columns in the column model
         return colCount;//returns the number of columns in the three tables
         }//end getColumnCount
         public int getRowCount(){//Returns the number of rows in this table's model
         return cache.size();//returns the number of components in the vector
         }//end getRowCount
         public Object getValueAt(int row, int col){//Returns the cell value at row and column
              return ((String[])cache.elementAt(row))[col];//Returns the component at the specified index
         }//end getValueAt
         public void setHostURL(){//sets the URL for the database
         String url = "jdbc:odbc:VideoLibrary";//a variable that allows a connection to be made to a database called VideoLibrary
         closeDB();//invokes the method closeDB()
              try{
    db=DriverManager.getConnection(url,"","");//tries to create a connection with the database using the DriverManager class
    statement=db.createStatement();//Creates a Statement object for sending SQL statements to the database
    }//end try
    catch(Exception e){
    System.out.println("Could not initialize the database.");//an error message
    e.printStackTrace();//a Throwable method that prints this throwable and it's backtrace to the standard error stream
    }//end catch
         }//end setHostURL
    public void setQuery(String q){//sets the kind of query that is to be sent to the database
              cache=new Vector();//constructs an empty vector so that its internal data array has size 10 and its standard capacity increment is zero
    String s="select * from Product";//a variable that causes all the data that is in the product table to be displayed in a JTable, which also means that all the data that is in both the member and rental tables can also be displayed in a JTable
              try{
                   ResultSet rs=statement.executeQuery(q);//an interface that is used to generate a database result set by executing a statement that queries the database
                   ResultSetMetaData meta=rs.getMetaData();//an interface that is used to get information about the types and properties of the columns in a ResultSet object
                   colCount=meta.getColumnCount();//Returns the number of columns in this ResultSet object
                   headers=new String[colCount];//gets the name of each column in the three tables
                   for(int h=1;h<=colCount;h++){
                        headers[h-1]=meta.getColumnName(h);//Get the designated column's name
                   }//end for
                   while(rs.next()){
                        String[] record=new String[colCount];//stores the name of each column in the three tables in memory
                        for(int i=0;i<colCount;i++){
                             record[i]=rs.getString(i+1);//Retrieves the value of the designated column in the current row of this ResultSet object as a String
                        }//end for
                        cache.addElement(record);//Adds the specified component to the end of this vector, increasing its size by one
                   }//end while
                   fireTableChanged(null);//Forwards the given notification event to all TableModelListeners that registered themselves as listeners for this table model
              }//end try
              catch(Exception e){
                   cache=new Vector();//constructs an empty vector so that its internal data array has size 10 and its standard capacity increment is zero
                   e.printStackTrace();//a Throwable method that prints this throwable and it's backtrace to the standard error stream
              }//end catch
         }//end setQuery
         public void initDB(String url){
              try{
                   db=DriverManager.getConnection(url);//tries to create a connection with the database using the DriverManager class
                   statement=db.createStatement();//Creates a Statement object for sending SQL statements to the database
              }//end try
              catch(Exception e){
                   System.out.println("Could not initialize the database.");//an error message
                   e.printStackTrace();//a Throwable method that prints this throwable and it's backtrace to the standard error stream
              }//end catch
         }//end initDB
         public void closeDB(){
              try{
                   if(statement!=null){
                   statement.close();//Releases this Statement object's database and JDBC resources immediately instead of waiting for this to happen when it is automatically closed
                   }//end if
                   if(db!=null){
                   db.close();//Releases this Connection object's database and JDBC resources immediately instead of waiting for them to be automatically released
                   }//end if
              }//end try
              catch(Exception e){
                   System.out.println("Could not close the current connection.");//an error message
                   e.printStackTrace();//a Throwable method that prints this throwable and it's backtrace to the standard error stream
              }//end catch
         }//end closeDB
    }//end class QueryTableModel

    here's an uncommented version of the code.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.table.*;
    import javax.swing.JOptionPane;
    import java.sql.*;
    public class Demo extends JFrame{
       static String url = "jdbc:odbc:VideoLibrary";
       static Statement stmt;
       static Connection con;
       JTextField hostField;
       JTextField queryField;
       QueryTableModel qtm;
       JComboBox comboBox;
       public static void main(String args[]){
          int choice=-1;
          do{
             choice=getChoice();
             if(choice!=0){
                getSelected(choice);
          }while(choice!=5);
          System.exit(0);
       public static int getChoice(){
          String choice;
          int ch;
          choice = JOptionPane.showInputDialog(null,"1. Maintain product details\n"+"2. Maintain member details\n"+"3. Maintain rental details\n"+"4. View product, member and rental details\n"+"5. Log Off\n\n"+"Enter your choice"); 
          ch = Integer.parseInt(choice);    
          return ch;
       public static void getSelected(int choice){   
          if(choice==1){
             maintainProductDetails();
          if(choice==2){
             maintainMemberDetails();
          if(choice==3){
             maintainRentalDetails();
          if(choice==4){
             Demo test = new Demo();
             test.setVisible(true);
       public static Connection getConnection(){
          try {
             Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
          catch(java.lang.ClassNotFoundException e){
             System.err.print("ClassNotFoundException: ");
             System.err.println(e.getMessage());
          try {
             con=DriverManager.getConnection(url,"","");
          catch(SQLException ex) {
             System.err.println("SQLException: " + ex.getMessage());
          return con;
       public static void maintainProductDetails(){
          Connection con = getConnection();
          String  addProduct1, addProduct2, addProduct3, addProduct4, addProduct5, addProduct6, addProduct7, addProduct8, addProduct9, addProduct10;
          addProduct1 = "insert into Product values (110001, 'The Killers - Sams Town', 5.00, 'G', 'CD', 2006)";
          addProduct2 = "insert into Product values (110002, 'Robbie Williams - Rudebox', 5.00, 'G', 'CD', 2006)";
          addProduct3 = "insert into Product values (110003, 'Razorlight - Razorlight', 5.00, 'G', 'CD', 2006)";
          addProduct4 = "insert into Product values (110004, 'My Chemical Romance - The Black Parade', 5.00, 'G', 'CD', 2006)";
          addProduct5 = "insert into Product values (110005, 'Snow Patrol - Eyes Open', 5.00, 'G', 'CD', 2006)";
          addProduct6 = "insert into Product values (110006, 'Scissor Sisters - Ta-Dah!', 5.00, 'G', 'CD', 2006)";
          addProduct7 = "insert into Product values (110007, 'Lovesounds - Justin Timberlake', 5.00, 'G', 'CD', 2006)";
          addProduct8 = "insert into Product values (110008, 'Director - We thrive on big cities', 5.00, 'G', 'CD', 2006)";
          addProduct9 = "insert into Product values (110009, 'Roxette - Roxette hits', 5.00, 'G', 'CD', 2006)";
          addProduct10 = "insert into Product values (110010, '***** Cat Dolls - PCD', 5.00, 'G', 'CD', 2006)";
          try {
             stmt = con.createStatement();
             stmt.executeUpdate(addProduct1);
             stmt.executeUpdate(addProduct2);
             stmt.executeUpdate(addProduct3);
             stmt.executeUpdate(addProduct4);
             stmt.executeUpdate(addProduct5);
             stmt.executeUpdate(addProduct6);
             stmt.executeUpdate(addProduct7);
             stmt.executeUpdate(addProduct8);
             stmt.executeUpdate(addProduct9);
             stmt.executeUpdate(addProduct10);
             stmt.close();
             con.close();
          catch(SQLException ex) {
             System.err.println("SQLException: " + ex.getMessage());
       public static void maintainMemberDetails(){
          Connection con = getConnection();
          String addMember1, addMember2, addMember3, addMember4, addMember5, addMember6, addMember7, addMember8, addMember9, addMember10;
          addMember1 = "insert into Member values (1234, 'Ann', 'Smyth', 'Upper Killult, Falcarragh, Co. Donegal', '(074)-9135210', '(087)-2030172', #5/11/85#, #5/12/06#)";
          addMember2 = "insert into Member values (2345, 'John', 'Murphy', 'Lower Killult, Falcarragh, Co. Donegal', '(074)-9135211', '(087)-2030173', #4/12/85#, #6/13/06#)";
          addMember3 = "insert into Member values (1324, 'James', 'McFadden', 'Lower Ardsbeg, Gortahork, Co. Donegal', '(074)-9165314', '(087)-2030171', #4/11/85#, #6/14/06#)";
          addMember4 = "insert into Member values (1235, 'Frankie', 'Ferry', 'Ardsmore, Gortahork, Co. Donegal', '(074)-9165325', '(087)-2031234', #6/13/60#, #6/15/06#)";
          addMember5 = "insert into Member values (1236, 'Daniel', 'McKimm', 'Ballyness, Falcarragh, Co. Donegal', '(074)-9135212', '(087)-2030184', #5/14/73#, #6/16/06#)";
          addMember6 = "insert into Member values (2346, 'Stephen', 'Doohan', 'Ballyness, Falcarragh, Co. Donegal', '(074)-9135213', '(087)-2030185', #6/13/85#, #5/13/06#)";
          addMember7 = "insert into Member values (2347, 'James', 'Ferry', 'Meenlaragh, Gortahork, Co.Donegal', '(074)-9165360', '(087)-2031345', #9/12/85#, #5/14/06#)";
          addMember8 = "insert into Member values (2348, 'Liam', 'Cannon', 'Derryconner, Gortahork, Co.Donegal', '(074)-9165324', '(087)-2031456', #4/11/86#, #5/15/06#)";
          addMember9 = "insert into Member values (2401, 'Ciaran', 'Ferry', 'Brinalack, Gweedore, Co.Donegal', '(074)-9176425', '(087)-2030282', #9/12/85#, #5/16/06#)";
          addMember10 = "insert into Member values (2402, 'Ciaran', 'McGee', 'Derrybeg, Gweedore, Co.Donegal', '(074)-9176536', '(087)-2030393', #9/14/85#, #5/18/06#)";
          try{
             stmt = con.createStatement();
             stmt.executeUpdate(addMember1);
             stmt.executeUpdate(addMember2);
             stmt.executeUpdate(addMember3);
             stmt.executeUpdate(addMember4);
             stmt.executeUpdate(addMember5);
             stmt.executeUpdate(addMember6);
             stmt.executeUpdate(addMember7);
             stmt.executeUpdate(addMember8);
             stmt.executeUpdate(addMember9);
             stmt.executeUpdate(addMember10);
             stmt.close();
             con.close();
          catch(SQLException ex) {
             System.err.println("SQLException: " + ex.getMessage());
       public static void maintainRentalDetails(){
          Connection con = getConnection();
          String addRental1, addRental2, addRental3, addRental4, addRental5, addRental6, addRental7, addRental8, addRental9, addRental10;
          addRental1 = "insert into Rental values (110001, 'The Killers - Sams Town', 1234, 'Ann', 'Smyth', #9/01/06#, #9/10/06#, 'Yes', 2.00)";
          addRental2 = "insert into Rental values (120001, 'Mission Impossible 3', 2345, 'John', 'Murphy', #9/02/06#, #9/09/06#, 'No', 0.00)";
          addRental3 = "insert into Rental values (130001, 'Need for Special Carbon', 1324, 'James', 'McFadden', #9/03/06#, #9/12/06#, 'Yes', 2.00)";
          addRental4 = "insert into Rental values (110002, 'Robbie Williams - Rudebox', 1235, 'Frankie', 'Ferry', #9/04/06#, #9/11/06#, 'No', 0.00)";
          addRental5 = "insert into Rental values (120015, 'Prime', 1236, 'Daniel', 'McKimm', #9/05/06#, #9/14/06#, 'Yes', 2.00)";
          addRental6 = "insert into Rental values (130015, 'FIFA 07', 2346, 'Stephen', 'Doohan', #9/06/06#, #9/13/06#, 'No', 0.00)";
          addRental7 = "insert into Rental values (110009, 'Roxette - Roxette hits', 2347, 'James', 'Ferry', #9/07/06#, #9/16/06#, 'Yes', 2.00)";
          addRental8 = "insert into Rental values (120003, 'The Break Up', 2348, 'Liam', 'Cannon', #9/08/06#, #9/15/06#, 'No', 0.00)";
          addRental9 = "insert into Rental values (130027, 'Gears of War', 2401, 'Ciaran', 'Ferry', #9/09/06#, #9/18/06#, 'Yes', 2.00)";
          addRental10 = "insert into Rental values (110021, 'Scooter - Mind the Gap', 2402, 'Ciaran', 'McGee', #9/10/06#, #9/17/06#, 'No', 0.00)";
          try{
             stmt = con.createStatement();
             stmt.executeUpdate(addRental1);
             stmt.executeUpdate(addRental2);
             stmt.executeUpdate(addRental3);
             stmt.executeUpdate(addRental4);
             stmt.executeUpdate(addRental5);
             stmt.executeUpdate(addRental6);
             stmt.executeUpdate(addRental7);
             stmt.executeUpdate(addRental8);
             stmt.executeUpdate(addRental9);
             stmt.executeUpdate(addRental10);
             stmt.close();
             con.close();
          catch(SQLException ex) {
             System.err.println("SQLException: " + ex.getMessage());
       public Demo(){
          super("Demo Test Frame");
          setSize(350, 200);
          comboBox = new JComboBox();
          comboBox.addItem("jdbc:odbc:VideoLibrary");
          qtm = new QueryTableModel();
          JTable table = new JTable(qtm);
          JScrollPane scrollpane = new JScrollPane(table);
          JPanel p1 = new JPanel();
          p1.setLayout(new GridLayout(3, 2));
          p1.add(comboBox);
          p1.add(new JLabel("Enter your query: "));
          p1.add(queryField = new JTextField());
          p1.add(new JLabel("Click here to send: "));
          JButton jb = new JButton("Search");
          jb.addActionListener(new ActionListener(){
             public void actionPerformed(ActionEvent e){
                qtm.setHostURL();
                qtm.setQuery(queryField.getText().trim());
          p1.add(jb);
          getContentPane().add(p1, BorderLayout.NORTH);
          getContentPane().add(scrollpane, BorderLayout.CENTER);
    import java.sql.*;
    import java.io.*;
    import java.util.Vector;
    import javax.swing.*;
    import javax.swing.table.*;
    public class QueryTableModel extends AbstractTableModel{
         Vector cache; 
         int colCount;
         String[] headers;
         Connection db;
         Statement statement;
         String currentURL;
         public QueryTableModel(){
              cache=new Vector();
              try{
             Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
              catch(Exception e){
                   System.out.println("problem loading the driver ");
         public String getColumnName(int i){
            return headers;
         public int getColumnCount(){
         return colCount;
         public int getRowCount(){
         return cache.size();
         public Object getValueAt(int row, int col){
              return ((String[])cache.elementAt(row))[col];
         public void setHostURL(){
         String url = "jdbc:odbc:VideoLibrary";
         closeDB();
              try{
    db=DriverManager.getConnection(url,"","");
    statement=db.createStatement();
    catch(Exception e){
    System.out.println("Could not initialize the database.");
    e.printStackTrace();
    public void setQuery(String q){
              cache=new Vector();
    String s="select * from Product";
              try{
                   ResultSet rs=statement.executeQuery(q);
                   ResultSetMetaData meta=rs.getMetaData();
                   colCount=meta.getColumnCount();
                   headers=new String[colCount];
                   for(int h=1;h<=colCount;h++){
                        headers[h-1]=meta.getColumnName(h);
                   while(rs.next()){
                        String[] record=new String[colCount];
                        for(int i=0;i<colCount;i++){
                             record[i]=rs.getString(i+1);
                        cache.addElement(record);
                   fireTableChanged(null);
              catch(Exception e){
                   cache=new Vector();
                   e.printStackTrace();
         public void initDB(String url){
              try{
                   db=DriverManager.getConnection(url);
                   statement=db.createStatement();
              catch(Exception e){
                   System.out.println("Could not initialize the database.");
                   e.printStackTrace();
         public void closeDB(){
              try{
                   if(statement!=null){
                   statement.close();
                   if(db!=null){
                   db.close();
              catch(Exception e){
                   System.out.println("Could not close the current connection.");
                   e.printStackTrace();

Maybe you are looking for