Saturday, December 25, 2010

Derby sqldump


if username : srinath password:srinath schema:srinath and server not running



dblook -d "jdbc:derby:D:\Documents and Settings\Srinath.DIGIFIRE1\.netbeans-derby\btapp;user=srinath;password=srinath" -z srinath -o mydump.sql


Generated dump

-- ============================

-- This file was created using Derby's dblook utility.
-- Timestamp: 2010-12-26 10:50:18.906
-- Source database is: D:\Documents and Settings\Srinath.DIGIFIRE1\.netbeans-derby\btapp
-- Connection URL is: jdbc:derby:D:\Documents and Settings\Srinath.DIGIFIRE1\.netbeans-derby\btapp;user=srinath;password=srinath
-- Specified schema is: srinath
-- appendLogs: false

-- ----------------------------------------------
-- DDL Statements for schemas
-- ----------------------------------------------



-- ----------------------------------------------
-- DDL Statements for tables
-- ----------------------------------------------

CREATE TABLE "SRINATH"."ITEM" ("ID" INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1), "TITLE" VARCHAR(100) DEFAULT NULL, "ICON" BLOB(2147483647), "ICONBASE64" VARCHAR(2000) DEFAULT NULL, "DESCRIPTION" VARCHAR(1000) DEFAULT NULL, "CATEGORY_ID" INTEGER, "LOCATION_ID" INTEGER);

CREATE TABLE "SRINATH"."LOCATION" ("ID" INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1), "TITLE" VARCHAR(100) DEFAULT NULL, "ICON" BLOB(2147483647), "ICONBASE64" VARCHAR(2000) DEFAULT NULL, "DESCRIPTION" VARCHAR(1000) DEFAULT NULL);

CREATE TABLE "SRINATH"."CATEGORY" ("ID" INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1), "TITLE" VARCHAR(100) DEFAULT NULL, "ICON" BLOB(2147483647), "ICONBASE64" VARCHAR(2000) DEFAULT NULL, "DESCRIPTION" VARCHAR(1000) DEFAULT NULL);

CREATE TABLE "SRINATH"."SYSTEM_USERS" ("USERNAME" VARCHAR(100) NOT NULL, "PASSWORD" VARCHAR(100) DEFAULT NULL);

-- ----------------------------------------------
-- DDL Statements for keys
-- ----------------------------------------------

-- primary/unique
ALTER TABLE "SRINATH"."LOCATION" ADD CONSTRAINT "SQL101225075907980" PRIMARY KEY ("ID");

ALTER TABLE "SRINATH"."SYSTEM_USERS" ADD CONSTRAINT "SQL101225075656450" PRIMARY KEY ("USERNAME");

ALTER TABLE "SRINATH"."ITEM" ADD CONSTRAINT "SQL101225083438700" PRIMARY KEY ("ID");

ALTER TABLE "SRINATH"."CATEGORY" ADD CONSTRAINT "SQL101225075421390" PRIMARY KEY ("ID");

-- foreign
ALTER TABLE "SRINATH"."ITEM" ADD CONSTRAINT "LOCATIONID_FK" FOREIGN KEY ("LOCATION_ID") REFERENCES "SRINATH"."LOCATION" ("ID") ON DELETE CASCADE ON UPDATE RESTRICT;

ALTER TABLE "SRINATH"."ITEM" ADD CONSTRAINT "CATEGORYID_FK" FOREIGN KEY ("CATEGORY_ID") REFERENCES "SRINATH"."CATEGORY" ("ID") ON DELETE CASCADE ON UPDATE RESTRICT;

Share Article : Derby sqldump
Share/Save/Bookmark

Friday, October 29, 2010

Configuring NetBeans for BlackBerry development







  • Install BB JDK.
  • Copy following to a file and make necessary changes. 
    <?xml version='1.0'?>
    <!DOCTYPE platform PUBLIC '-//NetBeans//DTD J2ME PlatformDefinition 1.0//EN' 
              'http://www.netbeans.org/dtds/j2me-platformdefinition-1_0.dtd'>
    <platform name="BlackBerry_JDE_421" 
              home="C:\Program Files\Research In Motion\BlackBerry JDE 4.2.1" 
              type="CUSTOM" 
              displayname="BlackBerry JDE 421" 
              srcpath="" 
              docpath="${platform.home}/docs/api," 
              preverifycmd="&quot;{platformhome}{/}bin{/}preverify&quot; 
                            {classpath|-classpath &quot;{classpath}&quot;} 
                            -d &quot;{destdir}&quot; &quot;{srcdir}&quot;" 
              runcmd="cmd /C &quot;cd /D {platformhome}{/}simulator&amp;{device}&quot;" 
              debugcmd="cmd /C &quot;cd /D {platformhome}{/}bin&amp;jdwp&quot;">
        <device name="8800" description="8800">
            <optional name="JSR75" version="1.0" 
                      displayname="File Connection and PIM Optional Packages" 
                      classpath="${platform.home}/lib/net_rim_api.jar" 
                      dependencies="" default="true"/>
            <optional name="MMAPI" version="1.0" 
                      displayname="Mobile Media API" 
                      classpath="${platform.home}/lib/net_rim_api.jar" 
                      dependencies="" default="true"/>
            <configuration name="CLDC" version="1.1" 
                           displayname="Connected Limited Device Configuration" 
                           classpath="${platform.home}/lib/net_rim_api.jar" 
                           dependencies="" default="true"/>
            <optional name="OBEX" version="1.0" 
                      displayname="Object Exchange APIs" 
                      classpath="${platform.home}/lib/net_rim_api.jar" 
                      dependencies="" default="true"/>
            <optional name="JSR82" version="1.0" 
                      displayname="Java APIs for Bluetooth Wireless Technology" 
                      classpath="${platform.home}/lib/net_rim_api.jar" 
                      dependencies="" default="true"/>
            <optional name="WMA" version="1.1" 
                      displayname="Wireless Messaging API" 
                      classpath="${platform.home}/lib/net_rim_api.jar" 
                      dependencies="" default="true"/>
            <optional name="JSR179" version="1.0" 
                      displayname="Location Based APIs" 
                      classpath="${platform.home}/lib/net_rim_api.jar" 
                      dependencies="" default="true"/>
            <optional name="JSR177" version="1.0" 
                      displayname="Security and Trust Services APIs" 
                      classpath="${platform.home}/lib/net_rim_api.jar" 
                      dependencies="" default="true"/>
            <profile name="MIDP" version="2.0" 
                     displayname="Mobile Information Device Profile" 
                     classpath="${platform.home}/lib/net_rim_api.jar" 
                     dependencies="" default="true"/>
        </device>
    </platform>
  • Save it under - C:\Documents and Settings:
    .netbeans\6.x\config\Services\Platforms\org-netbeans-api-java-Platform 
    as  BlackBerry_JDE_421.xml.
  • Restart NetBeans. 
  • Open a Mobile project and add following to build.xml (just above </project> tag)

    <target name="do-preprocess">
            <fail unless="libs.ant-contrib.classpath">
         Classpath to Ant Contrib library (libs.ant-contrib.classpath property) is not set.
            </fail>
            <taskdef resource="net/sf/antcontrib/antlib.xml">
                <classpath>
                    <pathelement path="${libs.ant-contrib.classpath}">
                </pathelement></classpath>
            </taskdef>
            <available file="${platform.home}/bin/rapc.exe" property="do.rapc">
            <if>
                <isset property="do.rapc">
                <then>
                    <property name="jpda.port" value="8000">
                    <path id="antlib.classpath">
                        <fileset dir="${user.dir}/mobility8/modules/ext/" includes="ant-contrib-1.0b3.jar">
                    </fileset></path>
                    <mkdir dir="${dist.dir}">
                    <path id="src-files">
                        <fileset dir="${src.dir}" includes="**/*.*">
                    </fileset></path>
                    <property name="srcs" value="${toString:src-files}">
                    <for delimiter=";" list="${srcs}" param="file" trim="true">
                        <sequential>
                            <echo append="true" file="${src.dir}/${name}_build.files" message="@{file}${line.separator}">
                        </echo></sequential>
                    </for>
                    <touch file="${dist.dir}/${dist.jar}">
                    <nb-overrideproperty name="buildsystem.baton" value="${preprocessed.dir}">
                </nb-overrideproperty></touch></property></mkdir></property></then>
                <else>
                    <nb-overrideproperty name="buildsystem.baton" value="${src.dir}">
                    <antcall target="${name}-impl.do-preprocess">
                </antcall></nb-overrideproperty></else>
            </isset></if>
        </available></target>
        <target name="do-compile">
            <if>
                <isset property="do.rapc">
                <then>
                    <antcall target="create-jad">
                    <antcall target="update-jad">
                    <copy file="${dist.dir}/${dist.jad}" todir="${src.dir}">
                    <exec dir="${src.dir}" executable="${platform.home}/bin/rapc.exe" failonerror="true">
                        <arg value="-quiet">
                        <arg value="import=${platform.bootclasspath};${libs.classpath}">
                        <arg value="codename=${name}">
                        <arg value="-midlet">
                        <arg value="jad=${dist.jad}">
                        <arg value="@${name}_build.files">
                    </arg></arg></arg></arg></arg></arg></exec>
                    <delete file="${basedir}/${src.dir}/${name}_build.files">
                    <copy file="${name}.alx" todir="${dist.dir}">
                    <nb-overrideproperty name="buildsystem.baton" value="${build.classes.dir}">
                </nb-overrideproperty></copy></delete></copy></antcall></antcall></then>
                <else>
                    <nb-overrideproperty name="buildsystem.baton" value="${preprocessed.dir}">
                    <antcall target="${name}-impl.do-compile">
                </antcall></nb-overrideproperty></else>
            </isset></if>
        </target>
        <target name="pre-obfuscate">
            <nb-overrideproperty name="buildsystem.baton" value="${build.classes.dir}">
        </nb-overrideproperty></target>
        <target if="do.rapc" name="post-jar">
            <move todir="${dist.dir}">
                <fileset dir="${src.dir}">
                    <include name="**/${name}*.*">
                </include></fileset>
            </move>
            <copy todir="${platform.home}/simulator" verbose="true">
                <fileset dir="${dist.dir}">
                    <include name="**/${name}*.*">
                </include></fileset>
            </copy>
        </target>
        <target name="post-clean">
            <delete failonerror="false" includeemptydirs="true">
                <fileset dir="${platform.home}/simulator">
                    <include name="**/${name}*.*">
                </include></fileset>
                <fileset dir="${dist.dir}">
                    <include name="**/*.*">
                </include></fileset>
                <fileset dir="${src.dir}">
                    <include name="**/${name}*.*">
                </include></fileset>
            </delete>
        </target>
  • Create a file called [appname].alx in the project level and copy following to it.

    <loader version="1.0">
        <application id="MobileApplication1">
            <name>
               MobileApplication1
            </name>
            <description/>
            <version>
                1.0
            </version>
            <vendor>
            </vendor>
            <copyright>
            </copyright>
            <fileset Java="1.3">
                <directory/>
                <files>
                    MobileApplication1.cod
                </files>
            </fileset>
            <application id="MobileApplication1">
                <name/>
                <description/>
                <version>
                    1.0
                </version>
                <vendor>
                    Sun Microsystems Inc.
                </vendor>
                <copyright>
                    Copyright (c) 2008 Sun Microsystems Inc.
                </copyright>


            </application>
        </application>
    </loader>
  • That's it

  • Share Article : Configuring NetBeans for BlackBerry development
    Share/Save/Bookmark

    Sunday, October 17, 2010

    Android with NetBeans


    1.Installing Plugin  for NetBeans   
    - Go to Plugins and  add following update center  
    http://kenai.com/downloads/nbandroid/updates.xml.                                                                       
    Then Select and install Android plugin.

    2.Unzip android SDK and add it as a Java Platform for NetBeans.

    3.Then you must create an Android Virtual Device (AVD).
    An AVD defines the system image and device settings used by the emulator.
    To create an AVD, use the "android" tool provided in the Android SDK.
    Open a command prompt or terminal, navigate to the tools/ directory in the
    SDK package and execute:

    android create avd --target 2 --name my_avd


    Now it's all up to NetBeans
    [If RAM is full it will say "Device’s package manager not ready to install new packages" at
    the deployment time, close some app of PC and give some RAM]
                 

    Share Article : Android with NetBeans
    Share/Save/Bookmark

    Wednesday, October 13, 2010

    Oracle Jobs, user and privileges


    How Jobs Execute

    Jnnn processes execute jobs. To execute a job, the process creates a session to run the job. When a Jnnn process runs a job, the job is run in the same environment in which it was submitted and with the owner's default privileges. The owner must be explicitly granted the necessary object privileges for all objects referenced within the job definition.
    When you force a job to run using the procedure DBMS_JOB.RUN, the job is run by your user process and with your default privileges only. Privileges granted to you through roles are unavailable. You must be explicitly granted the necessary object privileges for all objects referenced within the job definition.

    Share Article : Oracle Jobs, user and privileges
    Share/Save/Bookmark

    Tuesday, September 28, 2010

    String Concat function-Oracle ( similar usage to SUM)



    SELECT deptno, wm_concat(ename) AS employees
    FROM   emp
    GROUP BY deptno;
    
    Result -----> 
        DEPTNO EMPLOYEES
    ---------- --------------------------------------------------
            10 CLARK,KING,MILLER
            20 SMITH,FORD,ADAMS,SCOTT,JONES
            30 ALLEN,BLAKE,MARTIN,TURNER,JAMES,WARD
    
    
    
    
    
    Base Data:
    
        DEPTNO ENAME
    ---------- ----------
            20 SMITH
            30 ALLEN
            30 WARD
            20 JONES
            30 MARTIN
            30 BLAKE
            10 CLARK
            20 SCOTT
            10 KING
            30 TURNER
            20 ADAMS
            30 JAMES
            20 FORD
            10 MILLER
    
    
    
    
    For Oracle 9 --> as wm_concat() function is not available use following custom function. 
    CREATE OR REPLACE FUNCTION get_it (invoice in VARCHAR2)
      RETURN VARCHAR2
    IS
      l_text  VARCHAR2(32767) := NULL;
    BEGIN
      FOR cur_rec IN (SELECT x AS itemName FROM invoice_breakdown where invoice_no = invoice /*query returning multiple rows*/) LOOP
        l_text := l_text || ',' || cur_rec.itemName;
      END LOOP;
      RETURN LTRIM(l_text, ',');
    END;
    /
    SHOW ERRORS

    Share Article : String Concat function-Oracle ( similar usage to SUM)
    Share/Save/Bookmark

    Tuesday, August 3, 2010

    Check if String Contains a certain Substring


    String string = "Madam, I am Adam"

    // Starts with 
    boolean b = string.startsWith("Mad"); 
    // true 

    // Ends with 
    b = string.endsWith("dam"); 
    // true 

    // Anywhere 
    b = string.indexOf("I am") > 0; 
    // true 


    // To ignore case, regular expressions must be used 
    // Starts with 
    b = string.matches("(?i)mad.*"); 

    // Ends with 
    b = string.matches("(?i).*adam"); 

    // Anywhere 
    b = string.matches("(?i).*i am.*");


    //
    .replaceAll("\\W", ""); replace all non-alphanumerics

    Share Article : Check if String Contains a certain Substring
    Share/Save/Bookmark

    Monday, July 26, 2010

    Auto Incrementing primary key with Oracle




    SQL> CREATE TABLE test
    (id NUMBER PRIMARY KEY,
    name VARCHAR2(30));

    Table created.

    SQL> CREATE SEQUENCE test_sequence
    START WITH 1
    INCREMENT BY 1;

    Sequence created.

    Now we can use that sequence in an BEFORE INSERT trigger on the table.

    CREATE OR REPLACE TRIGGER test_trigger
    BEFORE INSERT
    ON test
    REFERENCING NEW AS NEW
    FOR EACH ROW
    BEGIN
    SELECT test_sequence.nextval INTO :NEW.ID FROM dual;
    END;

    Trigger created.

    Share Article : Auto Incrementing primary key with Oracle
    Share/Save/Bookmark

    Wednesday, July 21, 2010

    JSTL [S]crap


    Iterating ArrayList of Arrays



    <c:foreach items="${list}" var="innerList">
    <c:foreach items="${innerList}" var="item">
    <c:out value="${item}"></c:out>|

    </c:foreach> <br>

    </c:foreach>

    Share Article : JSTL [S]crap
    Share/Save/Bookmark

    Wednesday, February 10, 2010

    MySql Tips


    Loading data from a text file :
    LOAD DATA INFILE 'aino.txt' INTO TABLE products_options_values (products_options_values_name);
     
    (Text file is read from the database directory of the default database)

    Removing spaces :
    update products_options_values set products_options_values_name = REPLACE(products_options_values_name,' ' ,'');
    

    Share Article : MySql Tips
    Share/Save/Bookmark

    Friday, January 15, 2010

    Solar Eclipse





    Share Article : Solar Eclipse
    Share/Save/Bookmark