dipti khullar

Greenhorn
+ Follow
since Oct 23, 2008
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by dipti khullar

I am using DOM parser for parsing aboyt 50000 XMLs.

Call to parse function : -


Problem is with special characters. Since our site is supporting Arabic language, characters like , causes problem in parser.
Exception:



I cannot use InputStream instead of new File() because of performance issues.
Is there some other way to set some encoding format to the file, without opening it? Or how can i remove invalid characters while XML parsing?
Hi Balu Sadhasivam

Thanks a lot for your reply.

Please see if things are more visible now.




Exception: java.sql.SQLException: Invalid parameter index 3.
at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.getParameter(JtdsPreparedStatement.java:255)
at net.sourceforge.jtds.jdbc.JtdsCallableStatement.registerOutParameter(JtdsCallableStatement.java:190)
at net.sourceforge.jtds.jdbc.JtdsCallableStatement.registerOutParameter(JtdsCallableStatement.java:178)
at routines.GetArticleContent_sp.getArticleContent_sp(GetArticleContent_sp.java:43)
at redbullmigration_20090407.trial_0_1.trial.tJava_1Process(trial.java:165)
at redbullmigration_20090407.trial_0_1.trial.runJobInTOS(trial.java:307)
at redbullmigration_20090407.trial_0_1.trial.main(trial.java:220)
Hi

I want to use the resultset values retrieved from the SP. I am not very much clear about the syntax and usage of registerOutParameter. But, I tried following thing after referring to some posts. Following exception is thrown: java.sql.SQLException: Invalid parameter index 3

Code Snippet:

CallableStatement proc = null;
Statement stmt_MSSql = con_MSSql.createStatement();
ResultSet rs_MSSql = stmt_MSSql.executeQuery("SELECT top 5 pageID FROM A_Pages WHERE fkPageTypeID = 25");
ResultSet rs_proc_MSSql = null;
while(rs_MSSql.next()){
proc = con_MSSql.prepareCall("{ call AAA_PageLanguages(?,?,?) }");


//proc.registerOutParameter(2, java.sql.Types.VARCHAR);
proc.setInt(1, rs_MSSql.getInt(1));
proc.registerOutParameter(2, java.sql.Types.INTEGER);
proc.registerOutParameter(3, java.sql.Types.VARCHAR);
rs_proc_MSSql = proc.executeQuery();

//rs_proc_MSSql = (ResultSet)proc.getObject(1);
while (rs_proc_MSSql.next()) {
System.out.println(rs_proc_MSSql.getInt(1) + "\t" +
rs_proc_MSSql.getString(2));
}

}

SP (Input : pageID and Output : pkID, LanguageID)

SELECT
pkID AS ID , LanguageID
FROM
tblPageLanguage AS PL INNER JOIN tblLanguageBranch AS LB ON
(PL.fkLanguageBranchID = LB.pkID) WHERE PL.fkPageID = @pageID


Thanks a lot for your reply.

You were absolutely right.
But that resultset iteration problem is still not resolved.

I found another way of implementing that some time back using function calls and passing relevant info into that.

Thanks. It really helped and saved my considerable time of debugging.
package routines;
import java.io.*;
import java.sql.*;

public class GetCategoryName {

public static void getCategoryName() {
try {
Connection con=null;
Class.forName("oracle.jdbc.driver.OracleDriver");
con=DriverManager.getConnection(
"jdbc:oracle:thin:@10.210.236.32:1521:xe",
"proj_staging",
"proj");
Statement s=con.createStatement();
String category = "";
String [] list = {};
String list_cat = "";
int id_av=0;
int count=0;
ResultSet rs_category=null;

ResultSet rs_breadcrumb = s.executeQuery("select ID_AUDIOVIDEO, SOURCE_SYSTEM_BREADCRUMB from AUDIOVIDEO");

while(rs_breadcrumb.next()) {

id_av = rs_breadcrumb.getInt(1);
category = rs_breadcrumb.getString(2);
System.out.println("id_av " + rs_breadcrumb.getInt(1));
System.out.println("category_ID " + rs_breadcrumb.getString(2));

rs_category = s.executeQuery("select CATEGORY_NAME from RBAR_CATEGORY WHERE ID_CATEGORY IN (" + category + ")");

rs_category.next();
list[0] = rs_category.getString(1);
for(int i=1;rs_category.next();i++)
{ list[i] = list[0] + "," + rs_category.getString(1);
System.out.println("list " + list[i]);
}
//I will be able to update the record, but the value in list is incorrect.
}

s.close();
con.close();
} catch(Exception e){e.printStackTrace();}
}

Problem 1: First loop. rs_breacrumb.next() executes only once for the first row and it breaks
Problem 2: The list[i] doesn't store correct values, it throws exception.


Summarizing the issue:

SOURCE_SYSTEM_BREADCRUMB stores the ID_CATEGORY values as "1,2,3,4,5"
which I need to replace with "cat1,cat2,cat3.cat4", corresponding to ID_AUDIOVIDEO, which means using nested resultsets.