File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

need help with array

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

 
Michael Dunn
Ranch Hand
Posts: 4632
  • 0
  • 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
 
Campbell Ritchie
Sheriff
Pie
Posts: 47229
52
  • 0
  • 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.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • 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!
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic