• 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
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Applet doesn't establish JDBC connection

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to set up an applet with JDBC functionality and can't get the thing to work. I've written the GUI so it can be loaded either as a JFrame or as a JApplet. As a JFrame application it works fine, establishing the JDBC connections and firing the appropriate Oracle queries. As an applet, it comes up fine on the screen, but does not connect to the database. All the files (the applet, a "DbLayer" class, and an inner event-handling class) are stored in a Resin web server on my machine. I've put all the applet files into a common jar file, and have put the path for this .jar file into my windows NT CLASSPATH.
What should I do to enable the connection between the applet
and our local database?
Many thanks in advance!
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi ben,
if u need an applet to connect to a local database,there is one
mechanism for u.In ur applet u creat a clientsocket and thru I/O
streams u send the applet content to a middle application where
u will create a server socket and get the applet content thru
Object input stream or any other input stream and there itself
u establish the jdbc connection and connect to the database.
u can send ur data to database as well as u can retrieve the
data from database into the middleapplication and from there
thru streams u can send to the applet.
If u are not comfortable with socket programming u can use
middle application as servlet which requires java webserver.
if use servlet as middle application u need not create the sockets.directly u can retrieve the data from database into the
servlet and send that info to the applet thru outputstreams.
if u are not clear let me know it
thanks and regards
Anand
 
Ben Weaver
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks very much, Anand. I'll try what you recommended.
 
Ben Weaver
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Got to thinking about this problem, Anand (and whoever else is interested!), and had two questions. One, if I used a servlet that would accept several String parameters from the applet in order to run the JDBC connection and queries, which MIME type would I choose as a parameter for resp.SetContentType()? I'm new to servlets, and I've seen only the usual 'text/html' as the parameter. Is there a 'text/String' or 'text/ascii' type?
Two, might I circumvent the IO problems entirely by linking the servlet and the applet with RMI? Couldn't I then pass the strings from applet to servlet as Strings without regard for http protocols?
 
Ben Weaver
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Correction: my proposed RMI connection would link the applet not to a servlet, but to a DatabaseLayer object implementing a Remote interface.
All the same, I am interested as much in the servlet as I am in the possible RMI solution, so any wisdom about the servlet resp.setContentType() parameter would be much appreciated.
reply
    Bookmark Topic Watch Topic
  • New Topic