2

I'm trying to write a simple Applet which must get text data from database.

I have some problems:

  • I have remote mysql db or i can create a local db, what would be the most correct?
  • I have downloaded mysql-connector-java-5.1.22-bin.jar and put it to my applet source directory

    yakoot@yakoot-home:~/java$ echo $CLASSPATH /home/yakoot/java/mysql-connector-java-5.1.22-bin.jar

but when I try,

Class.forName("com.mysql.jdbc.Driver");

I see

error: unreported exception ClassNotFoundException; must be caught or declared to be thrown

Class.forName("com.mysql.jdbc.Driver");

I tried some different locations for mysql-connector-java-5.1.22-bin.jar, but it did not help

6
  • 1
    It's a compile-time error. It says, you must enclose that statement within a try...catch block and catch/handle the ClassNotFoundException in case it's thrown. Commented Nov 10, 2012 at 18:13
  • a local or remote db thats upto your requirement bro. Commented Nov 10, 2012 at 18:15
  • i know it, but if i enclose this within a try-catch i see no errors and it's not working Commented Nov 10, 2012 at 20:21
  • I do this not for me.. Will the connection to the database work correctly on another machine without any additional actions? Commented Nov 10, 2012 at 22:21
  • i'm done this applet, synchronize my project folder via ubuntuone with my work machine, but when i'm trying to run applet at work it can it can not load com.mysql.jdbc.Driver.. connection in services tab work finely, CLASS_PATH = path to driver from services connection properties.. whats wrong? Commented Nov 12, 2012 at 6:12

2 Answers 2

2

Put your MySQL JAR File in Class Folder Instead. i.e. if you are using netbeans you need to choose include library/JAR Folder. then browse mysql-connector-java-5.1.22-bin.jar file. Then rebuild the source and run again.

Sign up to request clarification or add additional context in comments.

1 Comment

Hmm.. I dont use netbeans or other ide.. but i'll try tomorrow, thanx
1

You can have local or remote db as your requirement is.

Second you need to enclose Class.forName("com.mysql.jdbc.Driver"); in a try catch block.

try
{
Class.forName("com.mysql.jdbc.Driver");
}
catch(ClassNotFoundException e)
{
   e.printStackTrace();
}

4 Comments

@AndrewThompson thanks sir, actually I have been using my phone to reply lately and this "auto capitalization" :-D , but yea i should have taken care. Thank you for helping me improve it
@AndrewThompson haha..:-D , thank you sir , and yea thats surely a better implementation. Thank you. :-)
Cool. That's some noise deleted and (wipes hands together in finality) ..my work here is done. :)
@AndrewThompson hahah..cool.. We have like crashed together on quite some posts, i have seen your responses. RESPECT you as a co member. :-) (y)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.