DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Applets

Hybrid View

  1. #1
    Josh Guest


    Dear Forum:

    Can connections to a database be made through an applet. If so does anyone
    have a sample of this. Thanks in advance


  2. #2
    Björn Guest

    Re: Applets

    "Josh" <jbrandt@arastone.com> wrote:
    >Dear Forum:
    >Can connections to a database be made through an applet. If so does anyone
    >have a sample of this. Thanks in advance

    Sure, but I don´t have any code to provide to you. But you can always import
    the jdbc-driver specific classes to your Applet-code and connect to the database
    through it. Applet security prevents your applet from connecting to another
    host, than the one that provided the applet. You could of course make alterations
    to your browsers security/authentication, or make a Remote Method Invocation
    to another host, but the standard way is applet-host.

    java.sql.Connection conn = DriverManager.getConnection("jdbc://"+host+"/"+db,
    userName, passWord);
    java.sql.PreparedStatement ps = conn.prepareStatement("SELECT custname, address
    FROM customers WHERE custid = ? ");
    ps.setInt(1, 45); // sets the value of custid
    java.sql.ResultSet rs = ps.executeQuery();
    if (rs.next()) {
    System.out.println("Customer name: " + rs.getString(1));
    System.out.println("Address: " + rs.getString(2));

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.