masijade 1,351 Industrious Poster Team Colleague Featured Poster

When you execute a select query the first call to next() will "fetch" a specific number of records into a "cache" and then use that cache until the next next() call goes beyond it and fetches the next "set" of rows. The slower the network connection the more it behooves to increase this fetch size (depending on available memory). Default wise it is, for most DBs, 500, which should be enough, but you can play with it. See the API docs (for either ResultSet or Statement or maybe, even, Connection, I forget). Also, I would simply display a "wait" message while the initialisation occurs and then show the GUI after everything has been initialised. There is not much you can do about the network. If you feel you must use a "copy" I would suggest a MySQL DB on the local side as well and set it up as a replication DB.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

It probably didn't "seem" slow, it probably was slow. Properly handling DB connections and network traffic is a part of writing an application and simply circumventing those by building in a manual copy step to have the data local is a crutch and not a solution.

You should be opening the connection (or a pool of connections) on startup of the app and use it through out and there will be no problem (as long as you are using a decent fetch size).

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Even at the pseudocode level that's not going to work:
firstStep = console.nextLine(); eg "ooxxx"
secondStep = firstStep.replaceAll(o, x); "xxxxx"
thirdStep = thirdStep.replace(x, o); "ooooo"
System.out.println(thirdStep); "ooooo"

This needs an extra step:
replace all the o with some temp char
replace all the x with o
replace all the temp char with x

Too slow! ;-)

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Actually, that won't work, anyway. As if you replace all o with x then all x with o your string will consist of nothing but o

Step 1: get string
Step 2: replace x with z
Step 3: replace o with x
Step 4: replace z with o

Why do you feel the need to do it in one?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

I give up.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Where did you do that? If in .bash_profile, is .bash_profile even being used? Or is it using .bashrc?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

That line is creating the classpath variable. It doesn't matter if one already exists or not.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

You don't want to use CLASSPATH anyway. If you insist, however (and they always do), simply add that line directly to the .bash_profile (if that's even used otherwise .bashrc) environment file.

Edit: If, however, you insist (and they always do) on keeping it in a separate script, then you need to source that script from the proper environment file, not just execute it i.e.

. script.sh

not just

script.sh
masijade 1,351 Industrious Poster Team Colleague Featured Poster
masijade 1,351 Industrious Poster Team Colleague Featured Poster

Yep, you can't control that (AFAIK), unless IE has some option, but that's a Microsoft question. As I said, use HttpURLConnection and JFileChooser, Google for some tutorials.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Well, how are you "doing" the download?

I would assume you would use a HttpURLConnection and a JFileChooser, but it seems you are using Desktop.open(), no?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Uhm, three overloaded methods with <T extends ComputerPart>, <T extends Peripheral>, and <T extends Service>?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Dear All,
I have a java application which link to db on another computer on the local lan. The problem I have install jdk_1.6_21 without any problem. Then I have paste mysql-connector-java-5.1.14-bin.jar in /usr/java/jdk1.6.0_21/jre/lib/ext. When I compile my program has no problem when I try to run I get this error java.sql.SQLException: No driver found. I have been doing this method all this while it works suddenly this new machine have this problem. Any help please.My Os is centos 5.5.

Are you maybe ignoring the exception when you load the driver (or are you using the inherent "Service" capabilites as of Java 6/JDBC 4 (is the current version 4 or 5?))? Or have you mangled the connection url? As that error is not caused by a missing driver, but rather by the attempt to use a driver that has not been loaded (or a mangled connection url so that JDBC doesn't know what driver it should be using which amounts to the same thing).

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Yes. A good rule of thumb, I've found, is that public (and maybe protected) methods should use the interface (I.E. list) as parameter and return types. Whereas private (and maybe default) methods could easily use the implementation (I.E. ArrayList). This second part can make changes more widespread when a change is made, but it does not change the public interface and so those changes could still be made without affecting (theoretically) anybody else's code that may be using your API. Also, local variables should always use the implementation (if there is any chance you'll be using, or relying upon, functionality/behaviour that the implementation guaranties that the interface does not). They declare more functionalities than the Interface does, and there is no reason to restrict yourself in a local scope.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

By using a WindowListener, an ActionListener, and an ItemListener.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

The "connection object coming to it" is the one provided to it by whatever calls it. What calls it? Where did that get its connection? I assume you do know what your program does, right?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Then the first line is a blank line (or there are no lines, but then it would print null) and you are only reading one line. Also, if you can't work with the Sun tutorials no other's will help you either. The advice about closing the outer most reader/writer still stands.

Edit: Aack, you also need printStacktrace, not getStacktrace.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Close the bufferedwriter and not the file writer. By closing the filewriter you are probably preventing the bufferedwriter from flushing.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Because toString() is called using Objects declaration, in that case, and polymorphism causes Date's toString() method to be used.

You do know that imports have no effect on a compiled class, right? They are not even there anymore. They exist solely in the source files and solely for programmer "convenience", that they can type Date rather than having to type java.util.Date

masijade 1,351 Industrious Poster Team Colleague Featured Poster

No, that is not "putting it on the classpath". Do not put anything into the jre/jdk directories. If executing/compiling from the command line (without the -jar option) use the -cp option, if running from the command line with the -jar option, correctly configure the manifest file and place the jar in the proper place relative to the application jar, if using a web container/app server place the jar in the proper place (i.e. normally WEB-INF/lib for web containers but for drivers possibly a shared/lib somewhere in the server libs), and if using an IDE then add the jar as a library to the projects properties/preferences. See the tools documentation for the java/javac commands, the Manifest File tutorial, the web container/app server documentation, and the IDE documentation for more details on the chosen path.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Well, you want to actually set a value in index 24, right? So it is either <= 24 or < 25 (the same goes for the 49). You also want to set the value at that index so what is the length reference doing there? Also, the last half should be three times the index, right? Not the index Cubed (i.e. to the power of three), right?

Also, the array should consist of 50 elements, not 15 and you use square brackets [ ] not parens ( ) to declare an array length.

Also, you should be printing all 50 values, not just 10. But, you should be using print, not println (and don't forget to include some spacing between the numbers) and just use println at every 10th index (google java modulus).

You also need to declare a class to contain this main method, not just the method, and the main method has a specific signature (I'm sure you've been taught what that is) that you are not adhering to.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Okay, lets say your locks are numbered 1 - 5 (looking at your max min loop).

Now, lets say two threads are working, one doing a forward sort and one doing a backword sort. Now, lets say the one doing the forward sort gets a lock on say lock three, and the one doing the backward sort gets a lock on lock four. Now, each of these threads (due to your "stacking" or "embedding" of locks) wants to get the lock on the lock object that the other thread already holds. Boom, deadlock.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Well, if your starting it as an application (and not an applet or web service or etc) then yes (assuming the actual "m.End()" method creates and displays the GUI). If the JFrame is being created in the constructor (and "MyClass" extends JFrame) then you should change that. Make "MyClass" extend JPanel (or JComponent) and have the "End" method create and show the JFrame adding "this" to it.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

I'm so sorry, but can you please teach me how to do this?

Not until you at least try. We are not here to do your homework for you. You do not learn anything that way, and just makes the rest of the course that much harder (as you are probably already learning as all your other assignments have probably been done by others).

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Well, post that. You do realise that that "code" was not cut-n-paste, right? You have to modify to your code, but the syntax is the same.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

I already showed it to you.

component.setOpaque(true)
component.setBackground(someColor)

Give it a try.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Use setOpaque(true) and then setBackground(Color). Try it and post that if it "doesn't work".

masijade 1,351 Industrious Poster Team Colleague Featured Poster

See the API docs for (and/or search for a tutorial on) TimerTask and Timer.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

I'm trying to make it color red. I've been trying to change the color for 2 days

Where? Nothing in that code attempts to change the color of anything.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

If you mean no replicates through the life of the program, then follow the advice in the first reply here.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Use a while loop and continue pulling a random second name until it does not match the first?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

And your question? One note though, I would use "names.length" rather than "18" in your random number generation. I would also make "r" an instance variable rather than creating a new one with every call to "getPartner".

masijade 1,351 Industrious Poster Team Colleague Featured Poster

You know, I am not trying to hide things from or mislead you, you know. If you have to do exactly what that description says, then varargs is the only way. As already mentioned, using an array means the constructor takes one parameter, not two. Using overloaded constructors is not really feasible due to the description that more than two parameters must produce a "useful" error message, meaning you would have to create hundreds of the constructors to handle all possible invalid constructor calls (i.e. one with 3, one with four, one with five, etc and a constructor can have hundreds of parameters and you'd have to write a constructor for everyone. You could also write you own object for "passing" the parameters but everything said about the array applies to this, too.

So, as already said, the only "feasable" way to completely satisfy the description is varargs.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

The only way a method or costructor can take a "varying number of parameters" is through varargs. The only other thing is to simply use an array (as the parameter) and check its length. But then, the constructor is still taking just one parameter (not two as stated in the description) its just an array that its receiving, but that doesn't jive with the description either. The only thing that matches the description, as written, is varargs, so, take your choice, use an array (and one parameter), or mulitple overloaded constructors, or do it right and use varargs.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Who says (its called initiative)? Did you ask?

In any case, he is probably hinting at method overloading in that case

public void doit(int argOne) {
    doit(argOne, argOne);
}
public void doit(int argOne, int argTwo) {
    // do whatever
}
masijade 1,351 Industrious Poster Team Colleague Featured Poster
masijade 1,351 Industrious Poster Team Colleague Featured Poster

because calendar.getTime() retreives a Date object equivalent to the the last date and time set in that Calendar object (which is, seemingly, the current time at the time you created it). Simply use new Date() where you are currently using that, or, if you insist on using the calendar (maybe because of timezone settings, or whatever) then call setTime first.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Okay? For the first one a simple substr in a loop. In the second one a simple substr in a loop combined with charAt to determine the index.

Using those hints, give it a try and then post your code with a specific question.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Okay, readLine is BufferedReader. In any case, those things I mentioned are using InputStream, BufferedInputStream handles those things for you.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Whether you want to do the work yourself, or you want to control the read size of the buffer, or you don't want line endings getting hacked off (if using readLine), etc, etc.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Remove the JTable and the JLabel, then remove the JLabel and add the JTable.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Do not use == ( if(answer==Answercheck.correct) ) to compare Strings use the equals method

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Well, that's not what you said

so when i run the progg...no ques is displayed..only after i click on b1, is the first question displayed.....

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Well then, display one (or fire an event programettically. Really, the "initial" display never comes as the result of an action event, so, if you want a question displayed right away, than you need to display one, and not only display them in the Action Listener (which won't, obviously, be accessed until an Action Event is fired).

masijade 1,351 Industrious Poster Team Colleague Featured Poster

And I suppose you respect all of those that wish to steal your work?

In any case, it is clearly spelled out in the policies here that we do not simply give out code so this type of question should never come, so, I feel no need to "be respectful". However, I would like to know what you found "disrepectful" there? I asked him what is problem was, what he had already tried to do about it, and informed him that he wasn't going to get a handout (whether he was looking for one or not). Reading either respect or disrespect into that is point of personal subjectivity, IMHO.

So, another question to ask now is, why did you come looking at this question in the first place? Did you have the same question with the same expectations? Were you dissappointed?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Have you, as yet, done what the second line of that Note says? BTW, you did notice that is a Note and not an error, right?

minimi commented: Thank you! +0
masijade 1,351 Industrious Poster Team Colleague Featured Poster

Then this is a JavaScript question. A function and a Div, not hard.

Moving to JavaScript forum.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Gootle HTML refresh

masijade 1,351 Industrious Poster Team Colleague Featured Poster

It's not an "apache setting". It is a "Web Container"/"Application Server" configuration. I.E. Tomcat, Glassfish, Sun Application Server, WebSphere, WebLogic, JBoss, Jetty, etc. Find out which one you are going to use and read its documentation.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Simply call the add method, then validate and/or repaint.