找不到主要方法错误

时间:2009-12-15 08:19:38

标签: java database jdbc

我是jdbc的新手,我尝试通过数据库表单IDE连接。下面的代码是我写的;

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
    try {
        DriverManager.registerDriver(new org.apache.derby.jdbc.ClientDriver());
        Connection conn=DriverManager.getConnection("jdbc:derby://localhost:1527/sample","app","app");
        preparedStatement ps=conn.prepareStatement("select name,zip,discount_code from customer where customer_id=?");
        ps.setInt(1,Interger.parseInt(jTextField1.getText()));
        ResultSet rs=ps.executeQuery();
        if(rs.next()) {
            jTextField2.setText(rs.getString(1));
            jTextField3.setText(rs.getString(2));
            jComboBox1.setSelectedItem(rs.getString(3));
        }                                        
    } catch (NumberFormatException ex) {
        ex.PrintStackTrace();
    }catch (SQLException ex){
        ex.printStackTrace();
    }
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new jdfrm().setVisible(true));
            }
        }
    }

错误是......类“frm1.jdfrm”没有主要方法

2 个答案:

答案 0 :(得分:1)

您的main表单位于private void jButton1ActionPerformed内..请检查括号

答案 1 :(得分:0)

你的括号看起来不对。在main方法之前需要另一个结束。