• Post Reply Bookmark Topic Watch Topic
  • New Topic

need help with array  RSS feed

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am not clear on question but this approach you can use

 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Marshal
Posts: 56610
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

As Michael Dunn has implied, it is discourteous to ask the same question in two places without informing everybody.
 
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!