Enlightensoft's Blog

Helping in your each step

  • Categories

  • Authors

Author Archive

How to use/connect database from mysql command prompt

Posted by Pankil Patel on May 17, 2012

Note: Please make sure that you have checked the command prompt feature during mysql installation.

Step 1: type “cmd” into your run window of your OS

Step 2: type below command into your cmd terminal

>mysql -h localhost -u root -p

it will ask for passwod like below

Enter password: ****

you need to give password and after that press enter key.

Step 3: now it will give mysql> terminal initial, When you see mysql> it means from a MySQL prompt after successful logging into MySQL using “localhost” as a host and “root” as a user.

Step 4: Now perform any database commands into your database by creating / selecting your database.

Ex:

mysql> create database mytest;
Query OK, 1 row affected (0.00 sec)

mysql> use mytest;
Database changed
mysql>

Posted in Database, MySQL | Leave a Comment »

How to Configure MAVEN

Posted by Pankil Patel on May 16, 2012

Step 1: Download Maven zip from http://maven.apache.org/download.html (Ex: apache-maven-3.0.4-bin.zip)

Step 2: Unzip it into your drive (Ex: C:\java\apache-maven-3.0.4)

Step 3: Add system environment variables M2_HOME & M2 (Ex: M2_HOME=C:\java\apache-maven-3.0.4 & M2=C:\java\apache-maven-3.0.4\bin)

Step 4: Add M2 into your PATH system environment variable  (Ex: PATH=%M2%;%JAVA_HOME%\bin;%ANT_HOME%\bin)

Step 5: Set your MAVEN repository location :

  • Open file C:\java\apache-maven-3.0.4\conf\settings.xml for edit
  • uncomment <localRepository> tag in settings.xml file and set the repository location like below:<localRepository>C:\java\apache-maven-3.0.4\.m2\repository</localRepository>

Step 6: Verify your set up by typing command: mvn –version into your command prompt window.

It should give detail of your mvn like below:

C:\Documents and Settings\pankil.patel>mvn –version
Apache Maven 2.2.1 (r801777; 2009-08-07 00:46:01+0530)
Java version: 1.6.0_23
Java home: C:\java\jdk1.6.0_23\jre
Default locale: en_US, platform encoding: Cp1252
OS name: “windows xp” version: “5.1″ arch: “x86″ Family: “windows”
C:\Documents and Settings\pankil.patel>

You are now ready to use your MAVEN for your project…….

 

Posted in Maven | Leave a Comment »

Eclipse PlugIn For SVN, FIND BUG, MAVEN, PMD & CheckStyle

Posted by Pankil Patel on May 15, 2012

Eclipse & Oracle Workshop for WebLogic Plug-In For SVN, FIND BUG, MAVEN, PMD & CheckStyle

CheckStyle: http://eclipse-cs.sf.net/update/

SVN: http://subclipse.tigris.org/update_1.0.x or http://subclipse.tigris.org/update_1.6.x or http://subclipse.tigris.org/update_1.8.x

FIND BUG: http://findbugs.cs.umd.edu/eclipse

PMD: http://pmd.sourceforge.net/eclipse

MAVEN: http://m2eclipse.sonatype.org/sites/archives/m2e-0.10.0-20100209-0800/

Posted in IDE, Other | Leave a Comment »

Nth Highest record in Oracle

Posted by Pankil Patel on April 18, 2012

First solution:

nth highest record from Bv_Category table based on Indvl_Rank_Id

select * From
(
Select C.*, Dense_Rank() Over (Order By C.Indvl_Rank_Id Desc) Ranking From Bv_Category C
)
where Ranking = (nth index)

Example: Record with Second Highest Indvl_Rank_Id

select * From
(
Select C.*, Dense_Rank() Over (Order By C.Indvl_Rank_Id Desc) Ranking From Bv_Category C
)
where Ranking = 2

For more detail visit:

http://www.oratable.com/nth-highest-salary-in-oracle/

Second solution:

Example: Second Highest Indvl_Rank_Id

Select Min(Indvl_Rank_Id) From (
select * from (
Select Unique Indvl_Rank_Id From
Bv_Category
ORDER BY Indvl_Rank_Id DESC) where ROWNUM <= 2)

Posted in Database, Oracle | Tagged: , | Leave a Comment »

Hibernate Automatic Dirty Check for Detached Objects

Posted by Pankil Patel on April 18, 2012

To deal with Dirty check for detached objects in Hibernate there are two ways:

1) Use select-before-update=”true” mapping into your .hbm.xml file:

<class name=”com…….AbcVO”
table=”ABC” select-before-update=”true”>

2) By extending some of its public API:

http://www.brimllc.com/2010/08/hibernate-automatic-dirty-check-for-detached-objects/

Posted in Hibernate | Leave a Comment »

SubSelect in hbm.xml file

Posted by Pankil Patel on April 16, 2012

<class name=”com……StaffView”
entity-name=”staff_phase2_with_Inactive”>
<subselect>
<![CDATA[
SELECT DISTINCT u.ID,
u.FIRST_NM,
u.LAST_NM,
u.MIDDLE_INIT_NM,
u.FULL_NM,
u.PRFRRD_FRST_NM,
u.STTS_CD,
u.STTS_NM
FROM USER_TABLE u
]]>
</subselect>
<id name=”staffSID” type=”string” length=”28″>
<column name=”ID” />
<generator />
</id>
<property …

.

.

.

.

.

.
</property>
</class>

Posted in Hibernate | Leave a Comment »

jPub Object Generation Command

Posted by Pankil Patel on January 11, 2012

set path=%path%.;C:\oracle\product\10.2.0\client_1\BIN;

set classpath=%classpath%;.;C:\oracle\product\10.2.0\client_1\sqlj\lib\runtime12.jar;C:\oracle\product\10.2.0\client_1\sqlj\lib\translator.jar;C:\oracle\product\10.2.0\client_2\jdbc\lib\ojdbc14.jar;c:\xmlparserv2.jar;C:\oracle\product\10.2.0\client_1\sqlj\lib\runtime12ee

jpub -url=jdbc:oracle:thin:@<HostName>:15000/<service name> -user=username/password -omit_schema_names -package=co.cc.enlightensoft.demo.vote.db.dto -sql=BV_OBJ_FIRM_ARRARY_TAB:UserDBDto -tostring=true -dir=C:\jpub

Posted in Database, Oracle | Leave a Comment »

How to add where clouse into xml.hbm mapping file

Posted by Pankil Patel on November 13, 2011

For many-to-one:

<many-to-one name=”rankTypeLookupData”
formula=”(SELECT l.LKP_ID FROM EQ_LOOKUP_DATA l WHERE l.DROPDOWN_CODE = ‘BV_STAFF_RANK_TYPE’ AND l.LKP_KEY = INDVL_RANK_TYPE)”
class=”com……LookupData” not-found=”ignore”>
<column name=”INDVL_RANK_TYPE” />
</many-to-one>

For one-to-many:

<set name=”regionList” table=”BV_REGION” cascade=”all” fetch=”join”
outer-join=”true” where=”DEL_IN = ‘N’” inverse=”true”>
<key column=”INDVL_RANK_ID” />
<one-to-many
class=”com……..StaffTeamRankRegion” />
</set>

Posted in Hibernate | Leave a Comment »

Issue with createCriteria result set, class name appended by _$$_javassist_

Posted by Pankil Patel on November 8, 2011

Issue:  _$$_javassist_ is appended after class name, when you are using createCriteria(xyz.class) which have <set> or <bag> (one-to-many) relationship with Object that having <composite-id> instead of <id>.

Resolution: Instead of Using createCriteria(xyz.class), use EntityName for Criteria Query.

Ex: DetachedCriteria detachedCriteria = DetachedCriteria.forEntityName(“xyzSearch”);

Impact of Issue:

  1. For java, if you are using any code which have  comparison with class name it will fail in that case.
  2. If you are using any communication by RMI like: Spring BlazeDS for Flex & Java, It will not able to cast the Object in proper format & will give result in generics Object format.

Posted in Hibernate | Leave a Comment »

How to use sequence in ID tag of hbm.xml???

Posted by Pankil Patel on September 26, 2011

How to use sequence in ID tag of hbm.xml???

<id name=“id” type=“java.lang.Long” column=“ID”>

<generatorclass=“sequence”><paramname=“sequence”>XYZ_TAG_STAFF_SEQ</param></generator>

</id>

Posted in Hibernate | Leave a Comment »

 
Follow

Get every new post delivered to your Inbox.