473,396 Members | 1,755 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

java code - help!

Hi, i need a help with my code.

(1) - i am connecting to database
(2) - reading column
(3) - I want to capture all data (rows) into a string
(4) - Pass into a function --> ItemData data = new ItemData(TransactionList);


HOW DO I APPEND ROWS INTO A STRING? --> i am able to do that by using += but i am getting "null" char which i do not want. please help.

Thanks.

so here is short code... let me know if you need more then this i will post it.


try {
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
String url = "jdbc:oracle:thin:@prophet.njit.edu:1521:cours e";
String url1 = System.getProperty("JDBC_URL");
if (url1 != null)
url = url1;
Connection conn = DriverManager.getConnection (url, "ynp2", "Baroda19");
Statement stmt = conn.createStatement ();
// Select the SYSDATE column from the dual table
ResultSet rset = stmt.executeQuery ("select * from HD");
Output.setText("Connection.." + "\n");
// Print the result
//int no=0;


while (rset.next ())
{


if (rset.getString(2) != null)
{
TransactionList = "\n";
TransactionList += rset.getString(2).trim();
}

}

Output.setText(TransactionList + "\n");

ItemData data = new ItemData(TransactionList);
Jul 13 '07 #1
2 1424
praveen2gupta
201 100+
Try following updates

String TransactionList="" ;
while (rset.next ())
{

if (rset.getString(2) != null)
{

TransactionList += rset.getString(2).trim();
}

}

Output.setText(TransactionList);

If you need space the enter suitable code after += opeator.
Jul 14 '07 #2
JosAH
11,448 Expert 8TB
If the ResultSet is large, may I suggest using a StringBuffer or StringBuilder
instead, for efficiency reasons.

kind regards,

Jos
Jul 14 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: James Hong | last post by:
Help please, I try to sending an email from my html page using the java applet. but it give error on most of the PC only very few work, what is the error i make the java applet show as below ...
1
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej...
6
by: Rhino | last post by:
I'm trying to debug a simple Java UDF written in the DB2General style within Eclipse. I'm getting a java.lang.UnsatisfiedLinkError when I execute the set() method in the UDF. I know that the...
2
by: embz | last post by:
this post concerns three pages. 1. this page: http://www.katherine-designs.com/sendemail.php i get the following errors: a lot of it seems to deal with the PHP code i inserted to the page....
0
by: kayox007 | last post by:
hi am working on an applet right now that needs a string variable passed to it from the browser's URL... pls i need help cos i dont know how to go about it and ITS URGENT thanks
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.