|
pancakeleh wrote: however i am rushing out this.
That is a sure recipe for disaster.
You have the following statement within your try block, after you have opened your connection to the database.
if(incidenteidtxt != null){
I would assume that if the value is null there is no point in accessing your database, so you should make this test earlier.
Other than that I cannot quite figure out what your code is doing, although it looks like you are reading the database in sequence, and every time you see a record that does not match the incident id, you call your updateIncident method to do something.
I must get a clever new signature for 2011.
|
|
|
|
|
i have further change my code as shown below:
try{
Class.forName("org.apache.derby.jdbc.ClientDriver").newInstance();
Connection con = DriverManager.getConnection(dbURL);
stmt = con.createStatement();
if(incidentidtxt != null){
id = rs.getInt(1);
if( id == 0){
getSessionBean1().updateIncident(incidentId, instanceName);
}
else{
Integer newIncidentID = incidentId + 1;
getSessionBean1().updateIncident(newIncidentID, instanceName);
}
}
}
catch (Exception ex) {
log("ErrorDescription", ex);
error(ex.getMessage());
}
return null;
}
|
|
|
|
|
pancakeleh wrote:
if(incidentidtxt != null){
1. You still have this test within your try catch block, you should be doing it outside as there is no point entering this block of code if incidentidtxt has a null value.
2. your executeQuery command is commented out; is this what you meant to do?
2a. adding database parameters by string concatenation in this way is extremely dangerous, and leaves your application open to SQL Injection problems: Google it and learn how to avoid it.
3. I am no longer certain what you are actually trying to do here or what your problem is.
I must get a clever new signature for 2011.
|
|
|
|
|
Need urgent help in assignment of JAVA, any idea suggestion plz
I need help in my JAVA assignment plz. kindly guide me any technique/idea to do the following. m not at advance level of programming. i already have the initial part of my assignment completed which is to make a simple command line calculator. this is the next part.
The program should take function definitions and those definitions can be used in future expressions
for eg:
def add(x,y)=(x+y)
>>> ok
def inv(x)=1/x
>>> ok
inv(add(2,2))
>>> ans : 0.25
Also four additional commands:
show; to prints all de?nitions on screen
save flename; to save all defnitions in a fle
load flename; to load all definitions from a fle
delete funname; to delete the defnition corresponding to the function named funname
|
|
|
|
|
See here[^] for information on how to write Java programs. Please do not expect other people to write your assignment for you, unless you are prepared to pay royalties from your future earnings.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
I'm a little confused. You say this is a Java assignment, but the example you have posted looks more like Python to me, not Java. Am I missing something?
|
|
|
|
|
no, this is a JAVA assignment.
|
|
|
|
|
So the assignment is to rewrite the Python example in Java, is that right?
|
|
|
|
|
bro, no we dont know any python. but htis is our assignment in java only.
|
|
|
|
|
aesthetic.crazy wrote: I need help in my JAVA assignment plz. kindly guide me any technique/idea to do the following
You need the following parts
1. Something to read the input that the user types.
2. Something to parse each line into a command and OPTIONAL values since some commands do not have values.
3. Something to process EACH command. Write a method for each command.
4. AFTER you have the above parts and you have TESTED them, then you put them together to create the final program.
|
|
|
|
|
what is processing in the third part? i need to know some idea about how to proceed further after parsing.
|
|
|
|
|
Actually I misunderstood part of the assignment.
It is quite a bit more complicated than I thought although what I said applies for the easy part. In terms of that you would create a method called something like Show() which would display the current defs.
The hard part is the def command. You can do that with groovy in java. But it requires that you do java and groovy which is rather significant for a beginning assignment. Even the management of that without the actual call semantics is complicated.
|
|
|
|
|
My doctor has provided me with a LinkedBinaryTree and asked me to implement a BinaryTree using an ArrayList. I managed to do all the methods except for the Iterators: children(Position v), positions() and elements(). I will provide you the implementation of these methods using Lists, can anyone help me on how to implement them using the ArrayList class?
public Iterator children(Position v)
throws InvalidPositionException{
DNodeList L = new DNodeList();
checkPosition(v);
try {
if(hasLeft(v))
L.insertLast(left(v));
if(hasRight(v))
L.insertLast(right(v));
} catch(BoundaryViolationException e) {
System.out.println(e.getMessage());
}
return L.elements();
}
public Iterator positions() {
DNodeList L = new DNodeList();
if(size() != 0) {
try {
inOrderTraverse(root(), L);
} catch(Exception e) {
System.out.println(e.getMessage());
}
}
return L.elements();
}
public Iterator elements() {
Iterator pos = positions();
DNodeList L = new DNodeList();
while(pos.hasNext())
L.insertLast(((Position) pos.next()).element());
return L.elements();
}
private BTNode checkPosition(Position p) throws
InvalidPositionException {
if(p == null)
throw new
InvalidPositionException("null is not a valid position");
try {
BTNode temp = (BTNode) p;
return temp;
} catch(ClassCastException e) {
throw new
InvalidPositionException("position of wrong type");
}
}
private void inOrderTraverse(Position v, List L)
throws InvalidPositionException, BoundaryViolationException{
checkPosition(v);
if(hasLeft(v))
inOrderTraverse(left(v), L);
L.insertLast(v);
if(hasRight(v))
inOrderTraverse(right(v), L);
}
</pre>
|
|
|
|
|
Can you be a bit more specific with your question: what are you having trouble with? What help are you looking for? People here on this forum will gladly answer any specific questions you may have.
|
|
|
|
|
I want to impliment the methods I posted here using an ArrayList and not a linked List. But I dont know how to do it.
|
|
|
|
|
Well, presumably your professor either thinks you can, or he expects you to figure it out for yourself. You could ask him for help if you are completely stuck.
|
|
|
|
|
Hello my name is Nicolas Khoury, and I have a huge Text compression project to solve, and I'm having a hard time with it. I have all the predefined classes that I need to use, I just don't know what to do. Is there anyone who can give me their e-mail so I can upload the assignment and the classes and help me build the code? if so, please reply to my e-mail: nee-kow@hotmail.com
|
|
|
|
|
nee-kow wrote: Is there anyone who can give me their e-mail so I can upload the assignment
No, I'm afraid this site does not generally work like that. However you could try posting your question in the Collaboration & Beta Testing[^] forum.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
I assume you didn't do the pre-defined classes yourself. Why don't you ask you teacher/lecturer for some help - or maybe start paying more attention in lessons (if you actually go to them)
asking someone else to do your assignments for you is just stupid. If your going down that route then I suggest a career change. Go and do something your actually capable/interested in learning because your just wasting your life (and other peoples) at the minute.
return 5;
|
|
|
|
|
Thank you for for lecture mister Musefan I do appreciate it. However, I need to remind that I am a 20 year old grown man. and I'm a computer engineering student with a GPA of 3.7 in one of the best engineering schools in my country . YES I'm on the distinction list. The point of my thread is to help me get started with the damn project because we didn't acquire much information about the binary trees. Instead of whining to my teacher I thought I'd get a little help from some fellow programmers around the world. I asked for help and not for this lecture. and thank you for reading
|
|
|
|
|
nee-kow wrote: YES I'm on the distinction list
...By getting others to help/do the work for you?
I don't expect everyone to know everything about programming, after all this is what CP and similar sites are all about. But if you are struggling with binary trees and programming to include them then I suggest you ask more related questions. Then what ever useful information you gather then you pull it all together to get your program working.
Who is going to want to email you, get your source code, go through it and make it work for you, and all for free in their own time? Can I share your qualifications if I help you do it?
return 5;
|
|
|
|
|
Look my friend, you don't know me at all, how can you start judging me? I do not let other people do my work. After all I'm going to be an engineer... so I need to learn. Anyhow I don't have to explain myself. The point is, none of my classmates is capable of solving the project because we haven't been well exposed to the tree ADT. I suggested that someone takes the predefined classes, read them, so that he can have an idea on how to solve the project and give me some tips!!! because I don't know how to build a Huffman coding tree! and none of my classmates know. Now I'd be grateful if you can help me, and no I don't mean writing the code for me. However, if you do not wish to help me, and if you only want to mock me with your next reply, then please keep it to yourself.
|
|
|
|
|
Is it always this hard to get any useful information out of you? 3 decent sized paragraphs and so far all I have is binary tree and Huffman coding tree.
You say you have an assignment to do so perhaps a start may be to list the objectives of your assignment - which would have made a good basis to your original question.
Have these predefined classes been given to you as part of the assignment? surely these should be documented or have been explained as to what they do? If not, then I would think about complaining about whoever provided you with them.
return 5;
|
|
|
|
|
This was the whole point of telling you to message me on my e-mail, so I can send you the predefined classes and the assignment itself. the predefined classes are a part of the assignment. They were given by my doctor along with the assignment which is a word document. Everything is explained I just don't know where to post them, that's why I asked someone to text me on my e-mail. Anyways where can I attach them over here?
|
|
|
|
|
nee-kow wrote: Anyways where can I attach them over here?
You don't attach them. We are not here to do your homework for you! You have to ask questions related to what you are having problems with. What parts of your assignment have you done so far? or even attempted?
What you need to do is write a question in the following format...
- What you are trying to achieve (the objectives of the assignment)
- What you have to work with (explain what you predefined classes are used for)
- What you have tried so far (if anything)
- What you are having problems with (needs you to have actually tried something first)
And if you such a great student, why are you in such a hurry to get this done? surely you have not left this until the last minute?
return 5;
|
|
|
|