Win a copy of Spring in Action (5th edition) this week in the Spring forum!

Nicola Garofalo

Ranch Hand
+ Follow
since Apr 10, 2010
Italy
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
10
Received in last 30 days
0
Total given
9
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Nicola Garofalo

I've just seen another mistake

you write



Remember that you should catch an exception in a way like:



5 years ago
current e scanner are duplicate variables.

is not


Remove this first issues and go on.
5 years ago

i have put SQL Driver.tar in classpath.



What is the exact name of the driver you put in your classpath?
Let me know if it works.

Anyway that's mysql tutorial link on connecting to mySql using DriverManager

http://dev.mysql.com/doc/refman/5.6/en/connector-j-usagenotes-connect-drivermanager.html
the problem should be here

jdbc:mysql://localhost:3306/

let's say you created a schema named mydb, the connection string must be

jdbc:mysql://localhost:3306/mydb
Probably you can't, within the same Statement, execute select queries and batch updates.
6 years ago


you are welcome
6 years ago
Line 23 was a while and now it's an if. Put the while back

6 years ago
Could you please post the code as it is now?
6 years ago
No, you won't

Did you make all the changes i told you ?
6 years ago
You did not make all the changes i asked you to make.

1) Remove from line 14 to line 16
2) In line 18 you must read the String returned by method KbdInput.readString()



3) Remove line 19, or you will miss some tokens
6 years ago
Last thing.

Remove lines



in your main method of class Grades, because method readString() does it too, and you would end up to read two lines
6 years ago
KbdInput.readInt() method could lead you to a runtime exception
It reads a line and it assumes this line will be an integer.

You could delete it and remove all the instructions



A nice method in KbdInput is readString() that returns a String that you can tokenize

Assuming that a user will enter values 60 70 40 30 -99 (but you should check user input token by token)

method readString() will return the String "60 70 40 30 -99"

You can tokenize that String with StringTokenizer



int variable input could become, for example



the inner loop



it's useless and you should remove it.

Start to make this changes and see what's happening
6 years ago
First of all.
We should know what KbdInput class does, in particular one of its methods, readInt().
it does not return an int as expected but an empty String

Second:

You create a StringTokenizer of the String taken as input, i.e. String line

But you don't go through its tokens!!!
So the loop


will probably never end

Can you post KbdInput.readInt() method?
6 years ago