wood burning stoves 2.0*
The moose likes Java in General and the fly likes Polymorphics and Generics.... how to do specific things to a subclass Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Polymorphics and Generics.... how to do specific things to a subclass" Watch "Polymorphics and Generics.... how to do specific things to a subclass" New topic
Author

Polymorphics and Generics.... how to do specific things to a subclass

Janeice DelVecchio
Saloon Keeper

Joined: Sep 14, 2009
Posts: 1665
    
  11

Alright... I thought this might be an issue, but I know you Ranchers can help me through this.

Here's the question:

I have class Student and 3 subclasses: Graduate, Undergraduate, and PartTime.

In my user interface, I do both generic things (like instantiate the subclasses and modify name, etc) and specific things (like change thesis information) to the students.

I needed a way to "get" a student by ID, so I created a method, getStudentByID() .... and had it pull a Student from a map I so craftily created and return the student. I then realized I didn't think this all the way through (before I wrote all this code -- learning the hard way) and remembered my generics. I am going to have some issues doing specific things (i.e. change thesis title) for a couple reasons:
1. How do I keep a user from doing the wrong thing? I mean, typing in a student id and then trying to do part time things to an undergraduate?
2. How do I tell the compiler that I've considered this issue and it's okay? (I mean, after I/we make it okay )

I guess most things won't be an issue. For the most part, the things pertain to all students. They all have a gpa, a firstname, a lastname, and a mentor. I'm worried about the things that are only for the subclasses (like the overridden toString() method in each subclass).

I originally thought to do this in the Student class:


And then code for it in each subclass.... but that doesn't logically work out in my mind... I realized, once I put the Student in the Student map, it couldn't tell what kind of student it was anyways unless I cast it, right? So I'm generally back to square one.

There MUST be a better way. Any help is appreciated


When you do things right, people won't be sure you've done anything at all.
John de Michele
Rancher

Joined: Mar 09, 2009
Posts: 600
Janeice:

Rather than subclassing Student, it may make more sense to create an enum like this:

You can add fields and methods to this if you need some specific behaviors. Also, if your IDs are unique, then you shouldn't need to worry about doing the wrong thing if you combine checking the ID with checking the type of student.

John.
Janeice DelVecchio
Saloon Keeper

Joined: Sep 14, 2009
Posts: 1665
    
  11

Thanks for the help, John... and it makes sense.

But this is again a school project and a requirement is to use a class/subclass hierarchy..... They require class Student, subclass Undergraduate, subclass Graduate, and subclass PartTime, and give me all kinds of requirements on which traits and methods are inherited and which methods of Student I need to make abstract.

This is the last project for this class, and I don't remember them covering enumerations (although I did use two -- one for status, the other for undergraduate level), so I don't think it's a requirement.

Here's what I was thinking after sleeping on this, and you can tell me if I'm crazy:

1. Use Student.getStudentByID() method, which now returns a Student -- for the things that are for all students
2. Create a Graduate.getGraduateByID() method, which will return a Graduate (by casting once its out of the map) for the things only a graduate can do, and likewise for the other 2 subclasses.

This only leaves me with the issue of being sure the subclasses' methods (including the update() method for the db) will run.... but I don't think I can get around that.

My only other option is to create a map for each subclass.... and use a method in the superclass that searches each map and returns the correcly subclassed object.... that seems like trouble too. Or I could use that ENUM with a switch/case to return the correct student type (I'm thinking return PartTime s --- from the Student class.... is that even possible?)

There is a possibility I'm making this harder than it needs to be....... but I'm not seeing it.

John de Michele
Rancher

Joined: Mar 09, 2009
Posts: 600
Janeice:

Well, if you have to subclass for the assignment, then that's what you need to do . Rather than doing a getGraduateId() method (plus corresponding methods), I would suggest that you implement the enum as before, and create a field in your Student class for it. Then, after you pull a Student out of the map, you can:

1) Check for the enum, which will reduce the number of ClassCastExceptions
2) Cast to the subclass
3) Run the methods on the subclass

You'll want to have each subclass override the abstract methods, so then you can tailor the behavior to the specific subclass.

Doing the map thing for each subclass seems a bit extreme .

John.
Janeice DelVecchio
Saloon Keeper

Joined: Sep 14, 2009
Posts: 1665
    
  11

I agree, John, thanks for the help....

One more question:

Can I cast to the subclass from inside the Student class, or do I have to do that outside all the related classes (each time I pull a student out)?

Thanks again so much!
Janeice
John de Michele
Rancher

Joined: Mar 09, 2009
Posts: 600
Janeice:

I would do it outside of those classes. If you do it from inside the Student class, you tightly couple the subclasses to the Student class. This is something you generally want to avoid, because superclasses really shouldn't know anything about their subclasses.

John.
Janeice DelVecchio
Saloon Keeper

Joined: Sep 14, 2009
Posts: 1665
    
  11

Thanks a lot!

Janeice DelVecchio
Saloon Keeper

Joined: Sep 14, 2009
Posts: 1665
    
  11

Ok, this is what I created......



I'm thinking this should work... now I have to rework my application to use this class.
John de Michele
Rancher

Joined: Mar 09, 2009
Posts: 600
Janeice:

Just a couple of nits to pick :

On line 4, is there a reason why you're using a SortedMap rather than just a straight HashMap?
Also on line 4, unless there's really a good reason to make your Map public, I would create a getter, and make that map private.

Other than those, it looks fine.

John.
Janeice DelVecchio
Saloon Keeper

Joined: Sep 14, 2009
Posts: 1665
    
  11

Good heavens!

It IS private! Hmph. I thought if it was a static, it could be accessed like that... I guess I wasn't thinking about my access modifier. I'm on a getter right away!

As for the SortedMap... there are times when I display parts of the map to the screen, and I serialize the Students using this map. If I want them to come back in numerically ascending order, isn't sorted the best way to go? Is there a benefit to using HashMap over SortedMap?

Thanks, as usual, for all your help!!
John de Michele
Rancher

Joined: Mar 09, 2009
Posts: 600
Janeice:

I was wondering that same thing myself. This link was informative .

John.
Janeice DelVecchio
Saloon Keeper

Joined: Sep 14, 2009
Posts: 1665
    
  11

Thanks for the link! I think I'll stick with the TreeMap.

Thanks so much!
Janeice
Janeice DelVecchio
Saloon Keeper

Joined: Sep 14, 2009
Posts: 1665
    
  11

Update:

My StudentGetter is not compiling. The error I'm getting is:

Expected return type T
Returning Student

And I'm not able to do the Part time, undergrad, and grad specific things.... I know this because the places where I'm trying to, I'm getting a compiler error on those too -- cannot find method.

here's part of the interface:



and my Getter:


Any help is appreciated!
John de Michele
Rancher

Joined: Mar 09, 2009
Posts: 600
Janeice:

Ok, I think I see where the problem is. Try commenting out line 19, and the change line 10 to:

Change lines 13 and 16 similarly. See if that works.

John.
Janeice DelVecchio
Saloon Keeper

Joined: Sep 14, 2009
Posts: 1665
    
  11

Got more errors this time:


Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4181
    
  21

The key to using Generic methods is that you need something to tell the method what Run-Time Type to substitute for the Generic T. Nothing in your code does that - and really the only think that can is a parameter with the appropriate Run-Time Type (or with a Generic Type which can be matched to the method's Generic Type).

Here is how I might address your problem:


The Class parameter tells the method what type of Student I want to return. Then I get a generic student, test it's Class against the passed in Class to make sure the cast to the desired type is safe and return the retrieved student if it is. The negative is - what if the student with the given ID is not of the proper type? In my method you get a null value returned so you have to deal with that:


Another method of doing this sort of thing is a type of 'data injection'. Basically, you can keep the Student reference generic if you build a system where the Student decides which menu commands to present, and which functions to call. Here is a quick example. If your system, you have a text based menu which changes per type of student. I could have a MenuMaker class which will build the text menu based on the passed in Student type. In my example I have an overloaded 'makeSpecialMenu' method which takes specific menus with just the commands pertinent to that actual student:


So now I can make it so the Student sub-types call the correct overloaded version of the MenuMaker:


Then in the StudentGetter, you can have a generic get method which uses the Generic Student type to make specific text menus:


Output:


This is a neat way to do things, but it requires you to plan the app accordingly. For example, you would now have the specific Student, and the correct index for the command to run. You would then need to follow the same type of pattern to execute the correct command. So this is something you should think about but might be a little much to implement right now for your homework assignment.


Steve
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4181
    
  21

Sorry, that was far from a Beginner's overview :-( The pattern I described is called the Visitor's Pattern, I think. So if you want to learn more about it you have a search term to look up :-) Like I said before, this was an idea to think about, not something you need to do for your current homework. The first half of the post is more relevant to the homework question.
Janeice DelVecchio
Saloon Keeper

Joined: Sep 14, 2009
Posts: 1665
    
  11

Thanks so much for that, Steve! You put a lot of effort into that, and if I knew of that pattern before I started I probably could have implemented it. As a side note, I have the HeadFirst Design Patterns book around here somewhere.... I wonder if it's in there..... as I get massively distracted.....

As for this:



Maybe now (as usual for me on JavaRanch), after 20 posts, I have finally figured out what I'm not getting. Here it comes.....

What the heck is the 'T' for anyways, and how did I talk myself into using it?


This still looks like I'll have to recast when it comes out of the getter, which I can do, but I feel like it shouldn't be that way.
John de Michele
Rancher

Joined: Mar 09, 2009
Posts: 600
Janeice:

The T is the type. So, if you use the method with Undergraduate.class as the second parameter, T is the type 'Undergraduate'.

John.
Janeice DelVecchio
Saloon Keeper

Joined: Sep 14, 2009
Posts: 1665
    
  11

Uhmmmmm..... can I do this?

Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4181
    
  21

Janeice DelVecchio wrote:
What the heck is the 'T' for anyways, and how did I talk myself into using it?



The T is a Compile-Time place holder for a type which will be specified at Run-Time. In this method declaration:

T is used several times:
<T extends Student> == This method will use the generic Type T, which must be assignable to the Student class type
T getStudentByID(...) == The return type for this method is that same Type T (which we only know is assignable to Student)
... Class<T> ofType == The Class class has a Generic Type, and that Generic T is the same exact type which the generic T definition for this method must be.

So you can think of T as being a place holder and at some point when the method runs a real type must be substituted for the T definition. So in this method definition when we run it as:

UnderGrad.class is a Class Object of type Class<UnderGrad>. At run-time the JVM can then say 'Substitute Class<T> for Class<UnderGrad>' and can then deduce 'All Type T references are UnderGrad references.' Which makes the execution-time method declaration look like this:

The JVM can then substitute the UnderGrad type anyplace it sees the T in source code for that method (in that one execution).


This still looks like I'll have to recast when it comes out of the getter, which I can do, but I feel like it shouldn't be that way.

I am not exactly sure how you are using it. If you get the Student BEFORE calling the sub-menu, then you are probably using the parent Student type, so yeah, you would have to then cast it to a more specific type. But if you just get the ID, then get the job you want to do then you can get the more specific type right off the bat. Example:


See how I delayed the getting of the Student until I knew exactly what kind of Student I wanted to get.
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4181
    
  21

Janeice DelVecchio wrote:Uhmmmmm..... can I do this?



No. You define the variable s to be type Student. No matter what you do between the definition of s and the return of s, s will be a Student, not a sub-type of student.
Janeice DelVecchio
Saloon Keeper

Joined: Sep 14, 2009
Posts: 1665
    
  11

Alright, so I have looked and thought about this.

Sorry Steve, I like John's "getter" better... only because if I have to recast anyways, this will just be an easier implementation at this stage in the game:



As for the recasting:



How bout that?
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4181
    
  21

Steve Luke wrote:... You define the variable s to be type Student. No matter what you do between the definition of s and the return of s, s will be a Student, not a sub-type of student.


Which is why in my sample I have two local variables

The s comes from the Map, because the only thing the Map knows is they are Students. The method wants to return something more specific, an Object of type T, so that is what the toReturn reference is for. The rest of the method is just about making sure the one returned from the Map is of the correct type to be assigned to the toReturn variable.

[As a side note, there are a couple of problems with the method I posted before. 1. what if the ID does not exist in the Map? My method fails in a NullPointerException. 2. what if latter you add sub-classes of some sub-types of students, for example class DoubleMajored extends UnderGrad? In my code the DoubleMajored student would not be treated like an UnderGrad student, which it should be.]
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4181
    
  21

Janeice DelVecchio wrote:Alright, so I have looked and thought about this.

Sorry Steve, I like John's "getter" better... only because if I have to recast anyways, this will just be an easier implementation at this stage in the game:


Lol Whichever is easier. Just giving options.



How bout that?


How and where is s defined? It seems to me like you still have a problem like this:

But because s is already defined as type Student, and Undergraduate is assignable to Student you are implicitly doing this:


Once defined, a variables type can not be changed, so you will still only be able to use s as a Student. You must create a NEW variable of the proper type:
Janeice DelVecchio
Saloon Keeper

Joined: Sep 14, 2009
Posts: 1665
    
  11

If a student is always a student, then why can you do this :



Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4181
    
  21

Janeice DelVecchio wrote:If a student is always a student, then why can you do this :





Because an Undergraduate IS-A Student, which means it can be used just like a Student, everywhere, including being assigned to a Student Reference variable. The Object you created is of type Undergraduate, but the Reference (s) is of type Student. The type of the Reference can't change, but a NEW Reference to the SAME Object can be made with the more specific type.
Janeice DelVecchio
Saloon Keeper

Joined: Sep 14, 2009
Posts: 1665
    
  11

Alright.... I think I fixed it. You boys are up for sainthood for dealing with me.



Better now?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38765
    
  23
Steve Luke wrote:Sorry, that was far from a Beginner's overview . . .
Agree. Moving to JiG
Janeice DelVecchio
Saloon Keeper

Joined: Sep 14, 2009
Posts: 1665
    
  11

Wow. Moving up with the big dogs.....

I MUST be learning something.
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4181
    
  21

Janeice DelVecchio wrote:Alright.... I think I fixed it. You boys are up for sainthood for dealing with me.
//...
Better now?


I am not sure if it compiles and runs, you can test that out since I don't have all the code... If it does AND you understand it then it is better :-)

My philosophy is to cut down the scope of the variables you are using to their smallest scope, and ask yourself what you actually gain from each line of code. For example:

1) When you call this method, you make a second call to the getStudentByID() method (once to get the s reference, and once to get the active reference). Why do you need this second call? Think of this lookup as being your bottleneck. In more complex applications it may very well be (it could be the point you poll from a database for example). Try to make these types of calls the fewest possible times, and only when you absolutely must.
2) If you use this call, it is the most likely place for the method to fail because of the use of T and generics (I am not sure it WILL fail, just looks like the most dangerous point). So perhaps if you get rid of it you can simplify the method.
3) When you call this method you still don't know exactly what type of Student you want which makes things more complex. You don't know what type you want until the user makes a choice from the menu. And once they make that choice and you enter the case statements you don't need the generics (you can do a simple cast). So can you postpone the assignment to a specific type till then? If so, you can get away with a class type check + cast instead of another call to the getStudentByID().

I think you were closer to the cleanest solution when you where using John's getter method (back on your post at 12:36:48). Using that code you just need a specific typed variable with a cast in the appropriate place. I think the code here is more complicated than it needs to be and I am not convinced it does the job.


It also looks like you are putting a lot of code inside a single method (as per this switch on the specific change menu coming inside case 6 presumably from a choice on another menu). Perhaps if you start to move some of the jobs you are doing to different methods it will make the overall coding a bit easier to digest?
Janeice DelVecchio
Saloon Keeper

Joined: Sep 14, 2009
Posts: 1665
    
  11


Still not working..... here are my new errors.... I'm using my last "fix" above.



I must not be using this T correctly because it still thinks I'm using Student.
Janeice DelVecchio
Saloon Keeper

Joined: Sep 14, 2009
Posts: 1665
    
  11

Steve Luke wrote:
1) When you call this method, you make a second call to the getStudentByID() method (once to get the s reference, and once to get the active reference). Why do you need this second call? Think of this lookup as being your bottleneck. In more complex applications it may very well be (it could be the point you poll from a database for example). Try to make these types of calls the fewest possible times, and only when you absolutely must.

The studentID is private, this is the only way I can access it without asking the user again.

2) If you use this call, it is the most likely place for the method to fail because of the use of T and generics (I am not sure it WILL fail, just looks like the most dangerous point). So perhaps if you get rid of it you can simplify the method.

It did. I was posting the same time you were. I messed with it a little and finally got down to 4 errors and a warning.

3) When you call this method you still don't know exactly what type of Student you want which makes things more complex. You don't know what type you want until the user makes a choice from the menu. And once they make that choice and you enter the case statements you don't need the generics (you can do a simple cast). So can you postpone the assignment to a specific type till then? If so, you can get away with a class type check + cast instead of another call to the getStudentByID().

I was thinking of doing validation for each choice when the user picks it. I didn't think having the T would be complex because I thought it would be assigned by the get method that returns a specific type of student, no?


I think you were closer to the cleanest solution when you where using John's getter method (back on your post at 12:36:48). Using that code you just need a specific typed variable with a cast in the appropriate place. I think the code here is more complicated than it needs to be and I am not convinced it does the job.


It also looks like you are putting a lot of code inside a single method (as per this switch on the specific change menu coming inside case 6 presumably from a choice on another menu). Perhaps if you start to move some of the jobs you are doing to different methods it will make the overall coding a bit easier to digest?

There are 5 or six menus. The first menu goes to a method based on the user's choice. All other menus are inside those methods.
My code is complicated and long, and clearly is not doing the job. I have been working on this for weeks and I have never been able to get it to compile and run correctly as a whole. I feel like I'm so close to finishing, but can't figure out the generics and inheritance, which is, of course, the most important part.

I'll go back to the single student getter, and try casting right before using the specific methods. I'll probably have to add validators, too, right?
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4181
    
  21

Janeice DelVecchio wrote:
Steve Luke wrote:
1) When you call this method, you make a second call to the getStudentByID() method (once to get the s reference, and once to get the active reference). Why do you need this second call? Think of this lookup as being your bottleneck. In more complex applications it may very well be (it could be the point you poll from a database for example). Try to make these types of calls the fewest possible times, and only when you absolutely must.

The studentID is private, this is the only way I can access it without asking the user again.

Oh, I think you misunderstood me. I meant at some point you are probably doing this:

Then you are latter calling

It is the get.getStudentByID() method that you should try to avoid calling more than necessary, especially in this case, since presumably the Student being returned is the same Student as you already have (it has the same ID).

...

3) When you call this method you still don't know exactly what type of Student you want which makes things more complex. You don't know what type you want until the user makes a choice from the menu. And once they make that choice and you enter the case statements you don't need the generics (you can do a simple cast). So can you postpone the assignment to a specific type till then? If so, you can get away with a class type check + cast instead of another call to the getStudentByID().

I was thinking of doing validation for each choice when the user picks it. I didn't think having the T would be complex because I thought it would be assigned by the get method that returns a specific type of student, no?

No. The T would have to be determinable before the edit() method could execute (the T is part of the method signature, which means that it must be resolved as the method is being looked up - before it is executed, it can't be resolved as part of the execution of the method). The way your method is designed the Type of Student you are working on is creeping ever farther up the chain of events. Keep it as a need to know - shortest possible scope. I don't think edit() should be a Generic method.


I think you were closer to the cleanest solution when you where using John's getter method (back on your post at 12:36:48). Using that code you just need a specific typed variable with a cast in the appropriate place. I think the code here is more complicated than it needs to be and I am not convinced it does the job.


It also looks like you are putting a lot of code inside a single method (as per this switch on the specific change menu coming inside case 6 presumably from a choice on another menu). Perhaps if you start to move some of the jobs you are doing to different methods it will make the overall coding a bit easier to digest?

There are 5 or six menus. The first menu goes to a method based on the user's choice. All other menus are inside those methods.
My code is complicated and long, and clearly is not doing the job.

Don't be discouraged. You aren't far. And I think you can easily simplify things by moving the code for each case block into its own method. This would help you consider scope and keeps each task isolated from others and cohesive in itself. For example:


Then you can think about things in the smallest possible scope. From what you have learned so far you should know that the methods setStudentLevel() and setStudentThesisAdvisor() are broken. The rest of the code (as written here) is functional. Your job is pretty easy. Take setStudentLevel() and change it so it works. Then take setStudentThesisAdvisor() and change it so it works. Don't change any other code - and as a hint there is no need to call getStudentByID() again, and I have already described the fix.

I have been working on this for weeks and I have never been able to get it to compile and run correctly as a whole. I feel like I'm so close to finishing, but can't figure out the generics and inheritance, which is, of course, the most important part.

You are close. There is really very little you need to do from the code you posted Yesterday @ 12:36:48. Making the methods is just a way to help you concentrate on where the problem is (don't change anything outside of the case statements. Putting the case statements in methods helps you narrow the focus on where the problem - and thus the fix is.

I'll go back to the single student getter, and try casting right before using the specific methods. I'll probably have to add validators, too, right?

That sounds like a good plan - a quick test to make sure the classes match or are assignable to the necessary type is all that is needed.
Janeice DelVecchio
Saloon Keeper

Joined: Sep 14, 2009
Posts: 1665
    
  11

I finally got it to run.... and got a boatload of errors when it started......



I don't really know how to interpret these.... any ideas?
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4181
    
  21

I finally got it to run....

Wooh!

and got a boatload of errors when it started......


Awww.... Well, you have only two errors really:

1) java.io.FileNotFoundException: registrar.ser (The system cannot find the file specified)

I am guessing at some point in your code (okay specifically at StudentRegisterApp.java:10) you are trying to de-serialize a stored version of the student registry (or at least read from a File which looks to me like a serialized version...). The serialized version must be stored in the file called 'registrar.ser.' The problem is the 'FileNotFound.' Apparently the file is not in the location you are trying to read it from. To fix it you need to know where the file IS found, and where the application is looking for it. Then you need to make sure they match.

2) java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

Somewhere in your code (okay, specifically at Student.java:7) you are trying to use the MySQL JDBC driver, but the Driver 'ClassNotFound.' This usually means that there is a JAR which is missing from your classpath. To fix it you need to add the JAR to your classpath. Now, you compiled the class fine, which means you have the JAR somewhere. You just need to make sure the classpath you are using for compiling your code is the same one you use for running the code.
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18825
    
  40

Janeice DelVecchio wrote:
I don't really know how to interpret these.... any ideas?


Well, you have two exceptions, along with their stack traces....





Give it a shot. What do you think the errors are?

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Janeice DelVecchio
Saloon Keeper

Joined: Sep 14, 2009
Posts: 1665
    
  11

Okay.... the first one.... I thought that if the file didn't exist the JVM would create it for me. The file doesn't exist because this was the first time the application tried to run.

And the second one... I installed the driver for the mysql. I don't understand why i'm getting this error.

.... it looks like a lot for only 2 errors. I got scared.

Thanks for all the undying support!
Janeice
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4181
    
  21

Janeice DelVecchio wrote:Okay.... the first one.... I thought that if the file didn't exist the JVM would create it for me. The file doesn't exist because this was the first time the application tried to run.

Nope, you should check if it exists first, and only try to open it if it does. The File JavaDocs may be of help.

And the second one... I installed the driver for the mysql. I don't understand why i'm getting this error.

It is installed (after all the compiler knows where it is) you just have to tell Java where it is.

.... it looks like a lot for only 2 errors. I got scared.

Like Henry said, the rest is the stack trace. To read them start at the top line, where you will find the Name of the Exception and a message. Then each line that begins with 'at' is a line of code that was called that eventually led to the error. Trace it from the top to the bottom till you see something that you wrote. For example: "at StudentRegisterApp.main(StudentRegisterApp.java:10)" tells us the error occurs in the StudentRegisterApp Class's main method, in the StudentRegistarApp.java file at line 10.

Thanks for all the undying support!
Janeice


No problem, that's what we are here for :-)
Janeice DelVecchio
Saloon Keeper

Joined: Sep 14, 2009
Posts: 1665
    
  11

OK I think I got it, but I'm getting a compiler error.... something is wrong with my syntax.....



As for telling Java where to find my driver, do I put that in the application? This is what I have....

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Polymorphics and Generics.... how to do specific things to a subclass