How to get nested table data in java??
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Nikhil_Sood
Posted On:   Tuesday, June 29, 2004 11:08 PM

I am doing the following in oracle : create type keywords as table of varchar(20); create table Category (TagID number primary key, ParentTagID number references Category, TagName varchar(20), Keyword keywords) nested table Keywords store as keyword_tab; Now i am using the following code to access the 'Category' data (java code) public String[] getSubCategory( String[] tagTree, int sID, boolean v) { if((new Date()).getTime()>=(creationDate).getTime() + ttl ) { // System.out.println("TEST"); return null; } else { try { St   More>>

I am doing the following in oracle :

create type keywords as table of varchar(20);


create table Category (TagID number primary key, ParentTagID number references Category,
TagName varchar(20), Keyword keywords)
nested table Keywords store as keyword_tab;


Now i am using the following code to access the 'Category' data (java code)


public String[] getSubCategory( String[] tagTree, int sID, boolean v) {



if((new Date()).getTime()>=(creationDate).getTime() + ttl ) {
//

System.out.println("TEST");

return null;

}

else {

try {

String[] result;

String kword = tagTree[tagTree.length-1];

int pTagID;

if(v == false) {

pTagID = 0;

PreparedStatement temppstmt, pstmt;

ResultSet temprs, rs;

boolean more;

String query="SELECT TAGID, TagName FROM Category where ParentTagID=? AND TagName=?";

temppstmt = conn.prepareStatement(query);

pstmt = conn.prepareStatement(" SELECT keyword FROM Category WHERE TagID = ?");

for(int i=0 ; i

System.out.println(tagTree[i]);

temppstmt.setInt(1,pTagID);

temppstmt.setString(2,tagTree[i]);

System.out.println(pTagID);

temprs = temppstmt.executeQuery();

System.out.println(pTagID);

more = temprs.next();

if (!more) {

System.out.println("No rows found.");

return null;

}

pTagID = temprs.getInt(1);

System.out.println(pTagID);

System.out.println ( temprs.getString(2) ) ;

}

temppstmt.close();

System.out.println("hello" + pTagID);

pstmt.setInt(1,pTagID);

rs = pstmt.executeQuery();

if (!rs.next()) {

System.out.println(" No Row Found");

return null;

}

oracle.sql.ARRAY array = ((oracle.jdbc.driver.OracleResultSet)rs).getARRAY (1);

result = new String[array.length()];

result = (String[]) array.getArray();

System.out.println((String)result[0]);

}

}catch (SQLException ex){

System.out.println("SQLException caughttt");

System.out.println("---");

while ( ex != null ){

System.out.println("Message : " + ex.getMessage());

System.out.println("SQLState : " + ex.getSQLState());

System.out.println("ErrorCode : " + ex.getErrorCode());

System.out.println("---");

ex = ex.getNextException();

}

}

return result;

}

}




My problem is that how to access the keywords in the Category table.!!!

   <<Less
About | Sitemap | Contact