Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Using JDBC with an applet

 
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,

I am trying to access an MS Access Database using a Java applet. For the connection url I use:
url = "jdbc:odbc:Test_db"
This works great on my computer, but it appears to be using my computer version of Test_db, and not the server's version! Then when I run the applet on another computer it tries to use that computer version (oops, it doesn't have one, so I get an exception!). What can I do?
 
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you need to setup a DataSourceName within ODBC that
points to you network database. That should solve your ODBC issue.
Hope this helps...
------------------
We learn more from our mistake's than from our success's.
a.k.a. monty6
 
Paul Bailey
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Monty,
Thanks for the tip. I checked the servers ODBC and the database is there and everything is set up correctly. On top of that, I have a .cfm page that uses the same database, and everything works out just fine for that page.
Hmmm...
 
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The DSN must exist on the computer the applet is run on. If the DSN points to a remote computer, the database can be there (but may have to be on the same IP address as the webserver where the applet originated).
 
Paul Bailey
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeroen,
That makes sense. Now, how do I point to the webserver?
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found an example that does this. It's in chapter 11 of the wrox press book Java Server Programming. Basically, you need to create a servlet that runs on the server that contains the database. The applet can connect to the servlet. The book example shows this. Download the book examples from www.wrox.com. The book is not necessary in this case.
 
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic