Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners Solving task 1 by 1 from bundle of task data
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


sk
Solving task 1 by 1 from bundle of task data
2 Answer(s)      3 years and 7 months ago
Posted in : Java Beginners


Hello and namaste guys, i really need help here.i use ResultSet to query data from database. as we know, it query row by row using while (ResultSet()) this means, i have a lot of row.row means task.in each task, there will be an information like userid, Taskid, user_input

i have to use the information for eash task to solve the task it self.the problem im facing now is the code is just solve for the last data in result set.what should i do so that the solve code solve data 1 by 1?do i need to use array?what kind of array?


Advertisement
View Answers

April 7, 2011 at 3:16 PM


import java.sql.*;
import java.util.*;
class  Retrieve{
public static void main(String[] args){
    try{
           Class.forName("com.mysql.jdbc.Driver");
           Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root");
           Statement st=con.createStatement();
           ResultSet rs=st.executeQuery("select * from employee");

           ArrayList name=new ArrayList();
           ArrayList address=new ArrayList();
           ArrayList contact=new ArrayList();
           ArrayList email=new ArrayList();

           while(rs.next()){
             name.add(rs.getString("name"));
              address.add(rs.getString("address"));
              contact.add(rs.getInt("contactNo"));
              email.add(rs.getString("email"));
              }
           for(int i=0;i<name.size();i++){
           System.out.println(name.get(i)+"\t"+address.get(i)+"\t"+contact.get(i)+"\t"+email.get(i));
           }
    }
    catch(Exception e){
    System.out.println(e);
    }

    }
}


April 7, 2011 at 8:40 PM


using arraylist makes me more problem because i need to pass the value to the constructor.ive tried to change to single array,but got error.cannot find symbol constructor...

for(int i=0;i<count;i++)
                    {
                        String user_input = input[i];
                        int t_number = t_num[i];
                        String user_id = id[i];
                        int taskid = task_id[i];

                        Tway gen = new Tway(user_input , t_number , user_id , taskid);
                        gen.solve();

                     }

whats ive done wrong?



Related Tutorials/Questions & Answers:
Solving task 1 by 1 from bundle of task data
Solving task 1 by 1 from bundle of task data  Hello and namaste guys, i really need help here.i use ResultSet to query data from database. as we know... set.what should i do so that the solve code solve data 1 by 1?do i need to use
task 1 - Java Beginners
task 1  Please write a Java client that send a small letters string to a Java server which convert it to uppercase letters and send it back to the client. Please submit both the client and server programs  Hi Friend
Advertisements
data insertion and fetch 1
data insertion and fetch 1  @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ <... rs = (ResultSet) request.getAttribute("data"); while...; @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ insert int data base @@@@@@@@@ import
task 2 - Java Beginners
task 2  Write a time server that follows the time protocol outlined in RFC 868. When a client connects, the server sends a 4-byte, big-endian..., January 1, 1970 GMT (the epoch
Java task scheduling
Java task scheduling  What is a task?s priority and how is it used in scheduling
Java task scheduling
Java task scheduling  What is a task?s priority and how is it used in scheduling
Java Timer Task
Java Timer Task  How to assign a task in java at specified date & time (with seconds) using threads
Generate random numbers from 1 to 100
Generate random numbers from 1 to 100  1)A class Called: RandomNumberGenerator that generate random numbers from 1 to 100 2)A class Test that tests... an object from the Random NumberGenerator class to generate your input test data
print the sum of even number from 1 to 100
print the sum of even number from 1 to 100  how to print the sum of even number from 1 to 100 using for loops? Thanks
passing from 1 jsp to another - JSP-Servlet
passing from 1 jsp to another  Hi Sir, What are the ways and means of passing from 1 jsp page to another page.what are the different types of methods?  Hi Friend, You can use tag,sedRedirect() method
How to Create Multiplication Table from 1 to 10?
How to Create Multiplication Table from 1 to 10?  Hi, I want... table 1 to 10. Please suggest online example related to creating multiplication table. Thanks   Hi, Did you want to create multiplication table 1
Task Scheduling in JAVA
{ int count = 1; // run is a abstract method that defines task performed... Task Scheduling in JAVA       In some applications some task need to run periodically
Task Tag Decorator
Task Tag Decorator         In large projects there are a lot of task tags like TODO, FIXME, etc. and Eclipse provides only plain list of all these task tags which I
How to disable task manager using java
How to disable task manager using java  How to disable task manager using java
Scheduling a Timer Task
Scheduling a Timer Task       In this section, you can learn how to schedule a timer task to run.... This program asks you for the way of performing the task whether at the certain
Task manager enable and disable thru java
Task manager enable and disable thru java  I would like to know, how to enable and disable task manager using java. Kindly, please Let me know
A small programming task, plz respond at the ealiest..
A small programming task, plz respond at the ealiest..  Hi Guys ,small task to you all... 9 One can ski down from one peak to a connected peak if and only if the height
Create Multiplication Table from 1 to 10
to create multiplication table from 1 to 10. For this purpose, we have created...]; for (int i=1; i<array.length; i++) { for (int j=1; j<array[i].length; j++) { array[i][j] = i
display the hidden text from that row, when onclick on a row of 1- 10
display the hidden text from that row, when onclick on a row of 1- 10  Using JSP: I'm displaying a set of values from the databse in a table rows (1... created to show: <TABLE cellpadding="15" border="1" style="background-color
Need for Marketing Management Task
Management Task helps the management of companies in achieving the results... should be given focus during fixing a Marketing Management Task, many more topics
problem 1 - Java Beginners
. Method to input data from the data file Method to display the table...problem 1   Hi, please help me!!!! How can i code in java using.... this is my input data file: 88 90 94 102 111 122 134 75 77 80 86 94 103 113 80
Ajax Question 1
Ajax Question 1  I am having 3 fields in jsp they are Fieldname,Fieldtype,Required. If i enter Fieldname as studentid,Fieldtype as checkbox,Required.... From database it should displays the following jsp page as output page by using
Tags in struts 1
Tags in struts 1   I have problem in Include tag in Struts this tag using but it is not work Please Explain
Hibernate 1 - Hibernate
Hibernate 1  what is a fetchi loading in hibernate?i want source code?plz reply
function 1 - Java Beginners
function 1  WAP to calculate the value of x,where x=tan(A)+tan(B)/1+tan(A)*tab(B)  Give more details like how to calculate and what is tan(A) and tan(B),etc
contructors 1&test
contructors 1&test   how do i Create a class named Box that includes integer data fields for length, width and height. Create three constructors... created with length 10 and width 15. Box created with length 1, width 2
java code 1 of 2
java code 1 of 2  Create a washing machine class with methods as switchOn, acceptClothes, acceptDetergent, switchOff. acceptClothes accepts the noofClothes as argument & returns the noofClothes   Hi Friend, Visit
java code7 of 1
java code7 of 1  Develop the program calculateHeight, which computes the height that a rocket reaches in a given amount of time. If the rocket accelerates at a constant rate g, it reaches a speed of g ?· t in t time units
java code 8 of 1
java code 8 of 1  Develop a program that computes the distance a boat travels across a river, given the width of the river, the boat's speed perpendicular to the river, and the river's speed. Speed is distance/time
java program 1
java program 1  (4) WAP to take input of a String and check wheather it is valid number or not? Sample Output1: Enter a String : 10 10 is a number Sample Output2: Enter a String : 10b1 10b1 is not a number (5) WAP to take
 

 

 

DMCA.com