java - 主要方法未找到错误

标签 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”没有主方法

最佳答案

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

关于java - 主要方法未找到错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1905925/

相关文章:

java - 更改 ActionBar 文本颜色

java - JDBC 中的 Connection、Statement 和 ResultSet 应该多久关闭一次?

java - 如何在 Java Applet 中创建倒计时器?

java - 无法将类型 'java.lang.String' 的属性值转换为属性 'com.mongodb.ServerAddress[]' 所需的类型 'replicaSetSeeds'

database - 当具有多个具有 Play Framework 的数据库时不能使用 save()

database - dataminder如何连接到其他默认提供sql连接的数据库?

mysql - 规范化mysql数据库

mysql - 从 JDBC 调用存储过程时的最佳实践

java - java.sql.Timestamp 时区特定吗?

java - Spring security hasRole() 给出错误 403 - 访问被拒绝