How to create two String from ResultSet to arraylist?
Hi,
Here is my question:
String sql = "select colA, colB from tblA";
String str1 = null;
String str2 = null;
ArrayList al = null;
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(sql);
while(rs.next()){
str1 = rs.getString("colA");
str2 = rs.getString("colB");
}May i know how can i set the str1 and str2 in the ArrayList al?
Thanks.
Hi,
Here is my question:
String sql = "select colA, colB from tblA";
String str1 = null;
String str2 = null;
ArrayList al = null;
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(sql);
while(rs.next()){
str1 = rs.getString("colA");
str2 = rs.getString("colB");
May i know how can i set the str1 and str2 in the
ArrayList al?
Thanks.
is this what you're looking for?
al = new ArrayList();
al.add(str1);
al.add(str2);
Similar Messages
-
How to create XML string from BPM Business Object?
Hello,
I have a business object in my BPM project and I need to transform it in a XML string:
From:
Business Object: Customer
Properties: Name, Age
To:
"<Customer><Name>Robert</Name><Age>17</Age></Customer>"
How can I do this?
Thanks.Hello,
I have a business object in my BPM project and I need to transform it in a XML string:
From:
Business Object: Customer
Properties: Name, Age
To:
"<Customer><Name>Robert</Name><Age>17</Age></Customer>"
How can I do this?
Thanks. -
How to create session id from different string controls
how to create session id from different string controls
fais,
Please create the VI you are talking about and save some default data into all of the controls. Also on the front panel, place the session ID that should be generated by that data. Now, post your VI to a response so I can download it. I can then take this VI and help you create the functionality. (Please post what version of LabVIEW you are using.)
My guess it that you are going to need to use a good number of string concatenations as well as a few string indexes to get parts of strings out. As for the date, you can use a Property node with the Numeric Text.Text property to get the actual string displayed on the front panel for the date and parse out the parts that you want.
Randy Hoskin
Applications Engineer
National Instruments
h
ttp://www.ni.com/ask -
How to improve the speed of creating multiple strings from a char[]?
Hi,
I have a char[] and I want to create multiple Strings from the contents of this char[] at various offsets and of various lengths, without having to reallocate memory (my char[] is several tens of megabytes large). And the following function (from java/lang/String.java) would be perfect apart from the fact that it was designed so that only package-private classes may benefit from the speed improvements it offers:
// Package private constructor which shares value array for speed.
String(int offset, int count, char value[]) {
this.value = value;
this.offset = offset;
this.count = count;
}My first thought was to override the String class. But java.lang.String is final, so no good there. Plus it was a really bad idea to start with.
My second thought was to make a java.lang.FastString which would then be package private, and could access the string's constructor, create a new string and then return it (thought I was real clever here) but no, apparently you cannot create a class within the package java.lang. Some sort of security issue.
I am just wondering first if there is an easy way of forcing the compiler to obey me, or forcing it to allow me to access a package private constructer from outside the package. Either that, or some sort of security overrider, somehow.My laptop can create and garbage collect 10,000,000 Strings per second from char[] "hello world". That creates about 200 MB of strings per second (char = 2B). Test program below.
A char[] "tens of megabytes large" shouldn't take too large a fraction of a second to convert to a bunch of Strings. Except, say, if the computer is memory-starved and swapping to disk. What kind of times do you get? Is it at all possible that there is something else slowing things down?
using (literally) millions of charAt()'s would be
suicide (code-wise) for me and my program."java -server" gives me 600,000,000 charAt()'s per second (actually more, but I put in some addition to prevent Hotspot from optimizing everything away). Test program below. A million calls would be 1.7 milliseconds. Using char[n] instead of charAt(n) is faster by a factor of less than 2. Are you sure millions of charAt()'s is a huge problem?
public class t1
public static void main(String args[])
char hello[] = "hello world".toCharArray();
for (int n = 0; n < 10; n++) {
long start = System.currentTimeMillis();
for (int m = 0; m < 1000 * 1000; m++) {
String s1 = new String(hello);
String s2 = new String(hello);
String s3 = new String(hello);
String s4 = new String(hello);
String s5 = new String(hello);
long end = System.currentTimeMillis();
System.out.println("time " + (end - start) + " ms");
public class t2
static int global;
public static void main(String args[])
String hello = "hello world";
for (int n = 0; n < 10; n++) {
long start = System.currentTimeMillis();
for (int m = 0; m < 10 * 1000 * 1000; m++) {
global +=
hello.charAt(0) + hello.charAt(1) + hello.charAt(2) +
hello.charAt(3) + hello.charAt(4) + hello.charAt(5) +
hello.charAt(6) + hello.charAt(7) + hello.charAt(8) +
hello.charAt(9);
global +=
hello.charAt(0) + hello.charAt(1) + hello.charAt(2) +
hello.charAt(3) + hello.charAt(4) + hello.charAt(5) +
hello.charAt(6) + hello.charAt(7) + hello.charAt(8) +
hello.charAt(9);
long end = System.currentTimeMillis();
System.out.println("time " + (end - start) + " ms");
} -
Heap space error while creating XML document from Resultset
I am getting Heap space error while creating XML document from Resultset.
It was working fine from small result set object but when the size of resultset was more than 25,000, heap space error
I am already using -Xms32m -Xmx1024m
Is there a way to directly write to xml file from resultset instead of creating the whole document first and then writing it to file? Code examples please?
here is my code:
stmt = conn.prepareStatement(sql);
result = stmt.executeQuery();
result.setFetchSize(999);
Document doc = JDBCUtil.toDocument(result, Application.BANK_ID, interfaceType, Application.VERSION);
JDBCUtil.write(doc, fileName);
public static Document toDocument(ResultSet rs, String bankId, String interfaceFileType, String version)
throws ParserConfigurationException, SQLException {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document doc = builder.newDocument();
Element results = doc.createElement("sims");
results.setAttribute("bank", bankId);
results.setAttribute("record_type", "HEADER");
results.setAttribute("file_type", interfaceFileType);
results.setAttribute("version", version);
doc.appendChild(results);
ResultSetMetaData rsmd = rs.getMetaData();
int colCount = rsmd.getColumnCount();
String columnName="";
Object value;
while (rs.next()) {
Element row = doc.createElement("rec");
results.appendChild(row);
for (int i = 1; i <= colCount; i++) {
columnName = rsmd.getColumnLabel(i);
value = rs.getObject(i);
Element node = doc.createElement(columnName);
if(value != null)
node.appendChild(doc.createTextNode(value.toString()));
else
node.appendChild(doc.createTextNode(""));
row.appendChild(node);
return doc;
public static void write(Document document, String filename) {
//long start = System.currentTimeMillis();
// lets write to a file
OutputFormat format = new OutputFormat(document); // Serialize DOM
format.setIndent(2);
format.setLineSeparator(System.getProperty("line.separator"));
format.setLineWidth(80);
try {
FileWriter writer = new FileWriter(filename);
BufferedWriter buf = new BufferedWriter(writer);
XMLSerializer FileSerial = new XMLSerializer(writer, format);
FileSerial.asDOMSerializer(); // As a DOM Serializer
FileSerial.serialize(document);
writer.close();
} catch (IOException ioe) {
ioe.printStackTrace();
//long end = System.currentTimeMillis();
//System.err.println("W3C File write time :" + (end - start) + " " + filename);
}you can increase your heap size..... try setting this as your environment variable.....
variable: JAVA_OPTS
value: -Xms512m -Xmx1024m -XX:PermSize=256m -XX:MaxPermSize=512m -
How to transfer a string from sub sequence to main sequence
Hi,
How to transfer a string from sub sequence to main sequence, My main sequence has included a sub sequence, the sub sequence is return a string value after running done, I need to get this string value from sub sequence to main sequence, I check the defined that look like seem the two
sequence have themself local variable,but I don't know how to defined a globe variable to cover main sequence and sub sequence like VC++'s Main App ,Please kindly help me,thanks in advance...Hi,
I hope this small example will help you.
Regards
Ray Farmer
Regards
Ray Farmer
Attachments:
Sequence File1.seq 36 KB -
How to Create adf table from java bean
Hi,
How to Create adf table from java class (Not from ADF BC).
Thanks
Satya@vlsn -- you have to follow what shay said.
Do the following in Model layer ::
create a table property java class with your columns setters and getters like :
*public class gridProps {*
private int sno;
private String orderNum;
*public void setSno(int sno) {*
this.sno = sno;
*public int getSno() {*
return sno;
*public void setOrderNum(String orderNum) {*
this.orderNum = orderNum;
*public String getOrderNum() {*
return orderNum;
Create another table java class which will populate the values to your column values and return the collection :
*public class gridPopulate {*
private List<gridProps> gridValues ;
*public List<gridProps> setToGrid(ArrayList<ArrayList> valuesToSet) {*
*if (valuesToSet == null) {*
return gridValues;
gridValues = new ArrayList<gridProps>();
if(btnValue.equals("completeBtn"))
return gridValues;
for(ArrayList<String> tempArr:valuesToSet)
gridProps gp = new gridProps();
gp.setSno(Integer.valueOf(tempArr.get(0)));
gp.setOrderNum(tempArr.get(1));
return gridValues;
Right click gridPopulate class and create this as data control.This class will be seen in Data control list.Under this data control,Drag the grid property collection(created earlier) to your page.Then execute your binding(gridPopulate) according to your logic.
Thanks.(My jdev version 11.1.1.5.0) -
How to compare two rows from two table with different data
how to compare two rows from two table with different data
e.g.
Table 1
ID DESC
1 aaa
2 bbb
3 ccc
Table 2
ID DESC
1 aaa
2 xxx
3 ccc
Result
2Create
table tab1(ID
int ,DE char(10))
Create
table tab2(ID
int ,DE char(10))
Insert
into tab1 Values
(1,'aaa')
Insert
into tab1 Values
(2,'bbb')
Insert
into tab1 Values(3,'ccc')
Insert
into tab1 Values(4,'dfe')
Insert
into tab2 Values
(1,'aaa')
Insert
into tab2 Values
(2,'xx')
Insert
into tab2 Values(3,'ccc')
Insert
into tab2 Values(6,'wdr')
SELECT
tab1.ID,tab2.ID
As T2 from tab1
FULL
join tab2 on tab1.ID
= tab2.ID
WHERE
BINARY_CHECKSUM(tab1.ID,tab1.DE)
<> BINARY_CHECKSUM(tab2.ID,tab2.DE)
OR tab1.ID
IS NULL
OR
tab2.ID IS
NULL
ID column considered as a primary Key
Apart from different record,Above query populate missing record in both tables.
Result Set
ID ID
2 2
4 NULL
NULL 6
ganeshk -
How to swap two string variables without using a 3rd variable?
How to swap two string variables without using a 3rd variable?
ex.
A = "aa"
B = "bb"
Result required
A = "bb"
B = "aa"
ThanksHow to swap two string variables without using a 3rd
variable?
Something like this.
Append A with B (so A equals "aabb")
Set B equal to a substring of A starting with the first character and ending at A's length minus B's length. (So B equals "aa")
Set A equal to a substring of A starting from B's length and ending at the end of A. (So A equals "bb") -
How to create xml file from Oracle and sending the same xml file to an url
How to create xml file from Oracle and sending the same xml file to an url
SQL/XML (XMLElement, XMLForest, XMLAgg, etc) and UTL_HTTP.
Whether that works for you with the version of Oracle you have, your requirements, and needs is another story. A little detail goes a long way. -
How 2 read two files from 2 diff. directories, using single adapter
How 2 read two files from 2 diff. directories in same system, using single file adapter.
you can use advanced selection for source file
see
http://help.sap.com/saphelp_nw04/helpdata/en/e3/94007075cae04f930cc4c034e411e1/frameset.htm -
How to create Inbound Idoc from XML file-Need help urgently
Hi,
can any one tell how to create inbound Idoc from XML file.
we have xml file in application server Ex. /usr/INT/SMS/PAYTEXT.xml' we want to generate inbound idoc from this file.we are successfully able to generate outbound XML file from outbound Idoc by using the XML port. But not able to generate idoc from XML file by using we19 or we16.
Please let me know the process to trigger inbound Idoc with out using XI and any other components.
Thanks in advance
Dora ReddyHi .. Did either of you get a result on this?
My question is the same really .. I am testing with WE19 and it seems SAP cannot accept an XML inbound file as standard.
I see lots of mention of using a Function Module.
Am I correct in saying therefore that ABAP development is required to create a program to run the FM and process the idoc?
Or is there something tht can be done with Standard SAP?
Thanks
Lee -
How to create a String with a specific size?
how to create a String with a specific size?
For example I want to create different Strings with the size of 100 , 1000 or 63k byte?String are immutable so just initialize it with the number of characters you want.
You might want to look at java.lang.StringBuffer and see if that's what you want. -
How to create an invoice from multiple sales doc.
Hi,
how to create an invoice from multiple sales doc.
thanx,
souravhello, friend.
assuming that your settings in VTFA and VTFL allow, you can create 1 invoice for many sales orders or deliveries by using VF04. choose all documents that apply and click "collective billing document".
you can also click on "simulation" if you want to test if the combination is possible and the system will give you a split analysis if this is not possible.
regards. -
How to convert a string from upper case to lower case in FOX formula
Hi Experts,
How to convert a string from upper case to lower case in FOX formula?
Thanks,
Cheers!!!
PANKAJThe last result.append( c ) should be:
result.append( Character.toLowerCase(c) );
Maybe you are looking for
-
Hey guys, I need some serious help. I have an external hard drive, iomega which apears to no longer work; I am sure it is something I have done and I cant figure out what! I am certainly not a computer expert and am in Turkey so I dont have access to
-
Security for reprots running by Report Server
Hi When I run Reports in the a Forms application usiing web.show_document() all the parameters including user/password appears in address bar . what should I do ??? Thanx
-
Does Version 10.1.2.0.2 of oracle portal support WSDL
I was able to deploy my JSR 168 portlet through OEM and not through JDeveloper and other issue is that when I try to Register a Provider I don't see an option for WSDL in the Implementation Style when registering a provider. I have Version 10.1.2.0.2
-
< MODERATOR: Message locked. Please post this message in the [Controlling forum|SAP ERP Financials - Controlling;. > Hello all, I need some help from you. Is it possible to stop the depreciation of an asset in SAP? Thanks a lot
-
Hi All, Is there any way so that a file that is encrypted with public/private key methodology can be decrepyted in ABAP. Thanks and Regards