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

 
 


sk
Solving task 1 by 1 from bundle of task data
2 Answer(s)      2 years and a month 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?

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 Pages:
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
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
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
data insertion and fetch 1
data insertion and fetch 1  @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ <... rs = (ResultSet) request.getAttribute("data"); while...; @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ insert int data base @@@@@@@@@ import
Java Programming: Chapter 1 Quiz Answers
Sample Quiz Answers For Chapter 1 THIS PAGE CONTAINS SAMPLE ANSWERS to the Quiz on Chapter 1 of this on-line Java textbook. Note... 1: One of the components of a computer is its CPU. What is a CPU and what
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
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
Referencing Resource Bundle from a Page
Referencing Resource Bundle from a Page   ... according to the specific locale. Steps to Create Resource Bundle: 1. Create... to implement internationalization using Resource Bundle. Resource Bundle is a file
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 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 leftshift operator add 1 instead of 0
JAVA leftshift operator add 1 instead of 0  Hi Guys, I have a task to do. If I have some some int variable and If I apply left shift operator... So, the answer will be 20. But, I want to have "1" instead of "0"s. So
help me in solving this error
help me in solving this error  Hello, i have installed tomcat 6.0, i am getting following error while running application... Friend, Problem lies in your code. Try the following code: 1)login.jsp: <
Java Timer Task
Java Timer Task  How to assign a task in java at specified date & time (with seconds) using threads
Difficult Interview Questions Page -1
Difficult Interview Questions Page -1       Question 1: Tell me about yourself ? Answer: Whenever... a reliable quick learner from different sorts of  people with the skills
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
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
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
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
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
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
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
Simple Linked List Exercise 1
Java Notes: Simple Linked List Exercise 1 Name... and puts them in a doubly linked list. 1 2 3 4 5 6 7 8...; // Link to the previous element. public String data; // Reference to the data
Java programming 1 - Java Beginners
Java programming 1  thx sir for reply me..but sir can u pls simplify...; Hi friend, 1. Ask the user for their height. Convert it to a double... for BMI from 18.5 up to 25 * Overweight for BMI from 25 to 30
Java programming 1 - Java Beginners
Java programming 1  hi there, Sir! Can u help me check where my program gone wrong? here are my coding =D, hope to get reply from u guys soon... = JOptionPane.showInputDialog(null,"Enter mark 1", "Homework 8",JOptionPane.QUESTION_MESSAGE
Call Procedure
and  task. Stored Procedure can be compiled and executed... an example from 'Call Procedure'. In this Tutorial we create a table 'Stu_Table' with table attribute like 'field' and data type respectively. The create
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
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
JSP Architecture, JSP Model 1 architecture, JSP Model 2 architecture
for processing the business logic and getting the data (Model) from the database... types of view for the applications. We the help of JSP you can create data... of the architecture is used. These architectures are known as Model 1 and Model 2
How to disable task manager using java
How to disable task manager using java  How to disable task manager using java
java and xml problem. plz see this 1 first - XML
java and xml problem. plz see this 1 first  hi, i need to write... 002009031100001 22508591226 1... in your XML file: "); //String str = bf.readLine(); int no = Integer.parseInt("1
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
Cramers rule for solving equations using java
Cramers rule for solving equations using java  My code: import... of of equation" + (i+1)); for(int j=0;j<N;j++) { double k=s.nextDouble(); A[i][j]=k..." + (i+1)); double k = s.nextDouble(); B[i] = k; } } public double
Java Programming: Chapter 1 Quiz
Quiz Questions For Chapter 1 THIS PAGE CONTAINS A SAMPLE quiz on material from Chapter 1 of this on-line Java textbook. You should be able... the quiz questions can be found here. Question 1: One of the components
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
JDO UNPLUGGED - PART 1
, querying and retrieval of objects from the data stores. The collection of all class...)       Java Data Objects is an 'Object... support from Sun MicroSystems. Craig Russell is the specification lead
Sequence number to generate daily starting with 1
Sequence number to generate daily starting with 1  Sir, I am creating a bill report Application..I want to generate a sequence number for bill that is starting from 1.and if date changes the sequence number again starts with 1
More than 1 preparedStatement object - Java Beginners
More than 1 preparedStatement object  Hey but I want to use more than... = con.prepareStatement("update data set address=? where name =?"); pst1.setString(1, "Delhi"); pst1.setString(2
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
New Page 1
or EL as it is known is used by JSP developers to access and use application data...["1"]} EL Operators and Precedence:    Arithmetic... of context parameters param A map from parameter name to one
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
Five common Ajax patterns
Perhaps the most common Ajax task is to request updated HTML from... ? for example, in response to a search request. The code in Listing 1 requests a page from the server, and then places that content into a <div> tag

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.