📄 newsbean.java
字号:
package users;
import javax.sql.DataSource;
import java.sql.*;
import users.newsForm;
import java.util.ArrayList;
public class newsBean {
Connection conn=null;
public newsBean(DataSource ds)throws Exception {
conn=ds.getConnection();
}
public ArrayList nsearch(String id){
ArrayList a=new ArrayList();
try{
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
String sql="select * from news where n_id="+id;
ResultSet rst=stmt.executeQuery(sql);
newsForm f=new newsForm();
while(rst.next()){
f.setTopic(rst.getString(2));
f.setContent(rst.getString(3));
f.setTime(rst.getString(4));
f.setAuthor(rst.getString(5));
a.add(f);
}
}catch(Exception e){
e.printStackTrace();
}
return a;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -