• 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

DB connection from swings

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I create a swings webapplication.

I already know about swings to servlet communication reagarding database connection through streams,

But i want to know about jsp to swings comminication regarding db connection (or)

Any thing u suggest

Help me,

Thanks in advance.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm confused (and I suspect you are too ). Swing apps and web apps are completely separate things; they don't mix in one (unless a Swing app accesses a web app, but then you have two applications). From your description I can't make out which part accesses which other part, and where exactly the problem is - please provide a more detailed description of what you're trying to do.
 
kalyan chowdary
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Sorry i didn't give query properly,

I create webapplication, in that i calling applet from jsp using jsp:plugin.

Then i want to connect oracle from this applet.

I know about connect through servlet.

But this is old technology,

Please prefer any new technology to connect DB.

Bye,
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just because it's old technology doesn't mean it's obsolete. To the contrary, age may be a sign of maturity.

You can of course connect directly from the applet if it is signed, but I'm sure you know that (and since the username/password as well as the actual queries would be part of the applet, this has some unfortunate security implications). Using JDBC directly from applets also opens up a few problems in the area of transactionality and connection handling; it's better to avoid that.

Applet signing is discussed on this FAQ page.
[ June 30, 2006: Message edited by: Ulf Dittmer ]
 
kalyan chowdary
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI,

Thanks for reply,

please send sample code how to signing the applet.
 
kalyan chowdary
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
u already send signing applet link

its ok
 
kalyan chowdary
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI,

I studied about signed applet,

Its ok,

I wrote a swing program like this, It is singed

import javax.swing.*;
import java.awt.*;
import java.sql.*;
import java.awt.event.*;
//import javax.swing.event.*;

public class DBSwing extends JApplet implements ActionListener
{
JTextField jtf;
public void init()
{
Container contentPane=getContentPane();
contentPane.setLayout(new FlowLayout());
jtf=new JTextField(5);
JButton b=new JButton("Button");
b.addActionListener(this);
contentPane.add(jtf);
contentPane.add(b);

}
public void actionPerformed(ActionEvent ae)
{
try{
Class.forName("oracle.jdbc.driver.DriverManger");
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@192.168.0.230:1521:sevenora","scott","tiger");
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery("select *from kalyan");
while(rs.next())
{
jtf.setText(rs.getString(1));
}
}
catch(Exception e)
{e.printStackTrace();}

}
}


my html is



<APPLET CODE="DBSwing.class" WIDTH=600 HEIGHT=400 ARCHIVE="DBSwing.jar,classes111.jar" >
</APPLET>

I got an exception like this




<APPLET CODE="DBSwing.class" WIDTH=600 HEIGHT=400 ARCHIVE="DBSwing.jar,classes111.jar" >
<PARAM NAME="ARCHIVE" VALUE="DBSwing.jar">
<PARAM NAME="CODE" VALUE="DBSwing.class">
</APPLET>


<APPLET CODE="DBSwing.class" WIDTH=600 HEIGHT=400 ARCHIVE="DBSwing.jar,classes111.jar" >
<PARAM NAME="ARCHIVE" VALUE="DBSwing.jar">
<PARAM NAME="CODE" VALUE="DBSwing.class">
</APPLET>

I got an exception like this

java.lang.ClassNotFoundException: oracle.jdbc.driver.DriverManger
at sun.applet.AppletClassLoader.findClass(AppletClassLoader.java:167)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.applet.AppletClassLoader.loadClass(AppletClassLoader.java:118)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:164)
at DBSwing.actionPerformed(DBSwing.java:24)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:18
49)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.jav
a:2169)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel
.java:420)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258
)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonL
istener.java:234)
at java.awt.Component.processMouseEvent(Component.java:5488)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3093)
at java.awt.Component.processEvent(Component.java:5253)
at java.awt.Container.processEvent(Container.java:1966)
at java.awt.Component.dispatchEventImpl(Component.java:3955)
at java.awt.Container.dispatchEventImpl(Container.java:2024)
at java.awt.Component.dispatchEvent(Component.java:3803)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212
)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3892)

at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822)
at java.awt.Container.dispatchEventImpl(Container.java:2010)
at java.awt.Component.dispatchEvent(Component.java:3803)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchTh
read.java:234)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
ad.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)
Caused by: java.io.FileNotFoundException: F:\sign\oracle\jdbc\driver\DriverMange
r.class (The system cannot find the file specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:106)
at java.io.FileInputStream.<init>(FileInputStream.java:66)
at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection
.java:70)
at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLCon
nection.java:161)
at sun.applet.AppletClassLoader.getBytes(AppletClassLoader.java:279)
at sun.applet.AppletClassLoader.access$100(AppletClassLoader.java:43)
at sun.applet.AppletClassLoader$1.run(AppletClassLoader.java:157)
at java.security.AccessController.doPrivileged(Native Method)
at sun.applet.AppletClassLoader.findClass(AppletClassLoader.java:154)
... 30 more


Help me,

Thans in advance
 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Looks like a typo
java.lang.ClassNotFoundException: oracle.jdbc.driver.DriverManger

Fix the line:

and make sure you have the JDBC driver jar in classpath.
 
kalyan chowdary
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Class.forName("oracle.jdbc.driver.DriverManger");

Where i get this class

I have classes111.jar and classes12.jar,

But unable to find this class.
reply
    Bookmark Topic Watch Topic
  • New Topic