This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
hi all can anyone provide me some simple Applet code for querying the oracle database. please do specify classes to be included in the classspath in case of applets. i have already connected my application with oracle database but i m unable to connect my applet with the database. i will be greatly thankful to you.
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35241
7
posted
0
Welcome to JavaRanch.
The code for connecting from an applet is the same as for an application. An important difference is that applets can only connect to the host where they were served from (i.e., the web server). If the DB is running on that machine, all works fine; if it isn't, no connection is possible. Which of these is the case in your situation?
The two principal ways around this are to sign the applet, or to alter the local security policy; both are described here. [ April 28, 2007: Message edited by: Ulf Dittmer ]
thanks for replying. but i m still in doubt. is it mandatory to sign an applet? i m running my applet on my pc and oracle database is already installed there.
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35241
7
posted
0
Well, you said you were having problems, although you didn't say what kind of problems, or whether there were any exceptions. The most common source of problems with applets connecting to databases is cured by signing the applet. If you told us the specifics of your problem, maybe we could advise more specifically.
mintu kumar
Greenhorn
Joined: Apr 28, 2007
Posts: 10
posted
0
here i m running the following code . it executes the following query "Select * from emp"; the number in the text area decides the column number to be displayed.
Exception in thread "AWT-EventQueue-1" java.lang.NoClassDefFoundError: oracle/jdbc/OracleDriver at project.paint(project.java:23) at java.awt.Container.update(Container.java:1730) at sun.awt.RepaintArea.updateComponent(RepaintArea.java:239) at sun.awt.RepaintArea.paint(RepaintArea.java:216) at sun.awt.windows.WComponentPeer.handleEvent(WComponentPeer.java:254) at java.awt.Component.dispatchEventImpl(Component.java:4031) at java.awt.Container.dispatchEventImpl(Container.java:2024) at java.awt.Component.dispatchEvent(Component.java:3803) at java.awt.EventQueue.dispatchEvent(EventQueue.java:463) at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:234) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149) at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
this error comes when i run every jdbc applet. can you suggest any solution.
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35241
7
posted
0
Do you know what a "NoClassDefFoundError" is? Where is the JDBC driver (i.e., the jar file) located? The applet tag you quote doesn't include an "archive" tag, so this is most likely a classpath isue, which is trivial to correct.
mintu kumar
Greenhorn
Joined: Apr 28, 2007
Posts: 10
posted
0
sir , i have included the drivers in the classpath. but i m still getting the the same error. i have put archive.jar there, which contains ojdbc14.jar, ojdbc14_g.jar, classss111.jar etc. thanks for giving so much attention to my problem. can you please try to run this program.
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35241
7
posted
0
i have included the drivers in the classpath.
Applets do not use the classpath, so this won't help.
i have put archive.jar there, which contains ojdbc14.jar, ojdbc14_g.jar, classss111.jar etc.
Jar files within jar files won't work for accessing class files by the JVM. A jar file must contain class files directly.
Also note that the applet tag does not contain an "archive" attribute, which is used to tell the JVM which jar files contain classes used by the applet. It is described here.
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.