Package bm.db

Examples of bm.db.Database


            throws VirtualMachineException
    {
        final int id = checkMethod( methodName, args );
        if( id != -1 )
        {
            Database db = (Database)
                    target.getAttachment( "db" );
            try
            {
                switch( id )
                {
                    case CONNECT:
                        if( db == null )
                        {
                            db = Database.connect( Conversor.toString( args[0] ) );
                            target.setAttachment( "db", db );
                        }
                        return null;

                    case CREATE:
                        if( db == null )
                        {
                            db = Database.create( Conversor.toString( args[0] ) );
                            target.setAttachment( "db", db );
                        }
                        return null;

                    case GET_TABLE:
                        if( db != null )
                        {
                            final String tableName = Conversor.toString( args[0] );
                            final Table table = db.getTable(
                                    tableName
                            );
                            if( table != null )
                            {
                                Hashtable tables = (Hashtable)
                                        target.getAttachment( "tables" );
                                if( tables == null )
                                {
                                    tables = new Hashtable( 10 );
                                    target.setAttachment( "tables", tables );
                                }
                                Instance t = (Instance) tables.get( tableName );
                                if( t == null )
                                {
                                    t = getVirtualMachine().newInstance( "Table" );
                                    t.setAttachment( "table", table );
                                    t.setAttachment( "parent", target );
                                    tables.put( tableName, t );
                                }
                                return t;
                            }
                            else
                            {
                                return null;
                            }
                        }
                        else
                        {
                            return null;
                        }

                    case CREATE_TABLE:
                        if( db != null )
                        {
                            final Table table = (Table)
                                    args[0].getAttachment( "table" );
                            db.createTable( table );
                            Hashtable tables = (Hashtable)
                                    target.getAttachment( "tables" );
                            if( tables == null )
                            {
                                tables = new Hashtable( 10 );
                                target.setAttachment( "tables", tables );
                            }
                            Instance t = (Instance) tables.get( table.getName() );
                            if( t == null )
                            {
                                t = getVirtualMachine().newInstance( "Table" );
                                t.setAttachment( "table", table );
                                t.setAttachment( "parent", target );
                                tables.put( table.getName(), t );
                            }
                            return t;
                        }
                        else
                        {
                            return null;
                        }

                    case START:
                        if( db != null )
                        {
                            db.start();
                        }
                        else
                        {
                            return null;
                        }

                    case PACK:
                        if( db != null )
                        {
                            db.pack();
                        }
                        else
                        {
                            return null;
                        }

                    case DROP:
                        if( db != null )
                        {
                            db.drop();
                        }
                        else
                        {
                            return null;
                        }

                    case REPAIR:
                        if( db != null )
                        {
                            db.repair();
                        }
                        else
                        {
                            return null;
                        }

                    case IS_DAMAGED:
                        return db != null ?
                               Conversor.toInstance(
                                       getVirtualMachine(),
                                       new Boolean( db.isDamaged() )
                               ) :
                               null;

                    case OPEN:
                        if( db != null )
                        {
                            db.open();
                        }
                        else
                        {
                            return null;
                        }

                    case CLOSE:
                        if( db != null )
                        {
                            db.close();
                        }
                        else
                        {
                            return null;
                        }

                    case SHUTDOWN:
                        if( db != null )
                        {
                            db.shutdown();
                        }
                        else
                        {
                            return null;
                        }

                    case SANITY_CHECK:
                        if( db != null )
                        {
                            db.sanityCheck();
                        }
                        else
                        {
                            return null;
                        }

                    case GET_NAME:
                        return db != null ?
                               Conversor.toInstance(
                                       getVirtualMachine(),
                                       db.getName()
                               ) :
                               null;

                    case GET_VER_MAJOR:
                        return db != null ?
                               Conversor.toInstance(
                                       getVirtualMachine(),
                                       new Short( db.getVersionMajor() )
                               ) :
                               null;

                    case GET_VER_MINOR:
                        return db != null ?
                               Conversor.toInstance(
                                       getVirtualMachine(),
                                       new Short( db.getVersionMinor() )
                               ) :
                               null;

                    default:
                        return null;
View Full Code Here


            View nextView = startDatabase();
            checkDatabaseSanity();
            pe.increment();
            pe.dispatch();
            final Database database = Model.getDatabase();
            DefaultFieldResolver.setDatabase( database );
            if( nextView == null )
            {
                nextView = restoreLastView();
            }
View Full Code Here

                   RemoteCallException,
                   RSException,
                   RecordStoreFullException,
                   DBException
    {
        final Database database = Model.getDatabase();
        database.start();
        return ViewFactory.getMenu( "mainMenu" );
    }
View Full Code Here

        pe.dispatch();

        final StringBuffer buffer = new StringBuffer();
        final long totalMemory = Runtime.getRuntime().totalMemory() / KB;
        final long freeMemory  = Runtime.getRuntime().freeMemory() / KB;
        final Database db = Model.getDatabase();
        final long dbTotalSize = db.getTotalSize();
//        final int freeDisk = Settings.getFreeDisk();
        buffer.append( ResourceManager.getResource( "sysinfo.totalMemory" ) )
                .append( ": " )
                .append( totalMemory ).append( " Kb" )
                .append( "\n" )
View Full Code Here

TOP

Related Classes of bm.db.Database

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.