关于数据库连接的,这段代码能不能帮我解释一下啊!!
石翮 2004-09-15 11:39:45 代码如下:
//连接数据库
String sDBDriver = "sun.jdbc.odbc.JdbcOdbcDriver";
try
{
Class.forName(sDBDriver);
}
catch(java.lang.ClassNotFoundException ae)
{
System.err.println("ae: " + ae.getMessage());
}
String sConnstr = "jdbc:odbc:book";
Connection conn =null;
conn = DriverManager.getConnection(sConnStr,"sa","");
String strSQL; //SQL语句
strSQL="SELECT * FROM guestbook WHERE flag=1 order by Mydate desc";
Statement stmt =
conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
ResultSet result=null;
try
{
result = stmt.executeQuery(strSQL);
}
catch(SQLException be)
{
System.err.println("be.executeQuery: " + be.getMessage());
}
result.last();
intRowCount=result.getRow();
//计算总页数
————————————————————————————————————————
String strSQL; //SQL语句
strSQL="SELECT * FROM guestbook WHERE flag=1 order by Mydate desc";
Statement stmt =
conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
ResultSet result=null;
try
{
result = stmt.executeQuery(strSQL);
}
catch(SQLException be)
{
System.err.println("be.executeQuery: " + be.getMessage());
}
result.last();
intRowCount=result.getRow();
//计算总页数
这一段能不能帮我解释一下,谢谢高手!!