eclipse 的重要问题 按错误信息看应该是你的java类中没有main方法。把问题写的更详细,有利于问题的解决 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 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); } } }} 我的环境是eclipse 3.3+MyEclispe6.0,我在里面建了一个jsp2.0的 web工程,然后在src里新建了上面的一个DataBaseConnectTest类,运行始终报错! web工程是用来部署在应用服务器上运行的,不是用main方法来运行的!你新建一个普通java工程吧,在把这段代码放在普通java工程里试试。 如何解决 编辑器中的引号和jsp页面引号冲突问题 有了EL+struts2+jstl1.2还需要velocity这样的项目么? Java 中 break 的另类用法,我没见过,你来看一下啊,解释解释 宇宙霹雳无敌超级世界最虚心的请求一个问题....关于日历的..欢迎进来! 直接用IP访问网站,在tomcat5.5里应该要怎么设置 tomcat4数据连接池问题 讨论:新闻自动搜索要怎么样来做? axis1_1的<SOAP-ENV>标签的问题 求救:关于websphere中cmp与数据源配置的问题 socket问题? j2ee在实际开发中 请大家帮帮我:如何调用类
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);
}
} }}