我在Java Swing中进行了设计。数据库连接成功。我将此类添加为main
类,因此编译错误已解决但仍未打开。这是布局
这是代码。我是使用Java Swing和applet的NetBeans的新手。我之前使用过NetBeans来编写Java程序:
package dbms
import dbms.JavaConnectDb;
import java.sql.Connection;
import java.sql.DriverManager;
import javax.swing.JOptionPane;
import oracle.jdbc.OraclePreparedStatement;
import oracle.jdbc.OracleResultSet;
public class register extends javax.swing.JApplet {
public static void main(String[] args)
{
}
Connection conn = null;
OraclePreparedStatement pst = null;
OracleResultSet rs = null;
@Override
public void init() {
try {
java.awt.EventQueue.invokeAndWait(new Runnable() {
public void run() {
initComponents();
}
});
} catch (Exception ex) {
ex.printStackTrace();
}
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
/* all the init components*/
}// </editor-fold>
private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
conn = JavaConnectDb.ConnectDb();
try
{
String sql = "insert into login (fname, lname, uname, pass)
values(?,?,?,?)";
pst = (OraclePreparedStatement) conn.prepareStatement(sql);
pst.setString(2, jTextField1.getText());
pst.setString(3, jTextField2.getText());
pst.setString(4, jTextField3.getText());
pst.setString(5, jPasswordField1.getText());
rs = (OracleResultSet) pst.executeQuery(sql);
if(rs.next())
{
register r = new register();
r.setVisible(true);
}
}
catch(Exception e)
{
}
}
private void jPasswordField1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JPanel jPanel1;
private javax.swing.JPasswordField jPasswordField1;
private javax.swing.JPasswordField jPasswordField2;
private javax.swing.JTextField jTextField1;
private javax.swing.JTextField jTextField2;
private javax.swing.JTextField jTextField3;
// End of variables declaration
}
答案 0 :(得分:0)
在netbeans中,右键单击项目并选择属性。在应用程序&gt; Webstart,有一个选项Applet类。指定主类的完整路径(即包名)。
你做到了吗?
你的问题真的很难阐述。很难说出真正的错误。