masijade 1,351 Industrious Poster Team Colleague Featured Poster

The MySQL documentation shows you which class, at the very beginning of the page I linked to, and the tutorials (and the MySQL docs) show you how to use it. Read those.

Edit: Besides, why would you be loading a postgresql Driver (jar) when it is mysql (according to your title) that you want to connect to?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

You don't load the jar, you load the Driver class and include the jar on the classpath. See the Tutorial and the MySQL manual for MySQL specific examples

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Configure the ssh to use private keys.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

So use a JTextArea, then, instead of using System.out.print or println, you use the JTextAreas append.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

I have no idea what you are talking about.

Maybe you should provide a bit of a sample of the data you start with and then a detailed explanation of what you are doing with it (showing the modifications to that data).

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Because without the static, that Test t = new Test(); is an instance variable, that is instantiated with every call to new. So, you call new Test() in main, which triggers another new Test, which triggers another new Test, which triggers another new Test, which triggers another new Test, which trig.....

BestJewSinceJC commented: good advice :) +4
masijade 1,351 Industrious Poster Team Colleague Featured Poster

No it doesn't.

Does the real class maybe have a constructor?
And does that constructor maybe also call new on itself?
If so, what do think will happen if every call to new results in another to call new?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Ahh, nevermind, I must have looked at a join date or something. Not, I repeat, not a zombie thread.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Considering that you mentioned "email2.php", I assume you are running this from a hosted server? Well, does the "jar" run from the server? You say the "jar" worked, do you mean locally, or from that hosted server. Because I have the feeling that your site provider's firewall is refusing the connection, in which case you can try anything you want and it's not going to work.

Edit: Nevermind. I, finally, actualy looked at the code and see that script is a site the "program" is attempting to use.

Edit: Aaaaaaaarrrrrgggghhh and I also just now noticed that this thing was a year-long dead zombie thread.

Please do not resurrect old threads. I am fairly positive the OP is not still looking for answers from this thread, and that post is only a thinly veiled advertisement.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Strings can, of course be values in a hastable, but what does that have to do with the rest of the question?

What do you mean by "method generated Strings" and "plug them into another method"?

Also, whatever it is, HashMap would probably be a better choice than Hashtable, unless you have some specific reason for synchronizing access to it.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Strings can, of course be values in a hastable, but what does that have to do with the rest of the question?

What do you mean by "method generated Strings" and "plug them into another method"?

Also, whatever it is, HashMap would probably be a better choice than Hashtable, unless you have some specific reason for synchronizing access to it.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

might help to know what this getOccurredDate method looks like, or what Class it's from if it's not yours.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

trim returns a String (as the API docs state), so where are you storing that String? Strings are immutable (which you should already know) which means you cannot change their contents. You can only create new Strings.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Between reading the String and adding it to set, of course. Do you need someone to hold your hand when using the bathroom?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Uhm, no. He's using Strings and they are already comparable.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

to be found in the API docs.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Try using trim on the Strings before you add them to the sets.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

toBinaryString only produces as many bits as is necessary to show the value. With negative numbers this should always be the complete amount as the leftmost digit is the "negative" indicator, but for positive numbers it is less. For example the number 10 will produce 1010 instead of 0000000000000000000000000000001010. You will need to "leftpad" the numbers yourself.

Here are two easy ways:

String base = "00000000000000000000000000000000";
String num = Integer.toBinaryString(10);
String complete = base.substring(0, 32 - num.length()) + num;
System.out.println(complete);
String complete2 = String.format("%32s", num).replace(' ', '0');
System.out.println(complete2);
masijade 1,351 Industrious Poster Team Colleague Featured Poster

Okay. What do you have so far?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

A bare number that starts with zero is an octal number. And octal numbers cannot include either an 8 or a 9. Remove those zeros.

masijade 1,351 Industrious Poster Team Colleague Featured Poster
masijade 1,351 Industrious Poster Team Colleague Featured Poster
masijade 1,351 Industrious Poster Team Colleague Featured Poster

Well, I know how I would do it. The real question is how you think it should be done. We are not a homework service. Post your attempt at it here and we will help you correct it. We are not, however, going to do it for you.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Not a good beginning.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

There is nothing wrong by putting the database connection in the JSP,

Yes there is. You have obviously never worked on anything that lasted more than a few days, or ever needed to be expanded or improved or fixed. Scriptlets are a maintenance nightmare. At the very least use a bean.

but you have to create a new database connection and query for every page you creates.

Hopefully you mean retreiving one from a Connection pool and not actually creating one with every query. That would be a performance nightmare.

This will reduse the performance and response on server. This is one of the problems.

(I guess you didnt mean using a pool.) Not with a Connection Pool, and every web container (which you must be using to use JSP) has a connection pool, so no problem.

Instead you could create a connection class and put it into application scope and the connection will be made when server is started. This is done only once. Then it is available for all objects that uses table info from the database.

Yet another bad suggestion. A static, single connection used by a dynamic (God I hate that word) threaded application? What happens when one thread calls rollback directly before another thread was about call commit? Or the other way around?


Connection Pools, Beans, and a properly implemented layered approach. Everything presented here is ....... well, I don't think I really need to say it.

masijade 1,351 Industrious Poster Team Colleague Featured Poster
masijade 1,351 Industrious Poster Team Colleague Featured Poster

Yes, CardLayout is a good option, but doing other's work for them is not. Simply suggest CardLayout and link to the tutorial for it, or give a "generic" example of it.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

call validate and then repaint (on the entire JApplet, i.e. just like you're calling getContentPane), rather than that content.paint call.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Okay, now the question is whether you really want to replace the current list with the list that method returns, or if you want to add the items (not already included in the list) returned from that method into the current list. Before it was doing the second, now it is doing the first and they are two drastically different things.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

To help them learn. Definately not to do their homework for them.

Get them to attempt it, and post their code. Then, give them pointers on what they then need to do to fix that code, and get them to do it and post it again.

IOW, make them think. When you do it for them, they learn nothing.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Okay? So why are you attempting to do other's homework for them?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

By adding the xlint option shown in the warning to the javac command (how you do this with any IDE you might be using depends on the IDE, read its manual). In any case, as I said, that depended on what getSynonyms returned. Your problem, if you want this warning to go away, goes much deeper. See http://java.sun.com/docs/books/tutorial/extra/generics/index.html.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

If you "need codes", then you'd beter write some "codes", as we are not going to give them to you.

I for one would not appreciate, one day, ending up being a coworker of yours and continuing to do your work for you after you cheated your way through your classes.

Edit: As far as a site where you might find some code, but will definately be able to find some real help, try Google.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

If you "need codes", then you'd beter write some "codes", as we are not going to give them to you.

I for one would not appreciate, one day, ending up being a coworker of yours and continuing to do your work for you after you cheated your way through your classes.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

It's because you're not using generics. Also, if you look at the compiler message it is a warning, and, in this case, I believe you could ignore it. However, since you are doing all your work with Strings, then, currently, every where in your code where you currently have List (and I do mean everywhere), change it to List<String> .

Edit: Then again, that also depends on this "word" instance and what it's "getSynonyms" returns.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Okay? So why are you using "$a[...]" when your array is @data1?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Does it have a "package" statement? Probably not. You need to do more than simply copy the "class" file around. You have to actually declare the package in the source file and compile it as such.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Have you actually tried doing exactly that?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Yes, I can see that they are either tools to create Java code, or tools written in Java, but neither of those makes the problem a Java problem.

Looking at the homepage for this "CUP" thing (http://www2.cs.tum.edu/projects/cup/) shows a list of related persons with links to their web pages. At least some of those webpages contain email addresses. I would say to start there.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Yeah, ask at a site that pertains to this JLex and/or CUP thing you're using. I, myself, have never heard of them.

Truth be told, this problem doesn't seem to apply to Java, at all, but rather to these tools that you're using.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Yeah, let the plugins do their own work. In other words, the"main" app should not be attemtping to "build" the GUIs for the plugins. The plugins should be building their own own GUIs. Define an interface with a "getPanel" method. The "plugins" then need to construct a panel (with everything on it that they need), and create any needed listeners, in their constructor. The "main" app then need simply call "getPanel" and add that panel to the "main" GUI.

If the "plugin" is to be able to use functionality from the "main" app, then you also need to define an API for that.

The "main" app should never attempt to do any of the work for the "plugin" the "plugin" needs to be self contained. Anything else is just begging for problems, as well as an overcomplicated configuration.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Edit: No idea why this double posted.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Well, of course it can't if you don't have any code for it.

At least make an attempt.

As a hint, save the total amount made today in a variable, then triple that amount into another variable, then add that back into the original variable and repeat the process. A for loop is enough.

Now, make an attempt at it and post that code if it doesn't work.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

And your code? And your question? Just so you know, we are not going to do it for you.

masijade 1,351 Industrious Poster Team Colleague Featured Poster
Painting pl = new Painting(/*whatever*/);
pl.setValue(/*whatever*/);
if (/*famous painting check*/) {
  pl = new FamousPainting(/*whatever*/);
  pl.setValue(/*whatever*/);
}
p[i] = pl;

It's not that hard to figure out.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Because you are assigning "pl" to all the elements and your "FamousPainting" object is "f". What good does it do to have a FamousPainting object and then not use it? Instead of creating that at the beginning, create it at the same place as you are now creating your Painting objects. Just create one or the other, then set the value and assign it to the array, regardless of which it is.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Take a look at the methods in DefaultTableModel and use the getModel method of JTable.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Yeah write Class(es) that access the DB, then write Class(es) that display data in a Gui, then write Class(es) that act as listeners (and such) as a go between between the two and performs its actions in a separate thread.

This is called (and is only a simple explanation of) the MVC (data Model, View, Control) layered model. Google that.

This mixing of the DB and GUI code is only begging for problems with both the DB access and the gui.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Because setDataVector sets the data for the entire table.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Just use getDate.