欢迎访问悦橙教程(wld5.com),关注java教程。悦橙教程  java问答|  每日更新
页面导航 : > > 文章正文

JAVA,

来源: javaer 分享于  点击 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 index endIndex - 1. Thus the length of the substring is endIndex-beginIndex.

相关文章

    暂无相关文章
相关栏目:

用户点评