masijade 1,351 Industrious Poster Team Colleague Featured Poster

And your file exception is? (FileNotFound I'm betting). That simply means that your program is executing using a different "current working direcetory" than what you expect (which can always be the case whenever it is run). You should avoid using relative paths and attempt to use the complete path (or a path dependent on the classpath and getResource...).

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Keep an ArrayList of the "keys" (those fields which iniquely identify the record), then use contains before adding the record.

Another way, would be to define a "primary key" in the table, then simply attempt to insert the records and catch the "duplicate key" SQLException.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

"\\s+"

Read the API docs for Pattern and Matcher, the String functions work the same way (and, although I haven't checked that they do, they probably use those behind the scenes).

masijade 1,351 Industrious Poster Team Colleague Featured Poster
public static double averageScores(double[] g) {
        double total = 0, a;
        for (double  i = 0; i<g.length; i++);
        total = total + g;
        a = total / g.length;
        return a;
    } //end averageGrades()

In the above code, the line where you are declaring total (and I assume declaring "a") is wrong. Declare (and define with 0) each of them on a separate line.

You also realise (right) that your for loop does nothing, as it ends at the ";" that follows it.

And the next line, where you are suppossed to be doing the summing (inside of the for loop, but which at this point is outside of it) you are attempting to add together the double total, and the reference value of the array "g". I can only assume, that you meant to index into the array using the loop (i.e. g instead of g).

Also, you have defined your method to take an array, but the point at where you're calling it, your passing it a double. I assume you wanted to get, and store all scores before passing them to the method as an array all at one time, rather than one at a time, as you are doing now.

Also, on your if line

if ((score < 0.0) && (score > 10.0)) throw new NumberFormatException();

You do realise that a Number cannot be both less than 0 and greater than 10, right? I can only assume you meant to use …

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Rather than StringTokenizer try using split with the regex "\\s*,\\s*"

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Ha! I'm sorry, but do you know what the "common" meaning of the phrase "stuck up" means?

It means someone who acts and/or thinks as though they are better than everyone else, i.e. arrogant in the most irratating and annoying way.

Just thought you might like to know, since you titled your thread "I am stuck up".

masijade 1,351 Industrious Poster Team Colleague Featured Poster

We might, if we knew what you meant by "difficulties".

Is it not compiling?
Are you getting Exceptions when running?
Are you not getting the expected Results?

We need some more (actually, alot more) detailed information.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

I don't know that Access supports Scrollable ResultSets over the bridge, but I'm not sure, and can't really tel you more, because I, myself, don't use Access. I find it to be the worst DB choice available.

masijade 1,351 Industrious Poster Team Colleague Featured Poster
top -b -n 1 > whatever 2>&1
masijade 1,351 Industrious Poster Team Colleague Featured Poster

No, in all likelihood it is not, though allocating such variables in loops can lead to excess GC activity - and even in that case there is a good chance the JIT compiler will re-use a single reference instead of creating a new one each time anyway unless subsequent assignments make that impossible. The short answer is store the calculation in a local variable.

Actually, the space for the variables is allocated at the "method" level. So, declaring a variable before the loop, or in the loop, has no additional effect what-so-ever. ;-)


Edit: Doing an operation (of any kind) is always more expensive than simply accessing a variable, but, unless it is a very involved calculation, the difference is not enough to be noticed, unless it is being carried out millions or billions of times (such as in simulations, as I already said).

masijade 1,351 Industrious Poster Team Colleague Featured Poster

What do think? Is it more effecient to smithy a new knife every time you need one, or to use the same one again?

But pay attention to what you've already been told. The reusabilty and definately maintenance of the code should be the first priority. Usually, with today's processors, you don't have to worry about effeciency hardly at all (but only hardly, let's not get carried away, here), unless your doing simulations or something to that effect.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

The "alignment" values for a label, are only for the text's alignment within the label, not the alignment of one label with another, or the label with it's container.

If you think you're up to the task, try using a JTable. If not, then try using a GridLayout (instead of the default FlowLayout in your panel), or even better, since the "field" widths should vary, a GridBagLayout (although I believe this one is definately beyond you, but don't feel bad, many experienced programmers have a bear of a time getting it right, if they ever do).

masijade 1,351 Industrious Poster Team Colleague Featured Poster

What does the API docs say it does?

http://java.sun.com/javase/6/docs/api/java/awt/Component.html

P.S. You may wish to also call repaint() on "mainPanel" after the validate.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

After adding the labels, be sure to call validate() on "mainPanel".

masijade 1,351 Industrious Poster Team Colleague Featured Poster

For whatever you want.

It works extremely well for things like hit counters and authentication checks, though.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Okay. Good luck with that.

P.S. We are not just simply going to do it for you, whatever "it" is.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

And there is a large list of tutorials in a thread tacked to the top of this forum.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Yeah, take a look at the classes in the security (JSSE) package

http://java.sun.com/javase/6/docs/api/java/security/package-summary.html

masijade 1,351 Industrious Poster Team Colleague Featured Poster

dear all,

I know how to correctly execute SQL statement using con.execute()

No you don't, seemingly, since that's not right.

(where con is type of java.sql.Connection). But how can I execute Microsoft Access Query Object, which require one or more parameters?

Do we need to use PrepareStatement ?

Thanks

Statement, PreparedStatement, CallableStatement, whichever one is more suited to the task.
Read the JDBC tutorial.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

There is one tacked to the top of this forum.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

in fact the setSize method usually has no effect whatsoever as the frame will automatically resize itself according to the sizes of the components it contains.

Actually, if call setSize after pack, then call validate before calling setVisible, it works just fine (as it is pack that "resizes" the JFrame).

Not that I find it necessary to do so, but some people want to. ;-)

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Set the proper component size for the JTextArea.

JTextArea(String text, int rows, int columns)
// or
setColumns(int columns)
setRows(int rows)

Edit: And, you will probably want to place it in a JScrollPane.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Well, equals compares the String values (the String equals method that is, of course) of the referenced Objects. The String value of the null reference is "null" not "". Keep that in mind. ;-)

masijade 1,351 Industrious Poster Team Colleague Featured Poster

A frame will size itself according to the components contained within. Whether that answers your question about the "data" remains to be seen (since I, obviously, have no idea how your displaying that "data"). But, as a hunch, no, you do not have to use setSize() on a JFrame.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

No, really?

And do you actually want an "n" after the period, or did you mean "\n" for a newline (which is also redundant since println adds a newline anyway)?

Aside from the fact that it is counter productive to simply spew out the answer (the student learns nothing that way), the question has already been answered (here also if the OP was willing to use that thing between its ears) in a cross-posted thread, since the OP wasn't willing to use it.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

You want to stop it from "hurt more comps" (not that I believe either wrote one, or that you want to stop it), go to the police with your virus and give them a detailed description of your first use of it.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

First, as the others have said, Excel is not a DB, and you shouldn't be using it as such.

Second of all, this is an SQL question, not a Java/JSP/JDBC question. Next time, find an SQL forum.

.... where HR IN ( ....

not

.... where HR = ( ....

Edit: This should, at least, be a valid SQL now. Whether it gives you what you want is another question.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

BTW, read the thread referenced. The last post in that thread contained some pointed info and questions. If the OP had read that info, then answered the questions, the problem, and it's solution would have become painfully obvious. Seemingly though, the assignment wasn't important enough for the OP to show any effort.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Now I don't want to start a flame war...*usually followed by a flame war*

but we're brand new at this stuff. We're already confused and not getting it-thus we come to a forum of people with more experience than we for assistance. We've already read a book or had the teacher show us something and it just isn't gelling. Your response was pretty much the same as whats in the book.

Sometimes it takes someone leading you to a place by the nose and showing you what they are talking about. But please don't let me sound ungrateful. I greatly appreciate it when I can get the assistance of someone else. Just sometimes it takes a direct example.

And I understand that you and dozens of other people taught themselves *insert language here* in less than a week or in some light reading. Like many things on the web responses like that don't help the situation at all and merely show an air of condescension and attempted superiority.

Thank you to the people that did post several helpful suggestions. They were very useful in advancing to the next step of this project.

Did you actually read the thread pointed to there?

Do you know how much he would have learned had I simply posted the correct version of that line of code? Nothing.

Do you know how much he would have learned had he actually thought and then corrected the problem himself using the very detailed descriptions he …

masijade 1,351 Industrious Poster Team Colleague Featured Poster

@OP

what was wrong with this thread

http://www.daniweb.com/forums/thread114556.html

Oh, wait, don't tell me. You were upset that I didn't simply give you the answer, but rather tried to make you think. That must have hurt, man. I can't imagine the pain.

Ungrateful kids these days.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

It might help if you showed your code (and hopefully the DB stuff is in a bean and is not a scriptlet in your jsp), and then trying to better explain what it is you want, because I'm not at all sure of what it is you're asking here.

Also, use code tags when you post your code.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Why are you continually creating new threads on the same topic?

Why don't you simply reply to one of the threads you've already created? This is getting ridiculous.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Do not cross-/multi-post, it is extremely rude. Stick with one thread, please.

Google has all sorts of code for you, you simply need to be competent enough to modify it for your needs.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

And? What dfo you have so far, and where are you having a problem? We are not going to do it for you.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Do not cross-/multi-post, it is extremely rude. Stick with one thread, please.

Google has all sorts of code for you, you simply need to be competent enough to modify it for your needs.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

No idea what you're actually talking about, but yes, there are plenty of people here who can, and will help you. No one here, will do it for you though.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

If you want to use the decimal values, then there is no need for either a \ or ' characters, as the decimal ascii "escape code" is the same as the integer value for the char. So, simply do

char c = (char) 29;
masijade 1,351 Industrious Poster Team Colleague Featured Poster

Hi, thanks for the reply.
How the does the compiler converting it to equivalent char? is it finding some matching char for that or? I did look into ASCII table, but the character i find was different character from the one which above program prints.

How does java interpreting '\21' and '\29'(for eg.) there are some other examples which compiles and some not. How to recognize given an example whether char c='\21'; or char c = '\29'; that java recognizes?.

katharnakh.

See my post. Those are the octal and not decimal values. (I know, we probably "crossed" our replies).

masijade 1,351 Industrious Poster Team Colleague Featured Poster

It's because those are octal escape codes, and there are no 8s or 9s in octal numbers.

Edit:

Also a char is a single character. So '3' is okay, but '33' is two characters, so it is not okay.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

1) The same as the difference between regualr shell scripting and CGI (although much more "complicated" on both parts).

2) No.

3) In a J2EE application (saying more won't really help you anyway, until you're familiar with J2EE).

masijade 1,351 Industrious Poster Team Colleague Featured Poster

I assume it's these lines that are causing the problem?

...
Student student1 = new Student();
...
Student student2 = new Student();
...

Well, that would be because they are attempting to use the default constructor, and your class doesn't have one. The compiler will automatically create a default constructor for your class, only if you haven't defined any constructors. As soon as you define a constructor, the compiler will no longer create the default constructor.

So, if you want to be able to call a constructor with no arguments, you will need to define a constructor with no arguments (or delete all other constructors, which would probably be counter-productive).

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Hi, this is sugarskull
and you just responded to my problem and you put that i needed to check the quotes but what should i put them on and why does my error on clem say ')' expected?
System.out.println("firstVar is 13" or greater. \n);
if you can please help me i will appreciate it!!!
Thanks Sugarskull

I gave you another hint. Have you even tried to change anything yet? I am not going to give you the answer. I will give a third hint, and say that, in that statement, as soon as the String literal ends, the compiler expects the closing paren. Where, in that statement, does your String literal end, and where is your closing paren? Where should the String literal end?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

A literal String, such as that, has a quote at the front and at the end. I assume that the entire contents betweens the parens should be a literal String, right? So why is the second quote (which ends the String literal) in the middle of it?

masijade 1,351 Industrious Poster Team Colleague Featured Poster
System.out.println("firstVar is 13" or greater. \n);

Notice the placement of the quotes.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Well, why don't you use a table? A table with a border, padding, and spacing of 0 will give the appearance of text columns.

The other option, since the console print looks correct, is to surround the block with "pre" tags.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Yeah, show us what you have and we might help you correct/finish it, but we are not going to do your (home)work for you! If that is what you are expecting, then you deserve to die the death of 1000 tortures.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

@OP
Refactoring does not necessarily mean "poorly written". It simply means you want to accomplish what is being done ina different manner.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

What is wrong with using the String.format() method or PrintWriter.printf() method?

Edit:

Nevermind.

It's suppossed to have

&nbsp;

in it's body.

What are you viewing the output with, however. You show what you are doing, but what is this a part of?

A servlet, A JSP, a standalone application? There is a lot of missing context here.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

The same, of course, except that you modify what should be modified before writing it to the new file.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

what kind of a programmer are you??You can even help a new programmer in a very little problem...

Help? yes. Do it for you? NO!

What do you have so far?