如果(设好SQL Server的ODBC之后)写下面的设置则OK  <Realm 
className="org.apache.catalina.realm.JDBCRealm" 
connectionURL="jdbc:odbc:ACCDIY_SQL_ODBC" 
debug="99" 
driverName="sun.jdbc.odbc.JdbcOdbcDriver" 
roleNameCol="role" 
userCredCol="password" 
userNameCol="username" 
userRoleTable="u_user_role" 
userTable="u_users"
/>
如果用MS的SQL Server JDBC Driver的话写如下设置,侧出上面说的错误
  <Realm 
className="org.apache.catalina.realm.JDBCRealm" 
connectionName="sa" 
connectionPassword="sa" 
connectionURL="jdbc:microsoft:sqlserver://CPKF-FANGK:1433;User=sa;Password=sa" 
debug="99" 
driverName="com.microsoft.jdbc.sqlserver.SQLServerDriver" 
roleNameCol="role" 
userCredCol="password" 
userNameCol="username" 
userRoleTable="u_user_role" 
userTable="u_users"
/>(没有写代码)

解决方案 »

  1.   

    另注:
    jdbc:microsoft:sqlserver://CPKF-FANGK:1433;User=sa;Password=sa这个URL我在程序里试过,是可以正常访问SQL Server的
      

  2.   

    <Realm 
    className="org.apache.catalina.realm.JDBCRealm" 
    connectionName="sa" 
    connectionPassword="sa" 
    connectionURL="jdbc:microsoft:sqlserver://CPKF-FANGK:1433;DatabaseName=XXXXXXXXXXXXX" <===
    debug="99" 
    driverName="com.microsoft.jdbc.sqlserver.SQLServerDriver" 
    roleNameCol="role" 
    userCredCol="sa"  <==
    userNameCol="sa"  <==
    userRoleTable="u_user_role" 
    userTable="u_users"
    />
      

  3.   

    connectionURL加上SelectMethod=cursor;
      

  4.   

    jimjxr(宝宝猫) :
    加上SelectMethod=cursor之后,真的可以了,能说说为什么吗?(我会尽快结贴的)
      

  5.   

    我已经在文档中找到原因了,谢谢.
    注:原因如下:
    SelectMethod (cont.) Direct—The direct method sends the complete result set in one
    request to the driver. It is useful for queries that only produce a
    small amount of data that you fetch completely. You should avoid
    using direct when executing queries that produce a large amount
    of data, as the result set is cached completely on the client and
    constrains memory. In this mode, each statement requires its own
    connection to the database. This is accomplished by "cloning"
    connections. Cloned connections use the same connection
    properties as the original connection; however, because
    transactions must occur on a single connection, auto commit
    mode is required. Due to this, JTA is not supported in direct mode.
    In addition, some operations, such as updating an insensitive
    result set, are not supported in direct mode because the driver
    must create a second statement internally. Exceptions generated
    due to the creation of cloned statements usually return an error
    message similar to “Cannot start a cloned connection while in
    manual transaction mode.”
    Cursor—When the SelectMethod is set to cursor, a server-side
    cursor is generated. The rows are fetched from the server in
    blocks. The JDBC Statement method setFetchSize can be used to
    control the number of rows that are fetched per request. The
    cursor method is useful for queries that produce a large amount
    of data, data that is too large to cache on the client. Performance
    tests show that the value of setFetchSize has a serious impact on
    performance when SelectMethod is set to cursor. There is no
    simple rule for determining the value that you should use. You
    should experiment with different setFetchSize values to find out
    which value gives the best performance for your application.
    The default is direct.