aspose file tools*
The moose likes JDBC and the fly likes Please help with the resultset problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Please help with the resultset problem" Watch "Please help with the resultset problem" New topic
Author

Please help with the resultset problem

Boon Subra
Ranch Hand

Joined: Jul 18, 2001
Posts: 69
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
Jan Modaal
Greenhorn

Joined: Apr 06, 2004
Posts: 4
what exception does occeur exactly ?
or you could just try using the following:
darryl nortje
Greenhorn

Joined: Mar 31, 2004
Posts: 5
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
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61413
    
  67

"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


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Boon Subra
Ranch Hand

Joined: Jul 18, 2001
Posts: 69
Hi Daryl and Jan ,,
Thanks for the prompt response.
pstmt= conn.prepareStatement works. I am v.sorry .it was typo error.

Thanks a lot once again.
Bhuvana
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Please help with the resultset problem