Can someone please tell me what is the compilation error
"Exception in thread "main" java.lang.Error: Unresolved compilation problems: Syntax error on token "rs", delete this token The method getString(int) is undefined for the type String at SelectTest.main"
in the below java code
//SelectTest.java
import java.sql.*;
public class SelectTest1
{
public static void main(String args[])throws Exception
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:oradsn","System","123");
Statement st = con.createStatement();
ResultSet rs = st.executeQuery("select*from student");
{
while(rs.next())
{
System.out.println(rs.getInt(1)+" "+rs.getString(2)+" "rs.getString(3));
}
rs.close();
st.close();
con.close();
}
}
}
The last rs.getString(3) you forget '+'
System.out.println(rs.getInt(1)+" "+rs.getString(2)+" " +rs.getString(3));
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments