i found error in the following code....

import java.sql.*;
import java.util.*;

class search
{
public static void main(String args[])
		throws Exception
{
	Connection con=null;
	ResultSet rs=null;
	Statement st=null;
	

	Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
	con=DriverManager.getConnection("jdbc:odbc:oracle","user","vinay");

	
	String s="select *from student where roll=?";
	st=con.prepareStatement(s);
	rs=st.executeQuery();
	
	Scanner inp=new Scanner(System.in);
	System.out.println("Enter roll to search");
	int r=inp.nextInt();
	
	st.setInt(1,r);
	

	while (rs.next())
	{
		System.out.println("roll"+"name"+"address");
		System.out.print(rs.getInt(1));
		System.out.print(rs.getString(2));
		System.out.print(rs.getString(3));
		System.out.println();
	}
	con.close();
}
}

i found error in the following code....

Please explain. Post the full text of any error messages.

Please explain. Post the full text of any error messages.

search.java:19: cannot find symbol
symbol : method createStatement(java.lang.String)
location: interface java.sql.Connection
st=con.createStatement(s);
^
search.java:20: executeQuery(java.lang.String) in java.sql.Statement cannot be a
pplied to ()
rs=st.executeQuery();
^
search.java:26: cannot find symbol
symbol : method setInt(int,int)
location: interface java.sql.Statement
st.setInt(1,r);
^
3 errors

search.java:19: cannot find symbol
symbol : method createStatement(java.lang.String)

Where is the statement with the error in the source code you posted? I do NOT see any call to createStatement.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.