Related
When I tried to execute the given query through java I'm getting 'query block has an incorrect number of result columns' error. But when I run it separately it is producing the accurate results. Don't know what's wrong with the query. Could anyone help me with this? I am struggling with this for more than two days.
"select Project_Code"+
" ,trunc(Po_Issued_Date)"+
" ,trunc(Expected_Receipt_Date)"+
" ,trunc(actual_receipt_date) "+
" ,Supplier_Name "+
" ,PO_Number"+
" ,Release_Num"+
" ,Item_Code"+
" ,Item_Description"+
" ,Supplier_Item_Number "+
" ,Mfg_Part_Number "+
" ,Currency_Code"+
" ,Unit_Price "+
" ,PO_Quantity "+
" ,sum(quantity_received)" +
" ,(Unit_Price * sum(quantity_received)) "+
" ,receipt_num"+
" ,Buyer_Name "+
" ,invoice_num"+
" ,invoice_date "+
" ,po_header_id "+
" ,po_line_id"+
" from (select msi.ATTRIBUTE13"+
" ,pha.approved_date"+
" ,rsh.expected_receipt_date"+
" ,rt.transaction_date"+
" ,aps.vendor_name"+
" ,pha.segment1"+
" ,null"+
" ,msi.segment1"+
" ,pla.item_description"+
" ,(select primary_vendor_item from apps.po_approved_supplier_list"+
" where item_id = pla.item_id"+
" and vendor_id = pha.vendor_id"+
" and vendor_site_id = pha.vendor_site_id"+
" and nvl(disable_flag,'N')='N'"+
" ) Supplier_Item_Number"+
" ,msi.ATTRIBUTE12"+
" ,pha.currency_code"+
" ,pla.unit_price"+
" ,pla.quantity"+
" ,rsl.quantity_received"+
" ,rsh.receipt_num"+
" ,(select full_name from apps.per_all_people_f"+
" where person_id = pha.agent_id"+
" and sysdate between nvl(effective_start_date,sysdate) and nvl(effective_end_date,sysdate)"+
" )Buyer_Name"+
" ,aia.invoice_num"+
" ,aia.invoice_date"+
" ,pha.po_header_id "+
" ,msi.inventory_item_id"+
" ,pla.po_line_id"+
" ,pll.line_location_id"+
" ,pda.po_distribution_id"+
" ,rsl.shipment_line_id"+
" ,rt.transaction_id"+
" from apps.po_headers_all pha"+
" ,apps.po_lines_all pla"+
" ,apps.po_line_locations_all pll"+
" ,apps.po_distributions_all pda"+
" ,apps.mtl_system_items msi"+
" ,apps.ap_suppliers aps"+
" ,apps.ap_supplier_sites_all ass"+
" ,apps.rcv_shipment_headers rsh"+
" ,apps.rcv_shipment_lines rsl"+
" ,apps.rcv_transactions rt"+
" ,apps.ap_invoices_all aia"+
" ,apps.ap_invoice_lines_all ail"+
" where pha.org_id = 81"+
" and trunc(rsh.expected_receipt_date) between '01-Jan-2017' and '30-Sep-2017'"+
" and pha.type_lookup_code = 'STANDARD'"+
" and msi.item_type = 'IDM'"+
" and rt.transaction_type ='DELIVER'"+
" and pha.vendor_id = aps.vendor_id"+
" and pha.vendor_site_id = ass.vendor_site_id"+
" and pha.org_id = ass.org_id"+
" and pha.org_id = pla.org_id"+
" and pha.po_header_id = pla.po_header_id"+
" and pla.org_id = pll.org_id"+
" and pla.po_header_id = pll.po_header_id"+
" and pla.po_line_id = pll.po_line_id"+
" and pll.org_id = pda.org_id"+
" and pll.po_header_id = pda.po_header_id"+
" and pll.po_line_id = pda.po_line_id"+
" and pll.line_location_id = pda.line_location_id"+
" and pla.item_id = msi.inventory_item_id"+
" and msi.organization_id = pll.ship_to_organization_id"+
" and pda.po_header_id = rsl.po_header_id"+
" and pda.po_line_id = rsl.po_line_id"+
" and pda.line_location_id = rsl.po_line_location_id"+
" and pda.po_distribution_id = rsl.po_distribution_id"+
" and rsl.shipment_header_id = rsh.shipment_header_id"+
" and rsl.shipment_header_id = rt.shipment_header_id"+
" and rsl.shipment_line_id = rt.shipment_line_id"+
" and pda.po_header_id = ail.po_header_id(+)"+
" and pda.po_line_id = ail.po_line_id(+)"+
" and pda.line_location_id = ail.po_line_location_id(+)"+
" and pda.po_distribution_id = ail.po_distribution_id(+)"+
" and ail.line_type_lookup_code(+)= 'ITEM'"+
" and ail.invoice_id = aia.invoice_id(+)"+
" union"+
" select msi.ATTRIBUTE13"+
" ,pra.approved_date"+
" ,rsh.expected_receipt_date"+
" ,rt.transaction_date"+
" ,aps.vendor_name"+
" ,pha.segment1"+
" ,pra.release_num"+
" ,msi.segment1"+
" ,pla.item_description"+
" ,(select primary_vendor_item from apps.po_approved_supplier_list"+
" where item_id = pla.item_id"+
" and vendor_id = pha.vendor_id"+
" and vendor_site_id = pha.vendor_site_id"+
" and nvl(disable_flag,'N')='N'"+
" ) Supplier_Item_Number"+
" ,msi.ATTRIBUTE12"+
" ,pha.currency_code"+
" ,pla.unit_price"+
" ,pll.quantity"+
" ,rsl.quantity_received"+
" ,rsh.receipt_num"+
" ,(select full_name from apps.per_all_people_f"+
" where person_id = pha.agent_id"+
" and sysdate between nvl(effective_start_date,sysdate) and nvl(effective_end_date,sysdate)"+
" )Buyer_Name"+
" ,aia.invoice_num"+
" ,aia.invoice_date"+
" ,pha.po_header_id "+
" ,msi.inventory_item_id"+
" ,pla.po_line_id"+
" ,pll.line_location_id"+
" ,pda.po_distribution_id"+
" ,rsh.shipment_header_id"+
" ,rsl.shipment_line_id"+
" ,rt.transaction_id"+
" from apps.po_headers_all pha"+
" ,apps.po_releases_all pra"+
" ,apps.po_lines_all pla"+
" ,apps.po_line_locations_all pll"+
" ,apps.po_distributions_all pda"+
" ,apps.mtl_system_items msi"+
" ,apps.ap_suppliers aps"+
" ,apps.ap_supplier_sites_all ass"+
" ,apps.rcv_shipment_headers rsh"+
" ,apps.rcv_shipment_lines rsl"+
" ,apps.rcv_transactions rt"+
" ,apps.ap_invoices_all aia"+
" ,apps.ap_invoice_lines_all ail"+
" where pha.org_id = 81"+
" and trunc(rsh.expected_receipt_date) between '01-Jan-2017' and '30-Sep-2017'"+
" and msi.item_type = 'IDM'"+
" and rt.transaction_type = 'DELIVER'"+
" and pha.type_lookup_code = 'BLANKET'"+
" and pha.org_id = pra.org_id"+
" and pha.po_header_id = pra.po_header_id"+
" and pha.org_id = pla.org_id"+
" and pha.po_header_id = pla.po_header_id"+
" and pla.org_id = pll.org_id"+
" and pla.po_header_id = pll.po_header_id"+
" and pla.po_line_id = pll.po_line_id"+
" and pra.po_release_id = pll.po_release_id"+
" and pll.org_id = pda.org_id"+
" and pll.po_header_id = pda.po_header_id"+
" and pll.po_line_id = pda.po_line_id"+
" and pll.line_location_id = pda.line_location_id"+
" and pll.po_release_id = pda.po_release_id"+
" and pla.item_id = msi.inventory_item_id"+
" and pll.ship_to_organization_id=msi.organization_id"+
" and pha.vendor_id = aps.vendor_id"+
" and pha.org_id = ass.org_id"+
" and pha.vendor_site_id = ass.vendor_site_id"+
" and pll.ship_to_organization_id=rsl.to_organization_id"+
" and pda.po_header_id = rsl.po_header_id"+
" and pda.po_release_id = rsl.po_release_id"+
" and pda.po_line_id = rsl.po_line_id"+
" and pda.line_location_id = rsl.po_line_location_id"+
" and pda.po_distribution_id = rsl.po_distribution_id"+
" and rsl.shipment_header_id = rsh.shipment_header_id"+
" and rsl.shipment_header_id = rt.shipment_header_id"+
" and rsl.shipment_line_id = rt.shipment_line_id"+
" and pda.org_id = ail.org_id(+)"+
" and pda.po_header_id = ail.po_header_id(+)"+
" and pda.po_line_id = ail.po_line_id(+)"+
" and pda.line_location_id = ail.po_line_location_id(+)"+
" and pda.po_distribution_id = ail.po_distribution_id(+)"+
" and ail.line_type_lookup_code(+)= 'ITEM'"+
" and ail.invoice_id = aia.invoice_id(+)"+
") temp"+
" group by Project_Code"+
",trunc(Po_Issued_Date)"+
",trunc(Expected_Receipt_Date)"+
",trunc(actual_receipt_date)"+
" ,Supplier_Name"+
" ,PO_Number"+
" ,Release_Num"+
" ,Item_Code"+
" ,Item_Description"+
" ,Supplier_Item_Number"+
" ,Mfg_Part_Number"+
" ,Currency_Code"+
",Unit_Price"+
",PO_Quantity"+
",receipt_num"+
",Buyer_Name"+
",invoice_num"+
" ,invoice_date"+
",po_header_id "+
" ,po_line_id"+
" order by PO_Number"+
",item_code"
When having a UNION SELECT statement, number & type of columns fetched by each of them must match. If I saw it correctly, your first SELECT (starts at line 23) contains 26 columns, while its UNION pair (starts at line 102) contains 27 columns.
I didn't took time to match them one by one, I'll let you do it.
I want to achieve AutoSuggest ComboBox 2 problems I am facing
1st getting an array of id and name both want the name only.
Array i am receiving
2nd losing focus on typing the text.
Please help
database Query
public SentenceList getAutoProductList() {
return new StaticSentence(s, "SELECT "
+ "P.ID, "
+ "P.REFERENCE, "
+ "P.CODE, "
+ "P.CODETYPE, "
+ "P.NAME, "
+ "P.PRICEBUY, "
+ "P.PRICESELL, "
+ "P.CATEGORY, "
+ "P.TAXCAT, "
+ "P.ATTRIBUTESET_ID, "
+ "P.STOCKCOST, "
+ "P.STOCKVOLUME, "
+ "P.IMAGE, "
+ "P.ISCOM, "
+ "P.ISSCALE, "
+ "P.ISKITCHEN, "
+ "P.PRINTKB, "
+ "P.SENDSTATUS, "
+ "P.ISSERVICE, "
+ "P.ATTRIBUTES, "
+ "P.DISPLAY, "
+ "P.ISVPRICE, "
+ "P.ISVERPATRIB, "
+ "P.TEXTTIP, "
+ "P.WARRANTY, "
+ "P.STOCKUNITS "
+ "FROM PRODUCTS P "
+ "ORDER BY NAME", null, ProductInfoExt.getSerializerRead());
}
Auto Complete JcomboBox Code
SentenceList sentProductNames = dlSales.getAutoProductList();
m_JComboProductName.setEditable(true);
ComboBoxValModel m_jProductNameModel = new ComboBoxValModel();
editor = (JTextComponent) m_JComboProductName.getEditor().getEditorComponent();
List productList = null;
try {
productList = sentProductNames.list();
} catch (Exception e) {
}
productList.add(0, null);
m_jProductNameModel = new ComboBoxValModel(productList);
m_JComboProductName.setModel(m_jProductNameModel);
AutoCompleteDecorator.decorate(m_JComboProductName);
System.out.println("product List "+ productList);
if(m_JComboProductName.getItemCount()>0){
m_JComboProductName.setSelectedIndex(0);
}
I'm trying to create another array but I want it to be the array double gainT[], which is the temperature in Fahrenheit, converted to Celcius to make another array called double gainTC[]. I am also trying to do the same thing but with the precipitation. I just can't seem to find a way to do it though.
import java.io.IOException;
import java.util.Scanner;
public class AnnualClimate1 {
public static void main(String [] args) throws IOException
{
Scanner in = new Scanner(System.in);
System.out.print("Choose the temperature Scale (F = Fahrenheit, C = Celsius): ");
String tFC = in.nextLine();
System.out.print("Choose the precipitation Scale (I = Inches, C = Centimeters): ");
String pIC = in.nextLine();
System.out.println("");
System.out.println("");
System.out.println(" Climate Data");
System.out.println(" Location: Gainesville, Florida");
System.out.println(" Temperature " + tFC + " Precipitation " + pIC);
System.out.println("=================================================");
double gainT[]={54.3, 57.0, 62.5, 67.6, 74.3, 79.2, 80.9, 80.4, 77.8, 70.1, 62.8, 56.3};
double gainTC[] = {(gainT[] - 32) / 1.8};
double gainP[]={3.5, 3.4, 4.3, 2.9, 3.2, 6.8, 6.1, 6.6, 4.4, 2.5, 2.2, 2.6};
double gainPC[] = {gainP[] / .3937};
if(tFC.equalsIgnoreCase("F") && pIC.equalsIgnoreCase("I")){
System.out.println("Jan. " + gainT[1] + " " + gainP[1]);
System.out.println("Feb. " + gainT[2] + " " + gainP[2]);
System.out.println("Mar. " + gainT[3] + " " + gainP[3]);
System.out.println("Apr. " + gainT[4] + " " + gainP[4]);
System.out.println("May " + gainT[5] + " " + gainP[5]);
System.out.println("Jun. " + gainT[6] + " " + gainP[6]);
System.out.println("Jul. " + gainT[7] + " " + gainP[7]);
System.out.println("Aug. " + gainT[8] + " " + gainP[8]);
System.out.println("Sep. " + gainT[9] + " " + gainP[9]);
System.out.println("Oct. " + gainT[10] + " " + gainP[10]);
System.out.println("Nov. " + gainT[11] + " " + gainP[11]);
System.out.println("Dec. " + gainT[12] + " " + gainP[12]);
}
else if(tFC.equalsIgnoreCase("C") && pIC.equalsIgnoreCase("C")){
System.out.println("Jan. " + gainTC[1] + " " + gainPC[1]);
System.out.println("Feb. " + gainTC[2] + " " + gainPC[2]);
System.out.println("Mar. " + gainTC[3] + " " + gainPC[3]);
System.out.println("Apr. " + gainTC[4] + " " + gainPC[4]);
System.out.println("May " + gainTC[5] + " " + gainPC[5]);
System.out.println("Jun. " + gainTC[6] + " " + gainPC[6]);
System.out.println("Jul. " + gainTC[7] + " " + gainPC[7]);
System.out.println("Aug. " + gainTC[8] + " " + gainPC[8]);
System.out.println("Sep. " + gainTC[9] + " " + gainPC[9]);
System.out.println("Oct. " + gainTC[10] + " " + gainPC[10]);
System.out.println("Nov. " + gainTC[11] + " " + gainPC[11]);
System.out.println("Dec. " + gainTC[12] + " " + gainPC[12]);
}
}
}
Here is an incomplete example so you can fill in the blanks yourself:
double gainT[]={54.3, 57.0, 62.5, 67.6, 74.3, 79.2, 80.9, 80.4, 77.8, 70.1, 62.8, 56.3};
double gainTC[] = new double[gainT.length]; //create array which matches the size of gainT
//array.length is a property value returning the 'size' or length or the array
//Now just iterate through all the gainT[] values you populated above and read each one
for(int i = 0; i < gainT.length; i++){
double math = //use your conversion math here, and store the value
gainTC[i] = math; //assign the results of your math to the same spot in the new array
}
If you'd like more information on Loops and Arrays, check here:
For Loops: https://docs.oracle.com/javase/tutorial/java/nutsandbolts/for.html
Arrays: https://docs.oracle.com/javase/tutorial/java/nutsandbolts/arrays.html
I am learning java, and from what I can tell, what I am looking to do is a rare situation.
I am trying to use an API (kindof) to randomly generate musical notes. I want it to generate 20 times so i have it in a for loop. I realize that i could have used a list for this I just dont know how I could have implemented it. The question I have is, when I try to compile this code, the first part runs. It lets me make the seed. However after that it gives me
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 2
at co.kbcomp.music.Main.main(Main.java:64)
What could I do to prevent this? I know that what I am doing is wrong. That much I dont need to be told. What I want to know is where am I going wrong.
package co.kbcomp.music;
import java.util.*;
import org.jfugue.*;
import java.util.Scanner;
public class Main {
public static void main(String[] args){
Scanner in = new Scanner(System.in);
System.out.println("Please enter a number for the seed of the song");
long seed = in.nextLong();
Calendar cal = Calendar.getInstance();
Random rand;
//rand = new Random(cal.getTime());
rand = new Random(seed);
int NoteNumber = 0;
int NoteLength = 0;
int OctiveNumber = 0;
int ChordNumber = 0;
int InversionNumber = 0;
//int Duration = rand.nextInt(100 - 5) + 5;
//This keeps track of the iteration of the for loop.
String[] NN = { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "};
String[] NL = { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "};
String[] IN = { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "};
String[] CN = { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "};
String[] ON = { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "};
//This is what is being played
String[] note = { "A", "B", "C", "D", "E", "F", "G" };
String[] noteLength = {"", "w", "", "h", "", "q","", "i"};
String[] octive = { "","1","", "2", "", "3", "", "4", "", "5", "", "6", "", "7", "", "8", "", "9"};
String[] chord = { "", "maj", "", "min"};
String[] inversion = {"", "^", "", "^^", "", "^^^", "", "^^^^", "", "^^^^^"};
String[] key = {"",""};
String keys= " ";
String randstr = " ";
//this is the loop that defines the music legnth
for (int i = 0; i < 21; i++) {
NoteNumber = rand.nextInt(7);
NoteLength = rand.nextInt(8);
OctiveNumber = rand.nextInt(18);
ChordNumber = rand.nextInt(4);
InversionNumber = rand.nextInt(10);
NN[i] = note[NoteNumber]; // This randomly generates the note to be played.
NL[i] = noteLength[NoteLength]; // This randomly generates the length of the note.
ON[i] = octive[OctiveNumber]; // This defines the octive to be played in.
CN[i] = chord[ChordNumber]; // This is defines the major or the minor
IN[i] = inversion[InversionNumber]; // IN[i] = inversion[InversionNumber];
key[i] = NN[i] + NL[i] + ON[i] + CN[i] + IN[i];
//randstr = c[0] + " " + c[1] + " " + c[2] + " " + c[3] + " " + c[4] + " " + c[5] + " " + c[6] + " " + c[7] + " " + c[8] + " " + c[9] + " " + c[10] + " " + c[11] + " " + c[12] + " " + c[13] + " " + c[14] + " " + c[15] + " " + c[16];
keys = (key[0] + " " + key[1] + " " + key[2] + " " + key[3] + " " + key[4] + " " + key[5] + " " + key[6] + " " + key[7] + " " + key[8] + " " + key[9] + " " + key[10] + " " + key[11] + " " + key[12] + " " + key[13] + " " + key[14] + " " + key[15] + " " + key[16] + " " + key[17] + " " + key[18] + " " + key[19] + " " + key[20]);
}
System.out.println(key);
Player player = new Player();
Pattern pattern = new Pattern(key[0]);
player.play(pattern);
}
}
You declare your key array with a length of two:
String[] key = {"",""};
But then later in your for loop, you try to access elements beyond the length of your array:
keys = (key[0] + " " + key[1] + " " + key[2] + " " + key[3] + " " + key[4] +
" " + key[5] + " " + key[6] + " " + key[7] + " " + key[8] + " " + key[9] +
" " + key[10] + " " + key[11] + " " + key[12] + " " + key[13] + " " +
key[14] + " " + key[15] + " " + key[16] + " " + key[17] + " " + key[18] +
" " + key[19] + " " + key[20]);
Since your array has only a length of two, when you try to access the third element (at array index 2), you get an ArrayIndexOutOfBoundsException.
String[] key = {"",""};
...
for (int i = 0; i < 21; i++) {
...
key[i] = ....
Do you see the problem?
As you array in only 20 in length
then this
for (int i = 0; i < 21; i++) {
is going to cause an overflow
It should be < 20
Plus this code is meaningless as your key is only an array of 2
keys = (key[0] + " " + key[1] + " " + key[2] + " " + key[3] + " " + key[4] + " " + key[5] + " " + key[6] + " " + key[7] + " " + key[8] + " " + key[9] + " " + key[10] + " " + key[11] + " " + key[12] + " " + key[13] + " " + key[14] + " " + key[15] + " " + key[16] + " " + key[17] + " " + key[18] + " " + key[19] + " " + key[20]);
I have a method getstaffinfo, which has 3 parameter (var_1, connection, filewriter fw), the var_1 value is read from a text file. So the method will be called as many times based on all the var_1 value passed from text file . approx ( 15000)
public static String getstaffid(String var_1, Connection connection,
FileWriter fw) throws SQLException, Exception
// Create a statement
{
String record = null;
ResultSet rs = null;
Statement stmt = connection.createStatement();
boolean empty = true;
try {
rs = stmt
.executeQuery("select username, firstname, lastname, middlename, street, city, stateorprovince, ziporpostalcode, countryorregion, fax, phone, extension, mobile, pager, title, primaryemail, secondaryemail, officename, description, comments, suspendeddate, userdata, employeeid, createuser, updateuser, createdate, updatedate, employeetype, servicedeskticketnumber, startdate, enddate, manager, businessapprover, technicalapprover, delegate, location, jobcodes, customproperty1, customproperty2, customproperty3, customproperty4, customproperty5, customproperty6, customproperty7, customproperty8, customproperty9, customproperty10 from globalusers where username = '"+ var_1 + "'");
ResultSetMetaData metaData = rs.getMetaData();
int columns = metaData.getColumnCount();
ArrayList<String> records = new ArrayList<String>();
while (rs.next()) {
empty = false;
//record = rs.getString(1) + " " + rs.getString(2) + " " + rs.getString(3) + " " + rs.getString(4) + " " + rs.getString(5) + " " + rs.getString(6) + " " + rs.getString(7) + " " + rs.getString(8) + " " + rs.getString(9) + " " + rs.getString(10) + " " + rs.getString(11) + " " + rs.getString(12) + " " + rs.getString(13) + " " + rs.getString(14) + " " + rs.getString(15) + " " + rs.getString(16) + " " + rs.getString(17) + " " + rs.getString(18) + " " + rs.getString(19) + " " + rs.getString(20) + " " + rs.getString(21) + " " + rs.getString(22) + " " + rs.getString(23) + " " + rs.getString(24) + " " + rs.getString(25) + " " + rs.getString(26) + " " + rs.getString(27) + " " + rs.getString(28) + " " + rs.getString(29) + " " + rs.getString(30) + " " + rs.getString(31) + " " + rs.getString(32) + " " + rs.getString(33) + " " + rs.getString(34) + " " + rs.getString(35) + " " + rs.getString(36) + " " + rs.getString(37) + " " + rs.getString(38) + " " + rs.getString(39) + " " + rs.getString(40) + " " + rs.getString(41) + " " + rs.getString(42) + " " + rs.getString(43) + " " + rs.getString(44) + " " + rs.getString(45) + " " + rs.getString(46) + " " + rs.getString(47);
for (int i = 1; i <= columns; i++) {
String value = rs.getString(i);
records.add(value);
}
for (int j = 0; j < records.size(); j++) {
record = records.get(j) + ",";
}
fw.append(record);
}
/*fw.append(rs.getString(1));
fw.append(',');
fw.append(rs.getString(2));
fw.append(',');
fw.append(rs.getString(3));
fw.append('\n'); */
} finally {
fw.flush();
rs.close();
stmt.close();
}
return record;
}
As you can see, am executing a query for 47 values, which could be null or it can have some value.
Then i iterate through this 47 column, take the value and store it to an array list. Then i iterate the array list and write all the values to the string record with comma seperated value. Which is written to a csv file.
But it does not work fine. Any inputs would be appreciated...
You may have already solved the problem. Just let you know that I tried to use your code just now and found the issue was here:
record = records.get(j) + ",";
You should use something like this:
record = record + records.get(j) + ",";
Also change String to StringBuffer will improve the performance.
You didn't write the exact problem you face, but there is one for sure: you never write a line break into the file, so all data gets in one line.
while (rs.next()) {
... // your code, with the for loops
fw.append(record); //writing out the line, from your code
fw.append("\r\n"); //line break -- add this line
} //this is the end of the "while(rs.next())" loop
...