473,405 Members | 2,421 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,405 software developers and data experts.

Insert Strings from resultset into ArrayList

sunsolaris2000
I've spend all day looking for this and as far as I checked I always stick with an empty ArrayList. I also tried to display just the first record I find and I got null.What should be inserted into ArrayList are only courses, so Strings.

Expand|Select|Wrap|Line Numbers
  1. public String getProfessorCourses(){
  2.        ................       
  3.        //get the id related of the name
  4.    String s = null;
  5.    String sqlQuery = "SELECT courses.title FROM courses INNER JOIN professors_courses ON professors_courses.course_id = course.course_id WHERE prof_id = '"+1+"'";
  6.  
  7.        ArrayList<String> result = new ArrayList<String>();
  8.  
  9.        try {
  10.          rst = stmt.executeQuery(sqlQuery);
  11.         } catch (SQLException e1) {
  12.             e1.printStackTrace();
  13.         }
  14.  
  15.        try {
  16.            //titles are not inserted
  17.             while(rst.next()){
  18.               //s = new String(rst.getString(1));
  19.               //s = rst.getString(1);
  20.                           s = new String(rst.getString("title"));    
  21.                 }
  22.         } catch (SQLException e) {
  23.             e.printStackTrace();
  24.         }
  25.        .........................   
  26.        return s;
  27.       }
Jul 27 '12 #1

✓ answered by sunsolaris2000

SOLVED

I know wherethe problem was

1 2136
SOLVED

I know wherethe problem was
Aug 1 '12 #2

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

Similar topics

1
by: Steve Bishop | last post by:
I'm getting: Server: Msg 107, Level 16, State 3, Line 1 The column prefix 'tMembersClone' does not match with a table name or alias name used in the query. Help appreciated. Thanks. INSERT INTO...
1
by: Steve Bishop | last post by:
I have this stored proc that is to look for changes only between 2 tables and inserts the changes into one of my temp tables that I later delete in my DTS flow. I am running into a problem I...
7
by: Ben | last post by:
Hey everybody, I'm working on a program in c++, and I've come up against a problem that I can't figure out. I don't imagine that it's too difficult to solve, but it has been giving me trouble....
11
by: Chris Fink | last post by:
I have setup an Oracle table which contains a blob field. How do I insert data into this field using C# and ADO.net?
4
by: fix | last post by:
Hi all, I am trying to bind some data I got in an ArrayList, how is that possible? I see no example in the help. The code behind to bind is simple: rptItems.DataSource = alist...
2
by: James | last post by:
below is some codes. my arraylist below reads from a file. My files contains blank line (ie carriage return) My message dialog shows all strings being captured. However i do not want my...
0
by: sadiewms | last post by:
I'm trying to get data from one table into another. The data in the first table - Table A - is something like this: personfn, personln; personfn, personln; personfn, personln I would like to...
48
by: Alex Chudnovsky | last post by:
I have come across with what appears to be a significant performance bug in ..NET 2.0 ArrayList.Sort method when compared with Array.Sort on the same data. Same data on the same CPU gets sorted a...
1
by: harikap | last post by:
hi, im using vb.net 2005 how can i add values to arraylist & how can i retreive those values into one variable or windowsdatagrid view
0
by: Eric Val | last post by:
How i insert to an arrayList a specific column (pg. the ("PhoneNumber")field who has 30 records) from a dataSet C#.
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: 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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.