JAVA,
分享于 点击 26624 次 点评:106
JAVA,
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.
public String substring(int beginIndex, int endIndex)
- Returns a new string that is a substring of this string. The substring begins at the specified
beginIndex
and extends to the character at indexendIndex - 1
. Thus the length of the substring isendIndex-beginIndex
.
相关文章
- 暂无相关文章
用户点评