1:jdbc访问sql server 2000一般方法
package test;
import java.sql.*;
public class SqlTest {
public static void main(String[] args) throws SQLException,Exception {
String quryString="select title from titles ";
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
String url="jdbc:microsoft:sqlserver://dbserver:1433;databasename=pubs";
String user="sa";
String password="sa";
Connection conn=DriverManager.getConnection(url,user,password);
Statement stmt=conn.createStatement();
ResultSet rs=stmt.executeQuery(quryString);
----------------------------
//这中间就是具体的应用代码了
while(rs.next()){
System.out.println(rs.getString(1));
}
----------------------------
rs.close();
stmt.close();
conn.close();
}
}
2:session.setMaxInactiveInterval();
public void setMaxInactiveInterval(int interval)
- Specifies the time, in seconds, between client requests before the servlet container will invalidate this session. A negative time indicates the session should never timeout.
3:substring(int beginIndex, int endIndex);
public String substring(int beginIndex, int endIndex)
-
Returns a new string that is a substring of this string. The substring begins at the specified
beginIndexand extends to the character at indexendIndex - 1. Thus the length of the substring isendIndex-beginIndex.
博客展示了使用JDBC访问SQL Server 2000的一般方法,给出了具体的Java代码示例,包括数据库连接、查询语句执行等操作,还提及了session.setMaxInactiveInterval()。
16万+

被折叠的 条评论
为什么被折叠?



