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



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

Have Programming Question? Ask it here!
 
 
 


sk
Solving task 1 by 1 from bundle of task data
2 Answer(s)      3 years and 4 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
Logging Tutorial - Part 1
Logging Tutorial - Part 1 2000-12-14 The Java Specialists' Newsletter [Issue 003] - Logging part 1 Author: Dr. Heinz M. Kabutz If you are reading... in this newsletter useful. I drew some fire from respectable quarters that some
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 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
String Exercises 1 - Answers
Java: String Exercises 1 - Answers Answers to the String Exercises 1. 3 -- s refers to exactly the same string as a. ERROR -- t is a local variable, and it must be assigned a value first. "1abc" -- + means concatenation
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
WEBSERVICES=1 - WebSevices
WEBSERVICES=1  I have develop webservices through wsad classes i dont want like this.I want like Create simple class to acess webservice is it possibule to create simple class to acess the webservice?  Hi Friend
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, Try
que 1 - Java Beginners
que 1  WAP to enter a sentence & count the no. of times a particular word occurs in it.Display the frequency of the searched word. eg- input:the quick brown fox jumps over the lazy dog. word to be searched:the output
array 1 - Java Beginners
array 1  WAP to input values in 2 arrays and merge them to array M.  Hi Friend, Try the following code: import java.util.*; class MergeArray{ public static int[] merge(int [] ... arr) { int arrSize = 0
arraylist not able to store large amount of data( over 1 lakh records) - Java Interview Questions
arraylist not able to store large amount of data( over 1 lakh records)  A result set containing over 1 lakhs of records is used to set data... function that iterator is used to iterate and data from above arraylist is used
C++ quuestion 1
C++ How to dispaly details for students and Create object for student class and input dispaly details   1.Create a class called student with following descriptions Data member : Rno - int Name - char[20] Std - int Mark1 int
New Page 1
;= 1; i <= 9; i++){   for(var j = 1
New Page 1
lost focus from the text box, onBlur() event occurs and specified function... can see from the above code that we have invoked the addFName() method...; Output : As soon as we lost focus from the very first
Database books- Page 1
Database books- Page 1     ... in manipulating data stored in Relational Database Management Systems (RDBMS). SQL provides commands through which data can be extracted, sorted, updated
Java programming 1 - Java Beginners
Java programming 1  Hi sir, i facing problem in this program. This program requires passing arrays as parameters and returning arrays from methods... to enter each mark in turn. Once the data is entered the program will process
Java Programming: Chapter 1
Chapter 1 Overview: The Mental Landscape WHEN YOU BEGIN a journey... the details from the brief expositions in this chapter.) Concentrate on learning enough... detail later in the course. Contents of Chapter 1: Section 1
Struts 2 Integration with Struts 1
Struts 2 Integration with Struts 1  I want to integrate struts 2 with struts 1 existing application. Can you please help on how to go about this. I am not finding any good source to integrate struts 2 with struts 1 framework
Cohabitation struts 1 and 2 - Struts
Cohabitation struts 1 and 2  Hi, I have a problem with the cohabitation of struts 1 and 2. I work on a web application which used struts 1. But i must add some functionality in struts 2. When i modify my web.xml file
Chapter 1. EJB Overview
 Chapter 1. EJB OverviewPrev Part I. Exam Objectives Next    Chapter 1. EJB... applications by combining components developed using tools from different
Java: Method Exercises 1
Java NotesMethod Exercises 1 Name: _________________________________ What is the output from this program? ___________________________ ___________________________ ___________________________ ___________________________ ___________________________ ___________________________ 1
How to Addding 1 Year with PHP
How to Addding 1 Year with PHP  Hi, I am very fresh in PHP language. I trying to create a small application about how to adding 1 year in specific date. Please suggest me. Thanks
Advertisements
 

 

 

DMCA.com