How to convert Resulset to two dimenson array
Hello,
I have a Resulset, i want to store it in 2 dimenson array, but i can't.
so I store the resulset in Vector:
Vector row = new Vector();
ResultSet rs = stmt.executeQuery(sql);
ResultSetMetaData meta = rs.getMetaData();
int colCount = meta.getColumnCount();
while(rs.next()){
String[] records = new String[colCount];
for(int i=0; i<colCount; i++){
records[i] = rs.getString(i+1);
row.addElement(records);
However i don't know to convert this Vector to two dimenson array.
Can you help me:
1. store the resulset to two dimenson array
2. or convert the vector that store the resulset to two dimenson array
The problem with storing the result into a two dimensional array directly is that you don't know the size required for the dimensions of the array, so you need to use something that is dynamic ( like a Vector, or a better use would be an ArrayList if you didn't need the container to be thread safe ).
I might suggest something like this:
ArrayList list = new ArrayList();
ResultSet rs = stmt.executeQuery(sql);
ResultSetMetaData meta = rs.getMetaData();
int colCount = meta.getColumnCount();
while(rs.next()){
String[] records = new String[colCount];
for(int i=0; i<colCount; i++){
records[i] = rs.getString(i+1);
row.add(records);
String[][] resultArray = new String[ list.size() ][ colCount ];
for ( int i = 0; i < list.size(); i++ ) {
resultArray[ i ] = (String[])list.get( i );
}
Similar Messages
-
How to convert a waveform signal into array of complex numbers
How to convert a waveform signal into array of complex numbers.
Hi Chaks,
try this:
(Get Waveform components, convert to complex DBL)
Message Edited by GerdW on 01-28-2008 09:23 AM
Best regards,
GerdW
CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
Kudos are welcome
Attachments:
ToCDB.png 1 KB -
How to convert a String to an array
Can somebody tell me how to convert a String to an array
ronisto wrote:
Can somebody tell me how to convert a String to an arrayI assume you mean to convert it into an array of the individual characters that comprise the String.
Can you not simply look at the API documentation? Nothing in the String API jumps out at you?
http://java.sun.com/javase/6/docs/api/index.html -
How to convert a Image object to byte Array?
Who can tell me, how to convert Image object to byte Array?
Example:
public byte[] convertImage(Image img) {
byte[] b = new byte...........
return b;Hello,
any way would suit me, I just need a way to convert Image or BufferedImage to a byte[], so that I can save them. Actually I need to save both jpg and gif files without using any 3rd party classes. Please help me out.
thanx and best wishes -
how do you display a two dimensional array in jsf? my current code is this
<t:dataTable value="#{bean.rows}" var="row">
<t:columns value="#{row.columns}" var="column">
<f:facet name="header">
<h:outputText value="#{column.name}" />
</f:facet>
<h:outputText value="#{column.value}" />
</t:columns>
</t:dataTable>am using myfaces tomhawk, thanks!! :)You can use getters/setters as deep as you want.value="#{row.column.name}"is valid.
-
How to convert from array to graph ?
how to convert from array to graph ?
A graph will accept an array of numbers. Do you have an example of what you are looking for?
And since somebody mentioned tutorials...
3 Hour Introduction
6 Hour Introduction
LabVEW Basics
Self Paced training for students
Self Paced training beginner to advanced, SSP Required
LabVIEW Wiki on Training
Learning NI
Getting Started with NI Products
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines -
Hi, I would like to know how can i break the value for a row and column once i have converted the image to the array. I wanted to make some modification on the element of the array at a certain position. how can i do that?
At the moment (as per attachhment), the value of the new row and column will be inserted by the user. But now, I want to do some coding that will automatically insert the new value of the row and the column ( I will use the formula node for the programming). But the question now, I don't know how to split the row and the column. Is it the value of i in the 'for loop'? I've tried to link the 'i' to the input of the 'replace subset array icon' , but i'm unable to do it as i got some error.
Please help me!
For your information, I'm using LABView 7.0.Hi,
Thanks for your reply.Sorry for the confusion.
I manage to change the array element by changing the row and column value. But, what i want is to allow the program to change the array element at a specified row and column value, where the new value is generated automatically by the program.
Atatched is the diagram. I've detailed out the program . you may refer to the comments in the formula node. There are 2 arrays going into the loop. If a >3, then the program will switch to b, where if b =0, then the program will check on the value of the next element which is in the same row with b but in the next column. But if b =45, another set of checking will be done at a dufferent value of row and column.
I hope that I have made the problem clear. Sorry if it is still confusing.
Hope you can help me. Thank you!!!!
Attachments:
arrayrowncolumn2.JPG 64 KB -
How to copy data in text file into two-dimensional arrays?
Greeting. Can somebody teach me how to copy the input file into two-dimensional arrays? I'm stuck in making a matrix with number ROWS and COLUMNS according to the data in "input.txt"
import java.io.*;
import java.util.*;
public class array
public static void main (String[] args) throws FileNotFoundException
{ Scanner sc = new Scanner (new FileReader("input.txt"));
PrintWriter outfile = new PrintWriter("output.txt");
int[][]matrix = new int[ROWS][COLUMNS];
}my input.txt :
a,b,c
2,2,1
1,1,1
2,2,1
3,3,1
4,4,1
5,5,1
1,6,2
2,7,2
3,8,2
4,9,2
5,10,2import java.io.*;
import java.util.*;
public class array {
public static void main(String[] args) throws IOException {
FileInputStream in = null;
FileOutputStream out = null;
try {
in = new FileInputStream("input.txt");
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
String line = null;
while ((line = reader.readLine()) != null) {
String split[]=line.split(",");
catch (IOException x) {
System.err.println(x);
} finally {
if (in != null) in.close();
}}}What after this? -
How to use two dimensional array in custom.pll
HI
How to use two dimensional arrays in custom.pll
I tried by the following way .
type ship_array is table of number index by binary_integer;
type vc_array is table of ship_array index by binary_integer;
But I am getting the error as that
A plsql table may not contain a table or a record with composite fields.
Please tell me the way how to use themwhich forms version are you using? two dimensional arrays are available in >= 9i if memory serves.
regards -
How to clear two dimension array and content in JTextArea
hi all....
i have a problem to clear the counter in JTextArea..currently i design a program to store all the student details in two dimensian array...when i click "RESET"button..it will only reset the textarea..but can not clear the actual content inside the array..and when i click "Print Button" again..it's supposed nothing to display..but it displayed the thing which i previously entered......
so i think i need to clear the array...i use append to insert the text...,for this i also can not reset...
which the code is shown below :
txtArea.append(msg1);
the coding for reset area as below :
txtArea.setText("")
Anyone can help me?????
thks...How are you trying to reset the array?, you can just creat a new array.
Noah -
How to convert a string data to a 1 d array
Dear All,
I am wondering if somebody help me.
In the attached fle i have my program (in labview 8.6) which read temperature data and updates temperature during the time.
I want to use the updated temperature in a calculation. How can i get the new temperature which i think is in a string format and convert it to 1 d array?
I tried but the number that i got from temperature was not the same temperature which is shonw in data section of the program.
Could somebody please help me?
Regards,
Solved!
Go to Solution.
Attachments:
Readfiles[1].vi 152 KBYou are not reading temperature, you are reading a binary file. You seem to be assuming string format but do you really know? No one here can tell since you did not attach the file If it is you would need to use one of the string conversion functions. And please, get rid of the Data local variable. You are already usin shift registers. Do the same with the data from the file.
-
How can I use two dimensional array ?
Could some one show me how to use two dimentional array ?
I am know how to right a single ...but not two dimentional....please help,
Thanks,
Flower
public class Exam5
public static void main(String[] args)
int[][] numbers =
{ {1,2,3,4,5,6,7,8,9,10},
{1,2,3,4,5,6,7,8,9,10} };
for(int i = 1; i < 11; ++i)
System.out.println(i + "\t" + i * 2 + "\t" + i * 3 + "\t" + i * 4 + "\t" + i * 5 +
"\t" + i * 6 + "\t" + i * 7 + "\t" + i * 8 + "\t" + i * 9 + "\t" + i * 10);
Display #
1 2 3 4 5 6 7 8 9 10
2 4 6 8 10 12 14 16 18 20
3 6 9 12 15 18 21 24 27 30
4 8 12 16 20 24 28 32 36 40
5 10 15 20 25 30 35 40 45 50
6 12 18 24 30 36 42 48 54 60
7 14 21 28 35 42 49 56 63 70
8 16 24 32 40 48 56 64 72 80
9 18 27 36 45 54 63 72 81 90
10 20 30 40 50 60 70 80 90 100First, try not to ask someone to do your homework for you and then tell them they are wrong. The code posted may not have been exactly what you were looking for, but it was not wrong because it did exactly what the poster said it would do - print out the multiplication table.
Second, in the future if you ask specific questions rather than posting code and hoping someone will fix it for you, you may one day be able to complete the assignments on your own.
Here is code that prints what you want and uses a two dimensional array. Please ask questions if you do not understand the code. You will never learn if you just use someone else's code without taking the time to examine or understand it.
public class MultiTable{
public static void main(String[] args) {
int rows = 10;
int columns = 10;
int [][] numbers = new int [rows] [columns];
for(int j = 0; j < rows; j++) // for each of 10 rows
for(int k = 0; k < columns; k++) // for each of 10 columns
numbers[j][k] = (j+1) * (k+1); // calculate row+1 * col+1
for (int j = 0; j < rows; j++) // for each of 10 rows
for (int k = 0; k < columns; k++) // for each of 10 columns
System.out.print(numbers[j][k]+" "); // print out result
if (numbers[j][k] < 10) // for single digit numbers
System.out.print(" "); // print extra space for better formatting
System.out.println(); // skip to next line
} -
How to convert an array of bits into an array of bytes?
If I have an array of 1s and 0s, how can I pack them
into an array of bytes (8 bits)?
Thanks.NI recommends to get rid of 4.x mode (Quote from the help file: "National Instruments recommends reworking any application that uses the Convert 4.x Data mode as a long term solution."). For this reason, I have attached an alternative example to give you some ideas.
(The previous example (using 4.x type cast) is actually slightly flawed, because for some reason it only produces even sized output arrays (why???) so you would need to trim the resulting array as a function of the input array size.)
LabVIEW Champion . Do more with less code and in less time .
Attachments:
OnesAndZeroesU8v2.vi 43 KB -
How to convert 1D array of string to string
How to convert 1D array of string to string.
Maximus00, as Pavel indicated, there is a lesser known feature of "Concatenate Strings" that does exactly what your code is doing if the input is an array of strings. In one step! See attached image.
LabVIEW Champion . Do more with less code and in less time .
Attachments:
ConcatenateArray ofStrings.gif 7 KB -
How to convert arraylist into array
how to convert arraylist into array?
If you are using generics, I would use this version of toArray:
List < X > list = ...
X[] array = list.toArray(new X[list.size()]);If you are not using generics, that same thing looks like:
List list = ...
X[] array = (X[]) list.toArray(new X[list.size()]);
Maybe you are looking for
-
PO Print preview is not appearing properly for the Bulgarian
Hello Experts, We are facing an issue on PO output print preview and print. Where we are expecting the PO output was supposed to print Bulgarian language. Bulgarian letters are not appearing properly in PO print preview smart form We are able to see
-
Can't remove the screen lock by PIN and can't use the screen to receive calls
Hello, I have a brand new SONY Xperia , Model Number D5803, Android version 5.0.2. , Baseband version 8974-AAAAANAZQ-00063-42, Kernel version 8974-perf-g3f600d1. , Build number 23.2.A.1.62. I set a screen lock by PIN. However when I receive calls I c
-
HELP! I'm getting ready to throw my computer out the door!
I am on a G4 using system 9.2.2. I have photoshop 5.5. Photoshop keeps jamming when I open a larger size file. It will open a smaller file. I have tried everything. I reinstalled. I allocated more memory for photoshop. I ran Disk Warrior. I ran a con
-
I do not know how to get the music that I buy on itunes, on my mac, onto an ipod. I have already authorized my computer and "downloaded" my music, but that did not do anything, or provid the results that I was expecting, at least. Please, I really ne
-
Link work order Reservation to a PR
Hi All, I have a requirement,were in i have to create a PR from a work order reservation(IW32 components tab) using a custom program.As of now i am using the FM BAPI_PR_CREATE to that but i am not able to link the Reservation to the PR. Please let me