• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

A question about applet and jdbc

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Evildoers! Eat my justice! And this tiny ad's justice too!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic