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

ResultSet needs boolean??????

kriti sharma
Ranch Hand

Joined: Feb 16, 2001
Posts: 160
when i compile this code it gives the following error:
abc.java:52: incompatible types
found : boolean
required: java.sql.ResultSet
ResultSet rsB=stB.execute(sqlB);
^
1 error

STRANGE!!!help me please!!!
import java.io.*;
import java.net.*;
import java.sql.*;
class A
{
public static void main(String str[])
{
new B("POST");
}
}

class B extends Thread
{
String job;
Connection con;
B(String job)
{
this.job=job;
this.start();
}
public void run()
{
if(job.equals("POST"))
{
try
{
new C();
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("jdbc dbc:ForestDev","forestdev","forestdev");
Socket sB=new Socket("localhost",9090);
PrintWriter outB=new PrintWriter(sB.getOutputStream(),true);
BufferedReader brB=new BufferedReader(new InputStreamReader(sB.getInputStream()));
Statement stB=con.createStatement();
String sqlB="select * from transfer";
ResultSet rsB=stB.execute(sqlB);
while(rsB.next())
{
String sqlTemp=rsB.getString(2);
outB.println(sqlTemp);
String status=brB.readLine();
System.out.println(status);
}
rsB.close();
stB.close();
sB.close();
con.close();
outB.close();
brB.close();
}
catch(Exception e)
{
System.out.println(e);
}
}
}
}

class C
{
Connection con;
C()
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("jdbc dbc:ForestDev","forestdev","forestdev");
ServerSocket ssC=new ServerSocket(9090);
Socket sC=null;
sC=ssC.accept();
PrintWriter outC=new PrintWriter(sC.getOutputStream(),true);
BufferedReader brC=new BufferedReader(new InputStreamReader(sC.getInputStream()));
while(true)
{
String sqlC=brC.readLine();
Statement stC=con.createStatement();
stC.execute(sqlC);
outC.println("done");
stC.close();
}
/* con.close();
sC.close();
ssC.close();
outC.close();
brC.close();*/
}
catch(Exception e)
{
System.out.println(e);
}
}
}
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61606
    
  67

It helps to check the Javadoc.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Raj Chila
Ranch Hand

Joined: Mar 18, 2004
Posts: 128

Hi Kriti,
It certainly pays to go through the Javadoc, the execute method returns a boolean and the executeQuery() returns a ResultSet.
execute should be followed by getResultSet() to get the ResultSet.
kriti sharma
Ranch Hand

Joined: Feb 16, 2001
Posts: 160
thank you so much everybody here on the board.i am learning a lot!!!
Java Programmer
Greenhorn

Joined: Apr 20, 2004
Posts: 9
see execute(sql) returns boolean type and u r catching it in ResultSet object.
To get ResultSet object use either executeQuery(sql) or getResultSet(sql) on Statement object.


Smiling on Java
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61606
    
  67

"Java Programmer",
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ResultSet needs boolean??????