Applet + SQL - wyświetlanie w przeglądarce

0

Może ktoś wie co należy zrobić żeby uruchomić applet z obsługą SQL w przeglądarce. Applet w Applet Viewer uruchamia się bez błędów. Natomiast gdy chcę uruchomić plik html tego appletu stworzony przez netbeans niestety appletu nie ma.
Co do przykładu to przykładowy plik appletu z obsługą SQL:
Kod:

import java.sql.*; 
import javax.swing.*; 
 
public class Test extends JApplet { 
 
    String url = "jdbc:mysql://localhost/baza"; 
    String user = "root"; 
    String password = ""; 
    StringBuffer results; 
    @Override 
    public void init() { 
        try { 
 
            Class.forName("com.mysql.jdbc.Driver"); 
        } catch (java.lang.ClassNotFoundException e) { 
            System.err.println("ClassNotFoundException: " + e.getMessage()); 
        } 
        try { 
            Connection connection = DriverManager.getConnection(url, user, password); 
            Statement statement = connection.createStatement(); 
            String query = "SELECT * FROM oceny "; 
            ResultSet rs = statement.executeQuery(query); 
            // process query results 
            results = new StringBuffer(); 
            ResultSetMetaData metaData = rs.getMetaData(); 
            int numberOfColumns = metaData.getColumnCount(); 
            for (int i = 1; i <= numberOfColumns; i++) { 
                results.append(metaData.getColumnName(i) + "\t"); 
            } 
            results.append("\n"); 
            while (rs.next()) { 
                for (int i = 1; i <= numberOfColumns; i++) { 
                    results.append(rs.getObject(i) + "\t"); 
                } 
                results.append("\n"); 
            } 
            statement.close(); 
            connection.close(); 
        } catch (SQLException ex) { 
            System.err.println("SQLException: " + ex.getMessage()); 
        } 
        JTextArea textArea = new JTextArea(results.toString()); 
        textArea.setEditable(false); 
        add(new JScrollPane(textArea)); 
    } 
} 

Oraz stworzony plik html przez netbeans:
Kod:

<HTML> 
<HEAD> 
   <TITLE>Applet HTML Page</TITLE> 
</HEAD> 
<BODY> 
 
<!-- 
*** GENERATED applet HTML launcher - DO NOT EDIT IN 'BUILD' FOLDER *** 
 
If you need to modify this HTML launcher file (e.g., to add applet parameters), 
copy it to where your applet class is found in the SRC folder. If you do this, 
the IDE will use it when you run or debug the applet. 
 
Tip: To exclude an HTML launcher from the JAR file, use exclusion filters in 
the Packaging page in the Project Properties dialog. 
 
For more information see the online help. 
--> 
 
<H3><HR WIDTH="100%">Applet HTML Page<HR WIDTH="100%"></H3> 
 
<P> 
<APPLET codebase="classes" code="Test.class" width=350 height=200></APPLET> 
</P> 
 
<HR WIDTH="100%"><FONT SIZE=-1><I>Generated by NetBeans IDE</I></FONT> 
</BODY> 
</HTML>
0

We wszystkich tutorialach i w wielu miejscach javadoca bywa wyryte - "Don't forget package force Luke." ;)
Możesz umieszczanie pliku w pakiecie zignorować w wielu miejscach. Ale w kilku nie możesz. I to jest właśnie jeden z tych kilku przypadków.

1 użytkowników online, w tym zalogowanych: 0, gości: 1