Hi all ,
I am trying to find if a particular
string is available in a String using 'instr' function..I dont get the output.The line rs= pstmt.executeQuery is not functioning.Please help me out
public int checkFiles(int acuserid,String fileid,String files)
{
ResultSet rs = null;
PreparedStatement pstmt = null;
int userid=0;
System.out.println("Hai");
try
{
String sql = "select instr(\'"+files+"\',\'"+fileid+"\',1) from clientinfonew where CL_ACUSERID=\'"+acuserid+"\'";
System.out.println(sql);
// I can execute this output in oracle
conn.prepareStatement(sql);
System.out.println("Hello");//okay
rs = pstmt.executeQuery();
//I cannot get the output from here
System.out.println("Hello1111111");
if(rs.next())
{
userid=rs.getInt(1);
System.out.println(userid);
}
rs.close();
pstmt.close();
}
catch(Exception e)
{
userid=0;
}
finally
{
return userid;
}
}
I put the following code in the main method along with the connection
String fileid ="1";
String files="5,2,1";
int stat = clinfo.checkFiles(4,fileid,files);
System.out.println(stat);
I am not able to proceed further .Please help me out.
Thanks to all,
Bhuvana