Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
con= DriverManager.getConnection("jdbc:sqlserver://localhost:1433;DatabaseName=pxw","sa","881219");
stmt=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
stmt2=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
stmt3=con.createStatement();
int i=0;
int num=0;
rs3=stmt3.executeQuery("select * from 績效評估結果表");
String r1 = "insert into 績效評估結果表 (工號,姓名,等級) select UserID,UserName,TLevel from 教師信息表";
if(!stmt.executeQuery("select * from 績效評估結果表").next())
{
stmt.executeUpdate(r1);
}
rs=stmt.executeQuery("select * from 教師工作量");
rs2=stmt2.executeQuery("select * from 參數表");
ResultSetMetaData metaData;
ResultSetMetaData metaData2;
metaData = rs.getMetaData();
metaData2 = rs2.getMetaData();
rs.last();
rs2.last();
number=rs.getRow();
numbercanshu=rs2.getRow();
報這個錯 Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
好像是一個 sql 連接裡面 只有一個statement 和 resultset 把,你可以試試,多個的需要多次調用重新建立連接什麼的……