Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

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
?
236 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

Question has a verified solution.

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

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses

704 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