我的JApplet链接数据库总是找不到驱动,而不用JApplet是可以链接数据库的,小程序代码如下,请各位高手指点:
public class TestTableEditor extends JApplet
{
private JComboBox jcboDriver=new JComboBox(new String[] {
"com.microsoft.jdbc.sqlserver.SQLServerDriver"
,"sun.jdbc.odbc.JdbcOdbcDriver"});
private JComboBox jcboURL = new JComboBox(new String[]{
"jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=ProHope"
});
private JButton jbtConnect =
new JButton("链接数据库并且获取表格");
private JTextField jtfUserName=new JTextField();
private JPasswordField jpfPassword=new JPasswordField();
private String jpf=jpfPassword+"";
private JTextField jtfTableName= new JTextField();
private TableEditor tableEditor1=new TableEditor();
private JLabel jlblStatus =new JLabel(); public TestTableEditor(){
JPanel jPanel1=new JPanel();
jPanel1.setLayout(new GridLayout(5,0));
jPanel1.add(jcboDriver);
jPanel1.add(jcboURL);
 ....... 
 getContentPane().add(new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,jPanel3,tableEditor1),BorderLayout.CENTER);//有待查询
 getContentPane().add(jlblStatus,BorderLayout.SOUTH);
 
 jbtConnect.addActionListener(new ActionListener(){
 public void actionPerformed(ActionEvent evt){
 try{
 //Connect to the database
 Connection connection=getConnection();
 tableEditor1.setConnectionAndTable(connection,jtfTableName.getText().trim());
 }
 catch(Exception ex){
 jlblStatus.setText(ex.toString());
 }
 }
 });
}//connect to a database
private Connection getConnection() throws Exception{
//load the jdbc driver
System.out.println((String)jcboDriver.getSelectedItem());
Class.forName(((String)jcboDriver.getSelectedItem()).trim());
System.out.println("Driverloaded"); //establisish a connection Connection connection =DriverManager.getConnection(((String)jcboURL.getSelectedItem()).trim(),
jtfUserName.getText().trim(),jpf.trim());
jlblStatus.setText("Database connected");
return connection;
}}