All Examples  This Package

Class examples.jdbc.mssqlserver4.SocketApplet

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Container
                   |
                   +----java.awt.Panel
                           |
                           +----java.applet.Applet
                                   |
                                   +----examples.jdbc.mssqlserver4.SocketApplet

public class SocketApplet
extends Applet
This simple example applet opens a socket on a given host and port number. It is a useful first test for your database connectivity environment.

This example could fail if there is a firewall between your browser and the given host. If this is the case, look for a proxy server to help you get to the host.

There may also be a problem with the browser's security manager. Normal policy for a security manager is to let your applet only connect to the host from which it loaded. Make sure your applet is loaded from a web server on the same machine that hosts your database. You can also relax security restrictions in certain browsers, such as HotJava.

What should I do if this test fails?

If this test fails, try to telnet directly to the database server. From the command line type:

 telnet hostname port 

If you cannot telnet there's a chance that your database is not there or there's a firewall between you and your database. If telnet succeeds then you're probably having a problem with the Java security manager.

To set up this example:

  1. Set up your development shell as described in Package examples.jdbc.mssqlserver4.

  2. In the SocketApplet.java file, change the database URL, login, and password connection parameters to correspond to your Microsoft SQL Server configuration. If you need more help, check the section on connecting to a database in the Developers Guide, Using WebLogic jDriver for Microsoft SQL Server. Note that the "host" String used in the example should only include the host name. Do not prepend a database name.

  3. Compile this example by executing the following command in your development shell:

    $ javac -d c:/weblogic/mssqlserver4/classes SocketApplet.java

  4. Run this example by executing the following command in your development shell:

    $ appletviewer SocketApplet.html


Constructor Index

 o SocketApplet()

Method Index

 o init()
 o paint(Graphics)

Constructors

 o SocketApplet
 public SocketApplet()

Methods

 o init
 public void init()
Overrides:
init in class Applet
 o paint
 public void paint(Graphics graphics)
Overrides:
paint in class Container

All Examples  This Package