📄 connect.java
字号:
package beans;
import java.sql.*;
import javax.servlet.jsp.*;
public class Connect{
private String table = null;
private ResultSet rs = null;
private String driver = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
private String url = "jdbc:microsoft:sqlserver://localhost:1433";
private String user = "nick";
private String password = "123";
private Connection c = null;
private PreparedStatement ps = null;
private int count = 0;
public Connect() throws JspException{
try{
Class.forName(driver);
}
catch(ClassNotFoundException cnfe){throw new JspException(cnfe);}
}
public String getTable(){
return this.table;
}
public void setTable(String table){
this.table = table;
}
public ResultSet getResult(){
return this.rs;
}
public void setResult(ResultSet rs){
this.rs = rs;
}
public int getCount(){
return this.count;
}
public void setCount(){
this.count = count;
}
public void query() throws JspException{
try{
c = DriverManager.getConnection(url,user,password);
ps = c.prepareStatement("select * from "+table,ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
rs = ps.executeQuery();
if(rs!=null){
rs.last();
count = rs.getInt(1);
}
else
count = 0;
}
catch(SQLException sqle){throw new JspException(sqle);}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -