unreported exception java.sql.SQLException; must be caught or declared to be thrown
private static void sendSms(DBConnection conn, int lngEmpID, String strMessage) {
String sql = "SELECT STRMOVETEL FROM EMPBASEINFO WHERE (LNGEMPID = " + lngEmpID + ")";
String phone = DBUtil.getString(conn, sql);
if (phone != null && phone.startsWith("13")) {
Connection conn_orcl =null;
javax.sql.DataSource ds = null;
ResultSet rs = null;
Statement stm =null;
try {
javax.naming.InitialContext ctx = new javax.naming.InitialContext();
ds = (javax.sql.DataSource) ctx.lookup("jdbc/swoa2.0");
conn_orcl = ds.getConnection();
stm = conn_orcl.createStatement();
String sql_orcl ="insert into sms_tosend(msgid, sendtime,f_flag, phone,msgtext,sendflag) VALUES(SELL.NEXTVAL,SYSDATE-3,'0','"+phone+"','"+strMessage+"','111')";
System.out.println(sql_orcl);
stm.executeUpdate(sql_orcl);
}
catch (Exception e){
System.out.println(e.getMessage());
}
finally
{
//就是这几行代码报错
/*if(rs!=null) rs.close();
if(stm!=null) stm.close();
if(conn_orcl!=null) conn_orcl.close();*/
}
}
}
C:\IBM\WebSphere\AppServer\installedApps\zhangyx\cdyc_war.ear\cdyc.war\WEB-INF\c
lasses>javac swoa\common\Message.java
swoa\common\Message.java:91: unreported exception java.sql.SQLException; must be
caught or declared to be thrown
if(rs!=null) rs.close();
^
swoa\common\Message.java:92: unreported exception java.sql.SQLException; must be
caught or declared to be thrown
if(stm!=null) stm.close();
^
swoa\common\Message.java:93: unreported exception java.sql.SQLException; must be
caught or declared to be thrown
if(conn_orcl!=null) conn_orcl.close();
^
3 errors
什么原因阿???