473,569 Members | 2,593 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Creating a list of objects whose class is known dynamically

25 New Member
I am unable to create a list of objects dynamically. I run a SQL query on the database and populate objects of types that I also know aprior. I read the query as a string, run it on the database and want to be able to populate these objects of classes whose names are known to me also based on the type of the query. In this query, SomeClass is a variable.

Class myClass = Class.forName(" SomeClass");
Object myClassObj = myClass.newInst ance(null);

When I say,

List<myClassObj > myClassObjList = null;
myClassObjList = somDao.getmyLis t(qry);

I get an error, "myClassObj cannot be resolved to a type". This is very important as in my case I have a dynamically created query that is run on the database to create objects of specific type in advance and I am sending these list of objects to a jsp page for display and other purposes.

Thanks in advance.

Regards
Kris
Feb 20 '08 #1
1 1561
BigDaddyLH
1,216 Recognized Expert Top Contributor
Crosspost: http://forum.java.sun.com/thread.jspa?threadID=5266170
Feb 20 '08 #2

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

Similar topics

21
2492
by: Jason Heyes | last post by:
I want to allow objects of my class to be read from an input stream. I am having trouble with the implementation. Here are the different approaches I have tried: // Version 1.0 - Default constructors class MyClass { Foo foo; // foo and bar require default constructors Bar bar; public:
161
7753
by: KraftDiner | last post by:
I was under the assumption that everything in python was a refrence... so if I code this: lst = for i in lst: if i==2: i = 4 print lst I though the contents of lst would be modified.. (After reading that
9
2827
by: Daz | last post by:
Hello people! (This post is best viewed using a monospace font). I need to create a class, which holds 4 elements: std::string ItemName int Calories int Weight int Density
4
3285
by: Rui.Hu719 | last post by:
Hi, All: I read the following passage from a book: "There are three exceptions to the rule that headers should not contain definitions: classes, const objects whose value is known at compile time, and inline functions are all defined in headers. " Can someone explain to me why some of the const objects must be defined in the header...
6
5449
by: RSH | last post by:
Hi, i have a situation where I need to dynamically create objects in a loop. My question surrounds intantiation naming in such a scenerio. Below is a snippet that is basically hardcoding each object. My problem is that I would like to create the objects dynamically but I can't figure out how to do it How would I go about dynamically...
9
3613
by: Tarscher | last post by:
hi all, I have this seemingly simple problem. I have lost a lot of time on it though. When a user selects a value from a dropdownlist (static control) a dynamic control is generated. I have to create the dynamic controls in the OnInit stage of the lifecycle. Since data from static controls is not yet available in the OnInit stage I...
6
3991
by: Amit Bhatia | last post by:
Hi, I am not sure if this belongs to this group. Anyway, my question is as follows: I have a list (STL list) whose elements are pairs of integers (STL pairs, say objects of class T). When I create a new object of class T, I would like to check if this object already exists in the list: meaning one having same integers. This can be done in...
7
7091
by: Abhishek | last post by:
Hi I am using a generic list in my program to have a list of objects stored. I want to compare all the objects in this list with object of another class and find all the objects which meet the criteria. To make it more specific I have a class Employee and a class Salary which look like Employee { Name
6
4916
by: tjboudreaux | last post by:
Hi, This might be a crazy question, but does anyone know how to add variables dynamically to a class. Here's what I want to do. I have a class Model, which I inherit for interfacing with database tables, much like a classic MVC pattern. I want to be able dynamically create a variable for each field in that table. This is sort of what I...
0
7700
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7614
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7924
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8125
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6284
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5219
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2114
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1221
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.