> try {
> Class.forName(JDBC_DRIVER);
[quoted text clipped - 11 lines]
>
> catch (ClassNotFoundException classNotFound)
You appear to be catching a ClassNotFoundException here, but not an
SQLException, which -- as Alex Molochniko has already pointed out -- is
what the compiler error is telling you:
> Unhandled exception type SQLException
You need to add another catch block, something like
catch (SQLException sqle) {
sqle.printStackTrace();
System.exit(1);
}
before your finally block.
Oh, and another word of advice. In your first post, you said:
> if i create a new server in mysql control center i can connect with
> super user privlileges with root and no password.
You really *don't* want to have a root user without a password. This is
very poor security. Anyone with access to your MySQL server can come
along and take it over. There are *bad* people on the Internet who will
sniff out your insecure MySQL server and make your life miserable.
Please, give your root user a secure password and don't create any MySQL
users without passwords.
David Harper
Cambridge, England
dodo1548 - 05 Mar 2005 21:12 GMT
thanks david and alex.
i made the change and added the catch block you suggested.
i got some descriptive error messages this time.
i will try and google late tonight when i get home and see what advice was
offered
when someone else came across one of those error messages.
i will change fix the root password tonight as well.
i will keep my computer off line until i fix it.
i have to head to work now though.
later,
jim
The other poster already responded to you. You are missing the catch clause
for SQLException. The compiler spelled it out for you. You could get away
with one "catch-all" generic Exception clause, like this:
catch (Exception e)
{
}
if you did not care to handle different error situations individually.
AM
> hi-
>
[quoted text clipped - 63 lines]
>
> }
dodo1548 - 06 Mar 2005 05:41 GMT
> The other poster already responded to you. You are missing the catch
> clause
[quoted text clipped - 8 lines]
>
> AM
Alex & David-
thanks again. the catch clause really made a difference. it helps so much
when i am trying to
diagnose the problem to have a hint as to what is going on.
my problem was basically that i needed to point to the .jar file for the
jdbc driver in the eclipse
build path.
that was my first test of any java program code except playing around with
the eclipse environment
while reading about it.
when i took some basic C++ classes the compiler always gave a decent
description if a line of code had a problem.
i never went far enough in C++ to get into exception handling. i can see
where it will be really important in
java.
i am looking forward to having lots of fun with java.
have a great weekend,
jim
Alex Molochnikov - 06 Mar 2005 07:15 GMT
> Alex & David-
> thanks again. the catch clause really made a difference. it helps so much
[quoted text clipped - 4 lines]
> jdbc driver in the eclipse
> build path.
Glad we could help. However, normally your build path in Eclipse does not
need to have the JDBC driver classes. They are only needed at runtime, in
the program classpath.
> when i took some basic C++ classes the compiler always gave a decent
> description if a line of code had a problem.
So does the Java compiler. In your case, you just did not realize that the
error message from the compiler had to be taken literally.
> i never went far enough in C++ to get into exception handling. i can see
> where it will be really important in
> java.
There is hardly a unit of code in Java that works without handling one
exception or another. You will find it out very quickly.
Anyway, good luck to you.
AM
dodo1548 - 06 Mar 2005 05:41 GMT
> The other poster already responded to you. You are missing the catch
> clause
[quoted text clipped - 8 lines]
>
> AM
hi david and alex-
thanks for all the help.
i needed to add the .jar file to the buildpath in eclipse. the catch clause
really helped.
have a great weekend,
jim