
sir my table has only one element(that is pno),i am using ms-access as backend. i put only one element i want to retrieve that element .how can i retrieve that element,using jdbc technology.
please csee my code
import java.sql.*;
class raja {
int regd1; public int k() {
try {
Connection con2=null; Statement stmt2=null; ResultSet rs2=null; Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); con2=DriverManager.getConnection("jdbc:odbc:oldp");
stmt2=con2.createStatement(); String st2="select * from pname order by pno"; System.out.println(""+st2.toString());
rs2=stmt2.executeQuery(st2); System.out.println("hi"); while(rs2.next()) regd1=rs2.getInt(1); else System.out.println("hi");
stmt2.close(); con2.close(); } catch(Exception e) { e.printStackTrace(); }
return regd1; } public static void main(String args[]) { raja p=new raja(); p.k(); } } //could you please tell me the way.

Hi Friend,
You can try the following code:
import java.sql.*;
class RetrieveData{
public static void main(String[] args){
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:student");
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("select * from data");
while(rs.next()){
System.out.println(rs.getInt("id"));
}
}
catch(Exception e){
}
}
}
Thanks
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.