store data in a String array getting from access table

Hai all,

i an new to java.

i have a problem regarding database connectivity, in my bean class i have written code to retrieving data from a access table. It is successfully retrieving data as System.out.println(rs.getString(rows)) is working fine but i want to store the data in String array

My code is like follows

String[ ] listTitle;

rs.next();

for(int i;i<8;i++)

{

rows="F"+i;

System.out.println(rs.getString(rows));

listTitle[i]=rs.getString(rows);

}

when control coming to

listTitle=rs.getString(rows);

it is giving some error like::::No data found.

how to solve this any one?

[836 byte] By [Subrat.Ranjan.Raya] at [2007-11-26 19:49:02]
# 1
did you ever instantiate your String[ ] ?String[] whatever = new String[your length here];
den2681a at 2007-7-9 22:37:10 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 2
also, please post the exact error message you are getting.
den2681a at 2007-7-9 22:37:10 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 3

Hi,

U r trying to get the value two times. To avoid this store the value in variable, then manipulate.

Try this,

String[ ] listTitle;

String temp;

rs.next();

for(int i;i<8;i++)

{

rows="F"+i;

temp = rs.getString(rows);

System.out.println(temp);

listTitle [i] =temp;

}

Regards,

Ram.

JTecha at 2007-7-9 22:37:10 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 4
Hai Ram,i tried what u suggested, but when the control is comming to the line temp=rs.getString(rows);It is displaying the same error message thatjava.sql.SQLException:No Data foundHow to solve it?
Subrat.Ranjan.Raya at 2007-7-9 22:37:10 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 5
Thanks Ram problem is solved.
Subrat.Ranjan.Raya at 2007-7-9 22:37:10 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...