我在Jbuilder中学习创建一个APPLET,用于访问SQLSERVER数据库,在JBUILDER中编译通过并能正常运行,用IE浏览器打开,出现以下错误:
java.lang.NoClassDefFoundError:com/borland/dx/dataset/DataSet
at java.lang.Class.GetDeclaredConstructors0(Native Method)
....
我的IE浏览器装有JAVA 2 1.4.1
初学者,请各位指点,谢谢!
以下是源码:
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import com.borland.dx.sql.dataset.*;
import com.borland.dbswing.*;
import javax.swing.*;
import com.borland.dx.dataset.*;
/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2003</p>
* <p>Company: </p>
* @author not attributable
* @version 1.0
*/
public class Applet1 extends Applet {
private boolean isStandalone = false;
Database database1 = new Database();
QueryDataSet queryDataSet1 = new QueryDataSet();
BorderLayout borderLayout1 = new BorderLayout();
JdbNavToolBar jdbNavToolBar1 = new JdbNavToolBar();
JTabbedPane jTabbedPane1 = new JTabbedPane();
JPanel jPanel1 = new JPanel();
JPanel 列表 = new JPanel();
BorderLayout borderLayout2 = new BorderLayout();
TableScrollPane tableScrollPane1 = new TableScrollPane();
JdbTable jdbTable1 = new JdbTable();
GridBagLayout gridBagLayout1 = new GridBagLayout();
JdbLabel jdbLabel1 = new JdbLabel();
JdbTextField jdbTextField1 = new JdbTextField();
JdbLabel jdbLabel2 = new JdbLabel();
JdbTextField jdbTextField2 = new JdbTextField();
//Get a parameter value
public String getParameter(String key, String def) {
return isStandalone ? System.getProperty(key, def) :
(getParameter(key) != null ? getParameter(key) : def);
}
//Construct the applet
public Applet1() {
}
//Initialize the applet
public void init() {
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
//Component initialization
private void jbInit() throws Exception {
this.setLayout(borderLayout1);
queryDataSet1.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(database1, "SELECT
Customers.CustomerID,Customers.CompanyName,Customers.ContactName,Customers.ContactTitle
,Custom" +
"ers.Address,Customers.City,Customers.Region,Customers.PostalCode,Customers.Country,Custome
rs.Phone,Cu" +
"stomers.Fax FROM Northwind.dbo.Customers", null, true, Load.ALL));
database1.setConnection(new com.borland.dx.sql.dataset.ConnectionDescriptor("jdbc:odbc:sql",
"sa", "", false, "sun.jdbc.odbc.JdbcOdbcDriver"));
database1.setDatabaseName("");
jdbNavToolBar1.setFocusedDataSet(queryDataSet1);
列表.setLayout(borderLayout2);
jPanel1.setLayout(gridBagLayout1);
jPanel1.setBorder(BorderFactory.createLineBorder(Color.black));
jPanel1.setDebugGraphicsOptions(DebugGraphics.LOG_OPTION);
jPanel1.setMinimumSize(new Dimension(4, 4));
jPanel1.setPreferredSize(new Dimension(560, 463));
jdbLabel1.setText("jdbLabel1");
jdbTextField1.setText("jdbTextField1");
jdbTextField1.setColumnName("CompanyName");
jdbTextField1.setDataSet(queryDataSet1);
jdbLabel2.setText("jdbLabel2");
jdbTextField2.setText("jdbTextField2");
jdbTextField2.setColumns(0);
jdbTextField2.setColumnName("ContactName");
jdbTextField2.setDataSet(queryDataSet1);
jdbTable1.setDataSet(queryDataSet1);
this.add(jdbNavToolBar1, BorderLayout.NORTH);
this.add(jTabbedPane1, BorderLayout.CENTER);
jTabbedPane1.add(列表, "列表");
列表.add(tableScrollPane1, BorderLayout.CENTER);
tableScrollPane1.getViewport().add(jdbTable1, null);
jTabbedPane1.add(jPanel1, "详细记录");
jPanel1.add(jdbTextField1, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 35), 18, 0));
jPanel1.add(jdbLabel1, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 2), 42, 5));
jPanel1.add(jdbLabel2, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 57), 0, 0));
jPanel1.add(jdbTextField2, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
}
//Get Applet information
public String getAppletInfo() {
return "Applet Information";
}
//Get parameter info
public String[][] getParameterInfo() {
return null;
}
}
wizards-->archieve builder
类似这样地
<html>
<head>
<title>
JM-CRM 专员用户界面
</title>
</head>
<body >
<applet
codebase = "."
code = "crm.crmApplet.class"
archive = "myjmcrm.jar,dx.jar,dbswing.jar,jds.jar,jdsserver.jar,jdsremote.jar"
name = "TestApplet"
align = "center"
width = "600"
height = "474"
hspace = "0"
vspace = "0"
align = "middle"
>
</applet>
</body>
</html>