This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes need help with array Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "need help with array" Watch "need help with array" New topic
Author

need help with array

LaraDon Smith
Greenhorn

Joined: Jun 09, 2010
Posts: 1
hey
can somebody tell me how to print result from my array?
This is my code and i don't know what's wrong...



public void connection() throws ClassNotFoundException, SQLException
{
try
{

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con= DriverManager.getConnection("jdbcdbc:test");
Statement s= con.createStatement();
String query = "SELECT * from table";
ResultSet rs = s.executeQuery(query);


while (rs.next())
{
for (int i=0; i<0; i++)
{
question[i]= rs.getString("columnQustion");
answer1[i]=rs.getString("column1");
answer2[i]=rs.getString("column2");
answer3[i]=rs.getString("column3");
answer4[i]=rs.getString("column4");

}

}
setQandA();
rs.close();
s.close();
con.close();
}
catch (ClassNotFoundException e)
{
e.printStackTrace();
}
catch (SQLException e)
{

}
}
public void setQandA();
{
int i=0;
label1.setText("question number:" + " "+ (i+1));
labelQuestion.setText(question[i]); //
radioButton1.setText(answer1[i]); // when i comment those lines program running
radioButton1.setText(answer2[i]); // otherwise not
radioButton1.setText(answer3[i]); //
radioButton1.setText(answer4[i]); //
}


thanks
akshit kumar
Greenhorn

Joined: Jul 03, 2006
Posts: 13
i am not clear on question but this approach you can use


Looking for new ideas if you don't get one steal one . SCJP
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
does something look odd here?

for (int i=0; i<0; i++)


[edit]
another one for the ignore list

http://www.java-forums.org/awt-swing/29688-need-help-array.html
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38075
    
  22
Welcome to the Ranch

As Michael Dunn has implied, it is discourteous to ask the same question in two places without informing everybody.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Please UseCodeTags when posting code or configuration. Unformatted code and configuration is unnecessarily difficult to read. You can edit your post by using the button. Thanks, and welcome to JavaRanch!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: need help with array
 
Similar Threads
Can't Update Record ?
Help with java input file
Run time checkbox values
Can't Update Record ?
Help with java input file