Friday, July 31, 2009

Free project management Software Links

VIEW PATH

XML & XSL Advance Example

<?xml version='1.0'?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" omit-xml-declaration="yes"/>

<xsl:template match="/">
<xsl:apply-templates select="GeneralReport/Carlines/Carline/Prices"/>
<xsl:apply-templates select="GeneralReport/Prices"/>
</xsl:template>

<xsl:template match="Prices">
<xsl:apply-templates select="LocalReport"/>
<xsl:apply-templates select="DomesticOptionPrice"/>
<xsl:apply-templates select="ExportModelPrice"/>
<xsl:apply-templates select="ExportOptionPrice"/>
</xsl:template>

<xsl:template match="DomesticOptionPrice">
<xsl:for-each select="Models/Model">
<xsl:apply-templates select="Code"/>
<xsl:apply-templates select="../../Code"/>
<xsl:apply-templates select="../../ORS"/>
<xsl:apply-templates select="Name"/>
<xsl:apply-templates select="../../Name"/>
<xsl:apply-templates select="../../MSRP"/>
<xsl:apply-templates select="../../MSRPNet"/>
<xsl:apply-templates select="../../DealerNet"/>
<xsl:apply-templates select="../../Taxes"/>
<xsl:apply-templates select="../../EffectiveDate"/>
<xsl:apply-templates select="../../MY"/>
<xsl:apply-templates select="../../MYS"/>
<xsl:apply-templates select="../../Carline"/>
<xsl:apply-templates select="../../DealerIndex"/>
<xsl:apply-templates select="../../Currency"/>
<xsl:if test="not(position()=last())">
<xsl:call-template name="newline"/>
</xsl:if>
</xsl:for-each>
<xsl:if test="not(position()=last())">
<xsl:call-template name="newline"/>
</xsl:if>
</xsl:template>

<xsl:template match="ExportOptionPrice">
<xsl:for-each select="Models/Model">
<xsl:apply-templates select="Code"/>
<xsl:apply-templates select="../../Code"/>
<xsl:apply-templates select="../../ORS"/>
<xsl:apply-templates select="Name"/>
<xsl:apply-templates select="../../Name"/>
<xsl:apply-templates select="../../PlantPrice"/>
<xsl:text>+000000000</xsl:text>
<xsl:text>+000000000</xsl:text>
<xsl:apply-templates select="../../Taxes"/>
<xsl:apply-templates select="../../EffectiveDate"/>
<xsl:apply-templates select="../../MY"/>
<xsl:apply-templates select="../../MYS"/>
<xsl:apply-templates select="../../Carline"/>
<xsl:apply-templates select="../../DealerIndex"/>
<xsl:apply-templates select="../../Currency"/>
<xsl:if test="not(position()=last())">
<xsl:call-template name="newline"/>
</xsl:if>
</xsl:for-each>
<xsl:if test="not(position()=last())">
<xsl:call-template name="newline"/>
</xsl:if>
</xsl:template>


<xsl:template match="LocalReport">
<xsl:apply-templates select="Models/Model/Code"/>
<!-- 10 blanks for Option Code -->
<xsl:text> </xsl:text>
<xsl:apply-templates select="ORS"/>
<xsl:apply-templates select="Models/Model/Name"/>
<!-- 40 blanks for Option Name -->
<xsl:text> </xsl:text>
<xsl:apply-templates select="MSRP"/>
<xsl:apply-templates select="MSRPNet"/>
<xsl:apply-templates select="DealerNet"/>
<xsl:apply-templates select="Taxes"/>
<xsl:apply-templates select="EffectiveDate"/>
<xsl:apply-templates select="MY"/>
<xsl:apply-templates select="MYS"/>
<xsl:apply-templates select="Carline"/>
<xsl:apply-templates select="DealerIndex"/>
<xsl:apply-templates select="Currency"/>
<xsl:call-template name="newline"/>
</xsl:template>

<xsl:template match="ExportModelPrice">
<xsl:apply-templates select="Models/Model/Code"/>
<!-- 10 blanks for Option Code -->
<xsl:text> </xsl:text>
<xsl:apply-templates select="ORS"/>
<xsl:apply-templates select="Models/Model/Name"/>
<!-- 40 blanks for Option Name -->
<xsl:text> </xsl:text>
<xsl:apply-templates select="PlantPrice"/>
<xsl:text>+000000000</xsl:text>
<xsl:text>+000000000</xsl:text>
<xsl:apply-templates select="Taxes"/>
<xsl:apply-templates select="EffectiveDate"/>
<xsl:apply-templates select="MY"/>
<xsl:apply-templates select="MYS"/>
<xsl:apply-templates select="Carline"/>
<xsl:apply-templates select="DealerIndex"/>
<xsl:apply-templates select="Currency"/>
<xsl:call-template name="newline"/>
</xsl:template>



<xsl:template name="fillBefore">
<xsl:param name="objectString"/>
<xsl:param name="numberOfChars"/>
<xsl:param name="fillCharacter"/>
<xsl:variable name="size" select="string-length($objectString)"/>
<xsl:choose>
<xsl:when test="$size < $numberOfChars">
<xsl:call-template name="fillBefore">
<xsl:with-param name="objectString"><xsl:value-of select="concat($fillCharacter, $objectString)"/></xsl:with-param>
<xsl:with-param name="numberOfChars"><xsl:value-of select="$numberOfChars"/></xsl:with-param>
<xsl:with-param name="fillCharacter"><xsl:value-of select="$fillCharacter"/></xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:when test="$size > $numberOfChars">
<xsl:value-of select="substring($objectString,1,$numberOfChars)"/>
<!-- todo : better solution needed here -->
<!-- <xsl:message terminate="yes">ObjectString is too long</xsl:message> -->
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$objectString"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

<xsl:template name="fillAfter">
<xsl:param name="objectString"/>
<xsl:param name="numberOfChars"/>
<xsl:param name="fillCharacter"/>
<xsl:variable name="size" select="string-length($objectString)"/>
<xsl:choose>
<xsl:when test="$size < $numberOfChars">
<xsl:call-template name="fillAfter">
<xsl:with-param name="objectString"><xsl:value-of select="concat($objectString,$fillCharacter)"/></xsl:with-param>
<xsl:with-param name="numberOfChars"><xsl:value-of select="$numberOfChars"/></xsl:with-param>
<xsl:with-param name="fillCharacter"><xsl:value-of select="$fillCharacter"/></xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:when test="$size > $numberOfChars">
<xsl:value-of select="substring($objectString,1,$numberOfChars)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$objectString"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>


<!-- leave this as it was made, it is essential for the newline -->
<xsl:template name="newline">
<xsl:text>
</xsl:text>
</xsl:template>



<xsl:template match="Code">
<xsl:call-template name="fillAfter">
<xsl:with-param name="objectString"><xsl:value-of select="."/></xsl:with-param>
<xsl:with-param name="numberOfChars">10</xsl:with-param>
<xsl:with-param name="fillCharacter"><xsl:text> </xsl:text></xsl:with-param>
</xsl:call-template>
</xsl:template>

<xsl:template match="Model">
<xsl:call-template name="fillAfter">
<xsl:with-param name="objectString"><xsl:value-of select="."/></xsl:with-param>
<xsl:with-param name="numberOfChars">10</xsl:with-param>
<xsl:with-param name="fillCharacter"><xsl:text> </xsl:text></xsl:with-param>
</xsl:call-template>
</xsl:template>

<xsl:template match="MSRP | MSRPNet | DealerNet | PlantPrice">
<xsl:choose>
<xsl:when test="@sign">
<xsl:variable name="price" select="."/>
<xsl:call-template name="getPrice">
<xsl:with-param name="value" select="substring-after($price,'-')"/>
</xsl:call-template>
<xsl:value-of select="@sign"/>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="getPrice">
<xsl:with-param name="value" select="."/>
</xsl:call-template>
<xsl:text>+</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

<xsl:template name="getPrice">
<xsl:param name="value"/>
<xsl:choose>
<xsl:when test="not(contains($value,'.'))">
<xsl:text>000000000</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="before">
<xsl:call-template name="fillBefore">
<xsl:with-param name="objectString"><xsl:value-of select="substring-before($value,'.')"/></xsl:with-param>
<xsl:with-param name="numberOfChars">7</xsl:with-param>
<xsl:with-param name="fillCharacter"><xsl:text>0</xsl:text></xsl:with-param>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="after" select="substring-after($value,'.')"/>
<xsl:value-of select="concat($before, $after)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

<xsl:template name="getTax">
<xsl:param name="value"/>
<xsl:choose>
<xsl:when test="not(contains($value,'.'))">
<xsl:text>000000</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="before">
<xsl:call-template name="fillBefore">
<xsl:with-param name="objectString"><xsl:value-of select="substring-before($value,'.')"/></xsl:with-param>
<xsl:with-param name="numberOfChars">3</xsl:with-param>
<xsl:with-param name="fillCharacter"><xsl:text>0</xsl:text></xsl:with-param>
</xsl:call-template>
</xsl:variable>
<!-- BugFix #287 - eVPS-2006-03: format the Tax values to 3 digital places before the point and 3 after -->
<xsl:variable name="after_long">
<xsl:value-of select="substring-after($value,'.')"/>
</xsl:variable>
<xsl:variable name="after">
<xsl:value-of select="substring($after_long,1,3)"/>
</xsl:variable>
<xsl:value-of select="concat($before, $after)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

<xsl:template name="getSpecialTaxAmount">
<xsl:param name="value"/>
<xsl:choose>
<xsl:when test="not(contains($value,'.'))">
<xsl:text>+000000000</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="minsign">
<xsl:if test="(contains($value,'-'))">
<xsl:text>-</xsl:text>
</xsl:if>
<xsl:if test="not(contains($value,'-'))">
<xsl:text>+</xsl:text>
</xsl:if>
</xsl:variable>
<xsl:variable name="removeminus">
<xsl:if test="(contains($value,'-'))">
<xsl:value-of select="substring-after($value,'-')"/>
</xsl:if>
<xsl:if test="not(contains($value,'-'))">
<xsl:value-of select="string($value)"/>
</xsl:if>
</xsl:variable>
<xsl:variable name="before">
<xsl:call-template name="fillBefore">
<xsl:with-param name="objectString"><xsl:value-of select="substring-before($removeminus,'.')"/></xsl:with-param>
<xsl:with-param name="numberOfChars">7</xsl:with-param>
<xsl:with-param name="fillCharacter"><xsl:text>0</xsl:text></xsl:with-param>
</xsl:call-template>
</xsl:variable>

<xsl:variable name="after_long">
<xsl:value-of select="substring-after($before,'.')"/>
</xsl:variable>
<xsl:variable name="after">
<xsl:value-of select="substring($before,1,2)"/>
</xsl:variable>
<xsl:value-of select="concat($minsign,$before, $after)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

<xsl:template match="EffectiveDate">
<xsl:variable name="date" select="."/>
<xsl:value-of select="substring($date, 1, 2)"/>
<xsl:value-of select="substring($date, 4, 2)"/>
<xsl:value-of select="substring($date, 7, 4)"/>
</xsl:template>


<xsl:template match="ORS">
<xsl:call-template name="fillAfter">
<xsl:with-param name="objectString"><xsl:value-of select="."/></xsl:with-param>
<xsl:with-param name="numberOfChars">25</xsl:with-param>
<xsl:with-param name="fillCharacter"><xsl:text> </xsl:text></xsl:with-param>
</xsl:call-template>
</xsl:template>

<!--
<xsl:template match="Name">

</xsl:template>
-->

<xsl:template match="Name">
<xsl:call-template name="fillAfter">
<xsl:with-param name="objectString"><xsl:value-of select="."/></xsl:with-param>
<xsl:with-param name="numberOfChars">40</xsl:with-param>
<xsl:with-param name="fillCharacter"><xsl:text> </xsl:text></xsl:with-param>
</xsl:call-template>
</xsl:template>

<xsl:template match="Taxes">
<xsl:call-template name="getTax">
<xsl:with-param name="value" select="./SpecialTax"/>
</xsl:call-template>
<xsl:call-template name="getTax">
<xsl:with-param name="value" select="./Tax"/>
</xsl:call-template>

<xsl:call-template name="getSpecialTaxAmount">
<xsl:with-param name="value" select="./SpecialTaxAmount"/>
</xsl:call-template>


</xsl:template>

<xsl:template match="Carline">
<xsl:value-of select="substring(.,1,2)"/>
</xsl:template>

</xsl:stylesheet>




<!-- Stylus Studio meta-information - (c)1998-2001 eXcelon Corp.
<metaInformation>
<scenarios ><scenario default="yes" name="toExport" userelativepaths="yes" url="..\results\Kopie von sample.xml" htmlbaseurl="" processortype="internal" commandline="" additionalpath="" additionalclasspath="" postprocessortype="none" postprocesscommandline="" postprocessadditionalpath="" postprocessgeneratedext=""/></scenarios><MapperInfo srcSchemaPath="" srcSchemaRoot="" srcSchemaPathIsRelative="yes" destSchemaPath="" destSchemaRoot="" destSchemaPathIsRelative="yes" />
</metaInformation>
-->


============================
XML Data
============================
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="export.xsl"?>
<GeneralReport module="Domestic">
<Meta>
<User>TZG136</User>
<CreationDate>31.07.2009</CreationDate>
<CreationTime>15:16</CreationTime>
<Comment></Comment>
<SelectionCriteria>
<LegalEntityName>Austria</LegalEntityName>
<Carline>Agila</Carline>
<MY>2</MY>
<MYS>A</MYS>
<DealerIndex>000</DealerIndex>
<Currency>EUR</Currency>
<EffectiveDate>= 14.12.2001</EffectiveDate>
<ModelPrices>true</ModelPrices>
<Model>0HF68</Model>
<Option>*</Option>
<OptionIndicator>M</OptionIndicator>
<Active>true</Active>
<ORS apply="false">*</ORS>
</SelectionCriteria>
</Meta>
<AllModels>
<Model>0HF68</Model>
<Model>0HL68</Model>
<Model>0HN68</Model>
<Model>0HP68</Model>
</AllModels>
<Models>
<Model>0HF68</Model>
</Models>
<Prices>
<LocalReport>
<LegalEntityName>Austria</LegalEntityName>
<OptionIndicator>M</OptionIndicator>
<Carline>Agila</Carline>
<Code></Code>
<Name></Name>
<Models>
<Model>
<Code>0HF68</Code>
<Name>Agila Agila 5</Name>
</Model>
</Models>
<MY>2</MY>
<MYS>A</MYS>
<EffectiveDate>14.12.2001</EffectiveDate>
<DealerIndex>000</DealerIndex>
<MSRP sign="-">-90.00</MSRP>
<MSRPNet sign="-">-182.73</MSRPNet>
<DealerNet sign="-">-182.73</DealerNet>
<TransferPrice sign="-">-183.00</TransferPrice>
<Currency>EUR</Currency>
<ORS></ORS>
<Taxes>
<Tax>0.0000</Tax>
<SpecialTax>10.0000</SpecialTax>
<SpecialTaxAmount>500.00</SpecialTaxAmount>
</Taxes>
</LocalReport>
</Prices>
</GeneralReport>

Wednesday, July 29, 2009

PHP MYSQL APACHE Installation

Hi

Please Use the below link Which gives you the details information about PHP MYSQL APACHE Installation


Click Here Download Link - PHP MYSQL APACHE Installation instruction

After you install PHP - You can install HEIDSQL which is MYSQL front END.
Click Here Download Link : HEIDSQL - MYSQL Front End

Wednesday, July 15, 2009

Needs Answers :

1.How to retrieve values from Oracle's ref cursor using java Program.?

Thursday, July 9, 2009

Oracle Types access through Java Object

package com.oracleObjects.AcessOracleObjects;


import java.io.IOException;

import java.sql.*;
import java.util.List;
import java.util.Properties;

import oracle.sql.STRUCT;
import oracle.sql.StructDescriptor;
/**
* @author tzg136
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class AcessOracleObjectsUsingJava_EMP {
Connection conn = null;
String driverName ="";
String serverName = "";
String username ="";
String password = "";

String portNumber ="";
String sid = "";
String databaseName = "";

public AcessOracleObjectsUsingJava_EMP()
{
Properties configFile = new Properties();
try {
configFile.load(AcessOracleObjectsUsingJava_EMP.class.getClassLoader().getResourceAsStream("config.properties"));
driverName =configFile.getProperty("driverName");
serverName = configFile.getProperty("serverName");
username =configFile.getProperty("username");
password = configFile.getProperty("password");
portNumber =configFile.getProperty("portNumber");
sid = configFile.getProperty("sid");
databaseName = configFile.getProperty("databaseName");

} catch (IOException e) {
e.printStackTrace();
}


}
public Connection getConnection()
{
try
{
Class.forName(driverName);
String url = "jdbc:oracle:thin:@" + serverName + ":" + portNumber + ":" + sid;
conn = DriverManager.getConnection(url, username, password);
System.out.println("Connected Sucessfully");

}
catch (ClassNotFoundException e) {
System.out.println("ClassNotFoundException "+e.getMessage());

} catch (SQLException e) {
System.out.println("SQl Syntaxt Error "+e.getMessage());

}
catch (Exception e) {
System.out.println("Exception "+e.getMessage());

}
return conn;
}
public void insertTableObjectValue(Emp objEmp)
{
try {
Object objArray[] = new Object[4];
objArray[0] = objEmp.getEmp_id();
objArray[1] = objEmp.getEmp_Name();
objArray[2] = objEmp.getAge();
objArray[3] = new Integer(objEmp.getSalary());

StructDescriptor colStructDesc = StructDescriptor.createDescriptor("OBJ_TYPE_EMP", conn);

oracle.sql.STRUCT colStruct = new STRUCT(colStructDesc,conn, objArray);

PreparedStatement prepa_stmt= conn.prepareStatement( "INSERT INTO TABLE_EMP_OBJ VALUES (?)");
prepa_stmt.setObject(1,colStruct); // Bind the Java Object to the above Statement ps.executeUpdate();
prepa_stmt.executeUpdate();


} catch (SQLException e) {
System.out.println("SQLException"+ e.getMessage());
}
catch (Exception e) {
System.out.println("Exception"+ e.getMessage());
}
}



public void createTableWithObject()
{
/*
*
* CREATE TYPE OBJ_TYPE_EMP as OBJECT (
EMP_ID VARCHAR2(40),
EMP_NAME VARCHAR2(40),
AGE VARCHAR2(10) ,
SALARY NUMBER )

CREATE TABLE TABLE_EMP_OBJ (ObjEmp OBJ_TYPE_EMP )
*/
}

public void selectTableObjectValue()
{
try {



Statement stmt = conn.createStatement();

// Select rows from object1_table
ResultSet resultSet = stmt.executeQuery("SELECT * FROM TABLE_EMP_OBJ");

// OracleResultSet resultSet = (OracleResultSet)pst.executeQuery();

java.util.Hashtable mymap = new java.util.Hashtable();
Class obj = Class.forName("com.oracleObjects.AcessOracleObjects.Emp");
// Map the loaded java class to the object-type
mymap.put ("OBJ_TYPE_EMP", obj);

// Get the OBJECT values from each row
while (resultSet.next())
{
Emp objEmp;
objEmp = (Emp)resultSet.getObject(1, mymap);
System.out.println(""+objEmp.getEmp_Name());
System.out.println(""+objEmp.getAge());
}


}
catch (SQLException e) {
System.out.println("SQLException"+ e.getMessage());
e.printStackTrace();
}
catch (Exception e) {
System.out.println("Exception"+ e.getMessage());
}
}
public void closeConnection()
{
try
{
conn.close();
}
catch (Exception e) {
System.out.println("Exception"+ e.getMessage());
}

}



public static void main(String[] args) {
AcessOracleObjectsUsingJava_EMP objAccessJavaObject= new AcessOracleObjectsUsingJava_EMP();
Emp objEmp= new Emp();
objEmp.setEmp_id("1000");
objEmp.setEmp_Name("Andrew");
objEmp.setAge("34");
objEmp.setSalary(500);


Connection conn= objAccessJavaObject.getConnection();
if(args[0].equalsIgnoreCase("I"))
{
objAccessJavaObject.insertTableObjectValue(objEmp);
}
if(args[0].equalsIgnoreCase("S"))
{
objAccessJavaObject.selectTableObjectValue();
}

objAccessJavaObject.closeConnection();

}
}

Tuesday, July 7, 2009

Oracle Object Types - Java Implementation

Please find the code which has the implementation of inserting values in Oracle Objects and table.

CREATE TYPE product_detail_info AS object (product_detail_id VARCHAR(30), product_name VARCHAR(30),product_rate NUMBER)
CREATE TYPE product_type AS object (product_type_id VARCHAR(30), product_type_Name VARCHAR(30),obj_product_detail_info product_detail_info )
CREATE TABLE Electronics_Products(Electronics_Products_id VARCHAR(30), Electronics_Products_name VARCHAR(30),obj_product_type product_type)

Note :
While running this program Please give args[0] value as below
I- I - Insert
II- C - create Object and Table
III- S - Select

Java Code :


package com.oracleObjects.AcessOracleObjects;


import java.io.IOException;
import java.math.BigDecimal;
import java.sql.*;
import java.util.Properties;
/**
* @author tzg136
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class AcessOracleObjects_ElectronicsItem {
Connection conn = null;
String driverName ="";
String serverName = "";
String username ="";
String password = "";

String portNumber ="";
String sid = "";
String databaseName = "";

public AcessOracleObjects_ElectronicsItem()
{
Properties configFile = new Properties();
try {
configFile.load(AcessOracleObjects_ElectronicsItem.class.getClassLoader().getResourceAsStream("config.properties"));
driverName =configFile.getProperty("driverName");
serverName = configFile.getProperty("serverName");
username =configFile.getProperty("username");
password = configFile.getProperty("password");
portNumber =configFile.getProperty("portNumber");
sid = configFile.getProperty("sid");
databaseName = configFile.getProperty("databaseName");

} catch (IOException e) {
e.printStackTrace();
}


}
public Connection getConnection()
{
try
{
Class.forName(driverName);
String url = "jdbc:oracle:thin:@" + serverName + ":" + portNumber + ":" + sid;
conn = DriverManager.getConnection(url, username, password);
System.out.println("Connected Sucessfully");

}
catch (ClassNotFoundException e) {
System.out.println("ClassNotFoundException "+e.getMessage());
} catch (SQLException e) {
System.out.println("SQl Syntaxt Error "+e.getMessage());
}
catch (Exception e) {
System.out.println("Exception "+e.getMessage());
}
return conn;
}
public void insertTableObjectValue()
{
try {
// Create an oracle.sql.ARRAY object to hold the values
Statement stmt = conn.createStatement();
//CREATE TYPE product_detail_info AS object (product_detail_id VARCHAR(30), product_name VARCHAR(30),product_rate NUMBER)
//product_detail_info('TV_FLAT21_001' , '21 Inch Flat TV ' ,2000 )
String product_detail_info_sql = "product_detail_info('D.Info TV_FLAT21_001' , '21 Inch Flat TV ' ,2000 )";

// CREATE TYPE product_type AS object (product_type_id VARCHAR(30), product_type_Name VARCHAR(30),obj_product_detail_info product_detail_info )
// product_type (product_type_id , product_type_Name,product_detail_info_sql )
String product_type_sql= "product_type( 'TV', 'This contains TV',("+product_detail_info_sql+"))";

//CREATE TABLE Electronics_Products(Electronics_Products_id VARCHAR(30), Electronics_Products_name VARCHAR(30),obj_product_type product_type)
//Electronics_Products(Electronics_Products_id, Electronics_Products_name ,product_type_sql)
String Electronics_Products_sql = "INSERT INTO Electronics_Products VALUES('ELE_item','this Elec items',"+product_type_sql+")";

// Insert a row with values for both the object1 and object2 types
System.out.println("SQL is = \n"+Electronics_Products_sql);
int row = stmt.executeUpdate(Electronics_Products_sql);
System.out.println("Row Count"+row);
//stmt.execute("INSERT INTO object1_table VALUES(1, object1('str1', object2('obj2str1', 123)))");

} catch (SQLException e) {
System.out.println("SQLException"+ e.getMessage());
}
catch (Exception e) {
System.out.println("Exception"+ e.getMessage());
}
}
public void createTableWithObject()
{
try {
// Create an oracle.sql.ARRAY object to hold the values
// Create a statement
Statement stmt = conn.createStatement();
String prod_de_in= "CREATE TYPE product_detail_info AS object (product_detail_id VARCHAR(30), product_name VARCHAR(30),product_rate NUMBER)";
// Create the object2 type
stmt.execute(prod_de_in);
String prod_type= "CREATE TYPE product_type AS object (product_type_id VARCHAR(30), product_type_Name VARCHAR(30),obj_product_detail_info product_detail_info )";
stmt.execute(prod_type);
String elect_Prod= "CREATE TABLE Electronics_Products(Electronics_Products_id VARCHAR(30), Electronics_Products_name VARCHAR(30),obj_product_type product_type)";
stmt.execute(elect_Prod);
// Create a table with a column to hold a number and the new object1 type
} catch (SQLException e) {
System.out.println("SQLException"+ e.getMessage());
}
catch (Exception e) {
System.out.println("Exception"+ e.getMessage());
}
}

public void selectTableObjectValue()
{
try {



Statement stmt = conn.createStatement();

// Select rows from object1_table
ResultSet resultSet = stmt.executeQuery("SELECT * FROM Electronics_Products");

// Get the OBJECT values from each row
while (resultSet.next()) {
// Get the integer from the first column col_integer of the row
String ele_prod_id = resultSet.getString("ELECTRONICS_PRODUCTS_ID");
String ele_prod_name = resultSet.getString("ELECTRONICS_PRODUCTS_NAME");

// Get the object1 value from the second column col_object1
oracle.sql.STRUCT obj_PRODUCT_TYPE = (oracle.sql.STRUCT)resultSet.getObject("OBJ_PRODUCT_TYPE");

// Get the object1 values from each row
Object[] obj_PRODUCT_TYPEValues = obj_PRODUCT_TYPE.getAttributes();

System.out.println("obj_PRODUCT_TYPEValues"+obj_PRODUCT_TYPEValues.toString());

int obj_PRODUCT_length = obj_PRODUCT_TYPEValues.length;

for(int i=0;i<obj_PRODUCT_length;i++)
{
System.out.println(i+" Product Type "+obj_PRODUCT_TYPEValues[0]);
System.out.println(i+"Product Type"+obj_PRODUCT_TYPEValues[1]);

// Product Detail Info
oracle.sql.STRUCT Obj_product_detail_info = (oracle.sql.STRUCT)obj_PRODUCT_TYPEValues[2];
Object[] obj_product_detail_info_Values = Obj_product_detail_info.getAttributes();
int obj_product_detail_info_length = obj_product_detail_info_Values.length;
for(int j=0;j<obj_product_detail_info_length;j++)
{
System.out.println(j+" Product Detail Info "+obj_product_detail_info_Values[0]);
System.out.println(j+" Product Detail Info "+obj_product_detail_info_Values[1]);
System.out.println(j+" Product Detail Info "+obj_product_detail_info_Values[2]);

}
}

// Get the first value of object1, which is a string
/* String str = (String)object1Values[0];

System.out.println(""+str);

// Get the second value of object1, which is of the type object2
oracle.sql.STRUCT object2 = (oracle.sql.STRUCT)object1Values[1];

// Get the values of object2
Object object2Values[] = object2.getAttributes();
str = (String)object2Values[0];
BigDecimal num = (BigDecimal)object2Values[1];
System.out.println(""+str);*/
}


}
catch (SQLException e) {
System.out.println("SQLException"+ e.getMessage());
}
catch (Exception e) {
System.out.println("Exception"+ e.getMessage());
}
}
public void closeConnection()
{
try
{
conn.close();
}
catch (Exception e) {
System.out.println("Exception"+ e.getMessage());
}

}



public static void main(String[] args) {
AcessOracleObjects_ElectronicsItem v= new AcessOracleObjects_ElectronicsItem();
Connection conn= v.getConnection();
if(args[0].equalsIgnoreCase("C"))
{
v.createTableWithObject();
}
else if(args[0].equalsIgnoreCase("I"))
{
v.insertTableObjectValue();
}
else if(args[0].equalsIgnoreCase("S"))
{
v.selectTableObjectValue();
}
else
{
System.out.println("No vlaida option is selected");
}
v.closeConnection();
}
}


Database Configuration :
driverName=oracle.jdbc.driver.OracleDriver
serverName=139.73.41.135
portNumber=1521
username=scott
password=tiger
databaseName=facisdev
sid=facisdev