This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
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) {
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
your code " 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(); " Let me guess, you're getting a NullPointerException try this pstmt = conn.prepareStatement(sql); I think that'll help cheers Darryl
"darryl the second nortje", We're pleased to have you here with us in the JDBC forum, but there are a few rules that need to be followed, and one is that proper names are required. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it. In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious. Thanks! bear Forum Bartender