Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

A question about applet and jdbc

 
Peng Fan
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,everyone! this is my first time attempting to combine an applet with a jdbc(connector/j),here is my code:
there is no warning message or runtime exception thrown, but what drive me crazy is when i run this applet from my Internet Explorer 6, it just cannot modify the data in my MySql database. so please help me getting out of such situation.thx!
 
Joe Ess
Bartender
Posts: 9339
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
there is no warning message or runtime exception thrown


Probably because you are throwing the exception away:
 
Peng Fan
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
could you give me a example of an applet that access a mysql database with connector/j jdbc driver.
 
Joe Ess
Bartender
Posts: 9339
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Java Tutorial JDBC Chapter has plenty of examples. All that should change is the connection URL and the driver class.
 
Peng Fan
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could you please tell me the reason, when i run the same code as a standalone gui program,every thing is ok, but when i run the code as an applet, java console told me that a ClassNotFoundException was thrown,why? thank you!
 
Joe Ess
Bartender
Posts: 9339
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because applets load their classes from a web server and applications load their classes from the local file system. You have not made the database driver classes available on the web server. This is covered in the Java Tutorial chapter on Writing Applets. You should read it and pay close attention to the Practical Considerations when Writing Applets section. There are a number of differences between applications and applets which are covered in this section.
 
Peng Fan
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Joe Ess,thank you so much!I had solved the problem by copy the connector/j jar file to my jre/lib/ext subdirectory(only the jre but not my sdk) from my java sdk/jre/lib/ext subdirectory, i know, just as you had said, with such approach, only myself could get the applet run without any problem, how can i make others smoothly run my applet from their web browser without get a copy of connector/j into their jre subdirectory?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic