按错误信息看应该是你的java类中没有main方法。把问题写的更详细,有利于问题的解决

解决方案 »

  1.   

    import java.sql.*;
    public class DataBaseConnectTest { /**
     * @param args
     */
    public static void main(String[] args) {
    // TODO Auto-generated method stub
    Connection con=null;
    Statement stmt=null;
    Statement stmt1=null;
    ResultSet rs=null;
    try
    {
    Class.forName("com.mysql.jdbc.Driver").newInstance();
     con = DriverManager.getConnection("jdbc:mysql://localhost:3306/sample_db?user=root&password=858602&useUnicode=true&characterEncoding=GB2312");
     stmt = con.createStatement();

    String upd = "INSERT INTO employee(employee_id, last_name, first_name, birth, sex, email) VALUES (null, 'lin', 'mike', '1978/12/27', 'M', '[email protected]')";     

    stmt.executeUpdate(upd);     
     stmt1 = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
    String query = "SELECT * FROM employee";
    rs = stmt1.executeQuery(query);

    rs.last( );
    stmt.close();
    stmt1.close();
    con.close();
    }
    catch(SQLException sqle)
    {
    out.println("sqle="+sqle);
    }
    finally
    {
    try {
    if(con != null)
    {
    con.close();
    }
    }
    catch(SQLException sqle)
    {
    out.println("sqle="+sqle);
    }
    } }}
      

  2.   

    我的环境是eclipse 3.3+MyEclispe6.0,我在里面建了一个jsp2.0的 web工程,然后在src里新建了上面的一个DataBaseConnectTest类,运行始终报错!
      

  3.   

    web工程是用来部署在应用服务器上运行的,不是用main方法来运行的!你新建一个普通java工程吧,在把这段代码放在普通java工程里试试。