边
边尘浪子
Unregistered / Unconfirmed
GUEST, unregistred user!
普通的application可以成功 放到applet里就不行了...
是否 applet 不可以操作数据库?
(我的application和applet和access数据库 放在一个目录里的.....
以下内容为程序代码
--------------------------------------------------------------------------------
import java.sql.*;
import java.applet.Applet;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class One extends JApplet{
public void init(){
String url="jdbcdbc:db1";
Connection con;
Statement stmt;
Container cp=getContentPane();
JLabel lb=new JLabel("hello world");
cp.add(lb);
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}catch(java.lang.ClassNotFoundException e){
lb.setText("Error 1:"+e.getMessage());
System.exit(0);
}
try{
con=DriverManager.getConnection(url,"","");
stmt=con.createStatement();
stmt.executeUpdate("insert into table1(name,beizhu) values('ad','sdf')");
stmt.close();
con.close();
}catch(SQLException ex){
lb.setText("Error 2:"+ex.getMessage());
System.exit(0);
}
}
}
--------------------------------------------------------------------------------
是否 applet 不可以操作数据库?
(我的application和applet和access数据库 放在一个目录里的.....
以下内容为程序代码
--------------------------------------------------------------------------------
import java.sql.*;
import java.applet.Applet;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class One extends JApplet{
public void init(){
String url="jdbcdbc:db1";
Connection con;
Statement stmt;
Container cp=getContentPane();
JLabel lb=new JLabel("hello world");
cp.add(lb);
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}catch(java.lang.ClassNotFoundException e){
lb.setText("Error 1:"+e.getMessage());
System.exit(0);
}
try{
con=DriverManager.getConnection(url,"","");
stmt=con.createStatement();
stmt.executeUpdate("insert into table1(name,beizhu) values('ad','sdf')");
stmt.close();
con.close();
}catch(SQLException ex){
lb.setText("Error 2:"+ex.getMessage());
System.exit(0);
}
}
}
--------------------------------------------------------------------------------