Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

createstatement: applet does not use jdbc 2 or above, same code is ok in application

Posted on 2001-06-27
6
Medium Priority
?
243 Views
Last Modified: 2013-11-23
I am using createstatement and the absolute method in an applet to load a picture from a SQL 7 database, using JDataconnect 2.0 as driver.

While the code works fine in an application, in the applet it produces java.sql.resultset ... method absolute not found  (same with createstatement)

I run the applet locally against Personal Web Server, with http etc... The database dataserver reports a database connection. No problem there.

I have tried everything under the sun with the archive clause in the html code, jars in the web root dir, locating which jars are actually consulted when compiling.

To no avail. I can only make it work using jdbc 1.2 methods.

So ... help !

Thanks

frank@space95.sc
0
Comment
Question by:frankjava
6 Comments
 
LVL 1

Expert Comment

by:viswa081400
ID: 6233389
Can you add some piece of code and error info??
0
 

Author Comment

by:frankjava
ID: 6235927
The error produced is 'nosuchmethoderror: java.sql.resultset ... method
absolute not found ' , i.e. when I move the mouse over the applet in IE5

In Netscape it says 'ERROR, CAN'T START APPLET'



The code: (it says DOES NOT WORK next to the createstatement and absolute that cause the applet not to work)



/*
<p><applet codebase="." code="PhotoUpl" align="baseline" width="711"
height="474" archive="jdbc-3_0-pfd2-classes.zip"></applet></p>
*/

import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import borland.jbcl.layout.*;
import borland.jbcl.control.*;
import java.sql.*;
//import javax.sql.*;
import java.io.*;
import java.util.*;
//import com.sun.java.swing.UIManager;
import borland.jbcl.util.*;
import com.sun.java.swing.*;

public class PhotoUpl extends Applet {
  XYLayout xYLayout1 = new XYLayout();
  boolean isStandalone = false;
  TextControl textControl1 = new TextControl();
  TextControl textControl2 = new TextControl();
///  ImageControl imageControl1 = new ImageControl();

//  ImageLoader ImageLoader1;
  TextControl textControl3 = new TextControl();
  ResultSet rs = null;
  ResultSetMetaData rsMetaData;
  Connection c;
//  Statement s;
  StringBuffer SQLstat = new StringBuffer("");
  StringBuffer mMessage = new StringBuffer("");

  Image Image1;
  Graphics gIm;
  Dimension dimIm;

  public void init() {
    try {
    jbInit();
    }
    catch (Exception e) {
    e.printStackTrace();
    }
  }

  private void jbInit() throws Exception {
    xYLayout1.setWidth(519);
    xYLayout1.setHeight(370);
    textControl1.setFont(new Font("Dialog", 1, 14));
    textControl1.setText("Establishment:");
    textControl2.setFont(new Font("Dialog", 0, 30));
    textControl2.setText("Picture Uploading to Database");
    textControl3.setEdgeColor(new Color(0, 0, 218));
    textControl3.setForeground(new Color(0, 0, 168));
    textControl3.setFont(new Font("Helvetica", 1, 13));
    textControl3.setText("Some establishment");
    this.setLayout(xYLayout1);
    this.add(textControl1, new XYConstraints(16, 75, 112, -1));
    this.add(textControl2, new XYConstraints(14, 13, -1, -1));
///    this.add(imageControl1, new XYConstraints(17, 139, 282, 178));
    this.add(textControl3, new XYConstraints(17, 104, 454, -1));

    Driver drv = null;
    try  {
      drv = (Driver) Class.forName("JData2_0.sql.$Driver").newInstance();
//      drv = (Driver) Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
    }
    catch (Exception e) {
        System.out.println("Cannot load the driver, reason:"+e.toString());
        System.out.println("Most likely the Java class path is incorrect.");
        mMessage.append("Test 1 !!!!!!!!!!!!!!! ");
    }



    try {
      c =java.sql.DriverManager.getConnection(       // best one
        "jdbc:JDataConnect://192.168.10.152/BOE1:frank10:frank11");
//      String url = "jdbc:odbc:BOE1";
//      c = java.sql.DriverManager.getConnection(url, "frank10", "frank11");

      if (c == null) {
//        mMessage.setLength(0);
        mMessage.append(" connection is null ! ");
        repaint();
      } else {
        mMessage.append(" connection is not null ! ");
        repaint();
///        return;
      }

      mMessage.append("Statement about to be prepared");
      repaint();
      mMessage.append("Statement prepared");
      repaint();


/////////// the createstatement below is jdbc 2, see the parameters
/////////// I seem to have access to the 1.2 only ???? See also absolute method !
// most likely correct; the overloaded createstatement with parameters does not work
// but the old one of jdbc 1.2 without parameters does work

//      Statement s = c.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
//                             ResultSet.CONCUR_UPDATABLE);    DOES NOT WORK !!!!!!!!!
      Statement s = c.createStatement();
      rs = s.executeQuery("SELECT * FROM HSCODE where no like '%0101%' order by no");

      if (rs == null) {
        mMessage.append(" resultset not available ! ");
        repaint();
      } else {
        mMessage.append(" rs ok ! ");
        repaint();
///        return;
      }

    }
    catch (Exception e) {
//      System.out.println("Error connecting or reading table:"+e.getMessage());
      mMessage.setLength(0);
      if (c == null) {
//        mMessage.setLength(0);
        mMessage.append(" The connection is null ! ");
      } else {
        mMessage.append(" The connection is not null ! ");
      }
      mMessage.append("test 6");
  //    repaint();
    }

//    mMessage.setLength(0);
    mMessage.append(""test);
    try {

//      rs.next();

      rs.absolute(1);             //    DOES NOT WORK !!!!!!!!!
      InputStream Is1 = rs.getBinaryStream(7);
      if (Is1 == null) {
        mMessage.append("getBinaryStream problem");
        repaint();
//        return;
      }
////      InputStream Is1 = getClass().getResourceAsStream("Image034.jpg");

      byte[] ByteIm1 = new byte[Is1.available()];
      Toolkit Toolkit1 = Toolkit.getDefaultToolkit();
      Is1.read(ByteIm1);   // replaces previous line
      Image1 = Toolkit1.createImage(ByteIm1);
      repaint();    //this works !!!!!!!
    }
    catch (Exception e) {
//      mMessage.setLength(0);
      mMessage.append("test 3 : ");
      mMessage.append(e.getMessage());
      repaint();
//      System.out.println("Error with getBinaryStream:"+e.getMessage());
    }




  }




  public void start() {
  }



  public void paint(Graphics g) {

    if (Image1 == null) {
//      mMessage.setLength(0);
      mMessage.append(" image is null ! ");
    }
    else {
//      mMessage.setLength(0);
      mMessage.append("there is an image");
      g.drawImage(Image1, 10, 100, null);
    }
    g.drawString(mMessage.toString(),10,100);
  }




//Get Applet information

  public String getAppletInfo() {
    return "Applet Information";
  }


  public String[][] getParameterInfo() {
    return null;
  }

  void buttonControl1_actionPerformed(ActionEvent e) {

  }
}

0
 
LVL 1

Expert Comment

by:viswa081400
ID: 6236093
Does your web server and database reside on the same machine???

Applets can make connections only to the machine where it resides.

So check that out.

good luck!!

-viswa
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:frankjava
ID: 6241069
I'm running Win98, with SQL server 7, and Personal Web Server all on the same machine. I'm calling my applet from a HTLM which I load with HTTP in IE5 or Netscape. Everything on the same machine.

A connection is established. JDataconnect 2.0 is a type 3 driver with has a dataserver running (of course, this very machine), and the DOS box reports a connection being established.

Am I contravening something by doing everything locally ?

Regards

Frank
0
 
LVL 5

Expert Comment

by:vemul
ID: 7616489
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
- To be PAQ'ed and points refunded
Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER !

vemul
Cleanup Volunteer
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 7639814
Finalized as proposed

modulo

Community Support Moderator
Experts Exchange
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question