954,545 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

cannot convert int to result set????

Hi, im trying to query an oracle db set up of table is all done and filling it is fine but when i try to send a query to the db using a resultset to store the outcome im getting the error "cannot convert int to ResultSet" ive looked at all the examples of resultset i can find on the web and they all seem to use the exact same syntax as me so i cant see the error. here is the code

import java.sql.*;
import java.io.*;

public class test {
    public static void main (String[] args){
        BufferedReader input = new BufferedReader(
                new InputStreamReader( System.in));
        
        String command = null;
        System.out.println("Enter SQL Query: ");
        try {
            command = input.readLine();
        }
        catch(Exception e) {
            System.out.println("Couldn't read from keyboard because"
                + e);

            System.exit(1);
        }
        search(command);
    }
    PreparedStatement pstmt = null;
    
    
    public static void search(String query){
        Connection conn = DBInfo.connectToDatabase();
        Statement stmt =null;
        ResultSet rs =null
        try{
            stmt = conn.createStatement();
        }
        catch(SQLException sqle){
            System.out.print("Unable to create search  because ");
            System.out.println(sqle);
            System.exit(1);
        }
        try {
            rs = stmt.executeUpdate(query);
            
        }
        catch(SQLException sqle){
                System.out.print("Unable to search records because ");
                System.out.println(sqle);
                System.exit(1);
        }
        try {
            conn.close();
        }
        catch(SQLException sqle){}
    }
    
}
macca84
Newbie Poster
2 posts since Sep 2006
Reputation Points: 10
Solved Threads: 0
 

crap just realised i actually wasnt doing the same as what the other stes said was just reading their .executeQuery as my .executeUpdate :( doh sorry for the bother people

macca84
Newbie Poster
2 posts since Sep 2006
Reputation Points: 10
Solved Threads: 0
 

Hi , executeUpdate doen't return resultset it returns integer.That may be the cause for the exception .verify once .Hi, im trying to query an oracle db set up of table is all done and filling it is fine but when i try to send a query to the db using a resultset to store the outcome im getting the error "cannot convert int to ResultSet" ive looked at all the examples of resultset i can find on the web and they all seem to use the exact same syntax as me so i cant see the error. here is the code

import java.sql.*;
import java.io.*;
 
public class test {
    public static void main (String[] args){
        BufferedReader input = new BufferedReader(
                new InputStreamReader( System.in));
 
        String command = null;
        System.out.println("Enter SQL Query: ");
        try {
            command = input.readLine();
        }
        catch(Exception e) {
            System.out.println("Couldn't read from keyboard because"
                + e);
 
            System.exit(1);
        }
        search(command);
    }
    PreparedStatement pstmt = null;
 
 
    public static void search(String query){
        Connection conn = DBInfo.connectToDatabase();
        Statement stmt =null;
        ResultSet rs =null
        try{
            stmt = conn.createStatement();
        }
        catch(SQLException sqle){
            System.out.print("Unable to create search  because ");
            System.out.println(sqle);
            System.exit(1);
        }
        try {
            rs = stmt.executeUpdate(query);
 
        }
        catch(SQLException sqle){
                System.out.print("Unable to search records because ");
                System.out.println(sqle);
                System.exit(1);
        }
        try {
            conn.close();
        }
        catch(SQLException sqle){}
    }
 
}
amaravanich
Newbie Poster
12 posts since Aug 2006
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You