简体   繁体   English

netbeans找不到主类

[英]netbeans cannot find main class

I am trying my hands on a simple tutorials that 我正在尝试一个简单的教程,

  • connects a java program to a simple java DB 将Java程序连接到简单的Java DB
  • using the NetBeans 7 IDE. 使用NetBeans 7 IDE。

Here is the link to the tutorials. 是教程的链接。

But when I run the project, NetBeans gives me the following error: 但是,当我运行项目时,NetBeans给我以下错误:

 run:
Error: Could not find or load main class database_console.DBConnect
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)

Below is the code for the main class: 下面是主类的代码:

package database_console;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class DBConnect {
    public static void main(String[] args) {
        try {
          String host = "jdbc:derby://localhost:1527/Employees";
          String uName="faisal";
          String uPass="password";
          Connection con=DriverManager.getConnection(host, uName, uPass);        
        }
        catch ( SQLException err ) {
          System.out.println( err.getMessage( ) );
        }
    }
}

Any one with a suggestion is welcome. 任何有建议的人都欢迎。

必须从Netbeans项目窗格中关闭项目,关闭netbeans IDE,然后再次启动netbeans IDE,最后再次打开项目以解决问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM