This week's book giveaway is in the Java in General forum.
We're giving away four copies of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 and have ishori Sharan & Adam L Davis on-line!
See this thread for details.
Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!

Narendira Sarma

Greenhorn
+ Follow
since Nov 14, 2008
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Narendira Sarma

A google search on "h2 database date format" presented this link. Data Types in H2

The documentation there clearly says the format for Date type is "yyyy-MM-dd" and for Timestamp it is "yyyy-MM-dd hh:mm:ss[.nnnnnnnnn]".

I guess its not a bug but normal behavior.
12 years ago
I guess there is a KeyListener for the whole app. Pressing an alphabet key anywhere in the window is registered.
12 years ago
I tried playing with IE 8 and Google Chrome...

Works fine for me.
12 years ago
Your package declaration in Test01LayoutManager should be like

12 years ago
Did your code compile?
I am having problems compiling the code. It says "Type MapTest doesn't take parameters"!.

Anyway, I guess, to test the override of toString method, you have to call the toString() method actually.
12 years ago

Campbell Ritchie wrote:
If however you write "B = new Cat();" it means create a new Cat object (maybe black cat called Tibbles at memory location 2345bcde) and use that instead of "B"



That made me understand. Thanks Ritchie.
12 years ago
To execute a JAR from command line you have to use

java -jar <JarName>.jar

Since you use Netbeans, your JAR will have Main-Class property set in the Manifest file. And the libraries (if you use any) would have also been set in the Manifest file. You don't have to use -cp option.
12 years ago

sahar sa wrote:
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
com.mysql.jdbc.Driver



Your stacktrace clearly suggests that the mysql-jbdc-connector jar is not in the classpath.
There can be many possible errors in the posted code.

1) mysql-jdbc-connector jar not present in classpath.

2)
doesn't have a space between *price* and *from*, where your query will fail...

and so on...

Please post the error you get.
Use printStackTrace() method to print stack trace of exceptions. It will help you locate the exact problem.

Peter Granstrom wrote:
Hi i liked your answer,
but i think in the if() i would try to decide if boolean to true or false before
because then you dont have to make changes afterwards and can decide
before if its right or wrong and probably get a better structure in your code



Hi Peter,

I couldn't understand what you were trying to say. I am a rookie programmer myself. That being said, I showed him how "I" would have handled the situation.

But I am eager to learn. Could you please tell me more clearly?

Thanks
-Naren
12 years ago
Sorry. I am not good with Swing. Someone else can help you.
12 years ago
Deepak,

No one is going to be so urgent to answer your question in the same way you are. Because its your problem.

Removing a "?" is very simple with using String.replace() function. But that is not going to help you, as more and more question marks can appear anywhere in the lines you read from the file.

Try to analyze your file. If Java (or IDE) is displaying a ? then it clearly suggests that the character is not supported on the used encoding. Try to print "byte by byte" and see if the byte relating to "?" is out of range off the printable characters.

Check if your IDE (if you are using some IDE) is capable of showing those characters.

I am just giving you suggestions from what you have presented.

These might help you.
12 years ago
I am assuming your actionPerformed() method is in the same class as the calling method.

Please have a global variable at class level (i am calling it tries) and initialize it to 1

in your if(!found) block increment it. tries++;

and your

will look like this



The logic is you will increment tries count every time username and password are not valid.

And while checking for username and password, you will also check for number of tries.

Hope its clear! All the best
12 years ago
I am assuming your actionPerformed() method is overridden method and is called on a button click event. Right?

Can you point us out at how the control comes into the actionPerformed() method? I mean, when is the actionPerformed() method is called?
12 years ago
You must have a global variable (or a variable outside the method) and increment it each time you go into the if(!found) block.

So while checking for username and password, you have check for the count variable also.

like



to go upto number 3, you cant have a boolean to do that. You need to use int to do that.
12 years ago