473,394 Members | 1,748 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,394 software developers and data experts.

SQL Server into Java array

ck9663
2,878 Expert 2GB
Hi guys, CK here from SQL Server forum.

Is there a function that will automatically populate a two-dimensional array coming from a SQL Server table? Or should I do it the old fashion "WHILE NOT EOF" way? Am not much of a java programmer but I need this one.

I can connect to my sql server and query the table. I just need to know how to place it to an array.

Can anyone give me a sample code or some links?

Thanks

-- CK
Jun 2 '08 #1
1 1864
BigDaddyLH
1,216 Expert 1GB
If you are coding this just using JDBC you do the following:

1. Define a specific class to represent one row of data. In my example, this is BusinessObject.
2. Store the data in a list rather than an array, because you don't know ahead of time how many rows are in your result.

Example:

Expand|Select|Wrap|Line Numbers
  1. ResultSet rs = ...
  2. try {
  3.     List<BusinessObject> result = new ArrayList<BusinessObject>();
  4.     while (rs.next()) {
  5.         BusinessObject row = new BusinessObject();
  6.         //populate row with data from rs
  7.         result.add(row);
  8.     }
  9.     return result;
  10. } finally {
  11.     yourCloseMethod(rs);
  12. }
  13.  
Jun 2 '08 #2

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

Similar topics

0
by: Benoît | last post by:
Hi, I have a problem with the string array type. I want to send a string array from the php client to the java server (Webservice with SOAP). Here is the code : ----- Java server method : -----...
0
by: helldiversafe-news | last post by:
Hi all, I will use a apache soap service with an .net c# client and have a problem with an complex array: <?xml version='1.0' encoding='UTF-8'?> <SOAP-ENV:Envelope...
0
by: Eric | last post by:
Hello I wan't to use a client PHP XMLRPC with my Java server XMLRPC. For simple type, all works fine. But for type like array, my server java lose my parameters ! How can I know if it comes...
2
by: Jobs | last post by:
Download the JAVA , .NET and SQL Server interview with answers Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This will help you judge yourself are you really worth of...
2
by: rookiejavadude | last post by:
I'm have most of my java script done but can not figure out how to add a few buttons. I need to add a delete and add buttong to my existing java program. Not sure were to add it on how. Can anyone...
0
by: r035198x | last post by:
Inheritance We have already covered one important concept of object-oriented programming, namely encapsulation, in the previous article. These articles are not articles on object oriented...
4
by: surja | last post by:
Hi, I have written a code to download images from a server end desktop, but while running the code ,WTK is showing a runtime error " Create image from Byte array Uncaught exception...
0
by: sathyguy | last post by:
when i type the below in my RHEL AS 4's Firefox 1.5 http://appsworld.ncc.com:7777/forms/...&form=test.fmx iam getting the below error... The requested URL /forms/frmservlet was not found on...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...

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.