- 论坛徽章:
- 0
|
请看看,我从记录集中取记录为什么取不出来?
这地方我也不专业。我的写法是这样的.
package sys;
import java.sql.*; // JDBC驱动程序用的Sybase Jconnect_55
public class conn {
String sConnStr = "jdbc:sybase:Tds:182.69.1.66:8888?charset=eucgb&jconnect_version=0";
Connection con = null;
ResultSet rs = null;
Statement stmt =null;
// 用来查询的Method
public ResultSet Query(String sql) throws SQLException,Exception {
Class.forName("com.sybase.jdbc2.jdbc.SybDriver".newInstance();
con = DriverManager.getConnection(sConnStr,"****","****"
Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);
rs = stmt.executeQuery(sql);
return rs;
}
// 用来插入,删除,更改的method
public void Update(String sql) throws SQLException,Exception {
Class.forName("com.sybase.jdbc2.jdbc.SybDriver".newInstance();
con = DriverManager.getConnection(sConnStr,"****","****"
Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);
stmt.executeUpdate(sql);
}
//用来关闭结果集的method
public void CloseRs() throws SQLException,Exception{
rs.close();
}
//用来关闭stmt的method
public void CloseStmt() throws SQLException,Exception{
stmt.close();
}
// 用来关闭数据库连的method
public void CloseCon() throws SQLException,Exception{
con.close();
}
} |
|