100分求解程序,急
pbnow 2003-04-27 06:01:46 import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.sql.*;
public class test {
public static void main(String[] args) {
String dburl = "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=myjob";
String user = "sa";
String pws = "";
Connection conn = null;//why must be initialized as null
Statement stmt = null;
ResultSet rs;
try {
Class.forName("com.microsoft.jdbc.sqlserver.SqlServerDriver");
conn = DriverManager.getConnection(dburl,user,pws);
stmt = conn.createStatement();
}
catch(java.lang.ClassNotFoundException e)
{ System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}
catch(SQLException ex)
{ System.err.println("SQLException: " + ex.getMessage() );
}
String query = "select * from t_sudent";
rs = stmt.executeQuery(query);
while (rs.next())
{
System.out.println(rs.getString("st_name"));
}
stmt.close();
conn.close();
}
}
载jbuilder中,提示以下几行出错,错误一样
rs = stmt.executeQuery(query);
rs.next();
System.out.println(rs.getString("st_name"));
stmt.close();
conn.close();
unreported Exception:java.sql.SQLException;must be caught or declared to be thrown
但我有catch语句,不只为啥?
question2:
我怎样在jbuilder中将java tutorial中的java文件加入我自己的jpx文件中使其能在jbuilder中运行?
我能在jbuilder中打开但不能运行?