pass welcome系统消息 
分配连接时出错。原因为: com.microsoft.jdbc.sqlserver.SQLServerDriver cannot be cast to javax.sql.DataSource
用netbeans开发visual web jsf 先建立数据库连接,把数据库的表拖到jsf页面上,netbeans自动配置dataprovider,可是当我使用时,总是出现上面的错误。
那位高手有过这方面的资料,请高手帮看看是什么原因,可能的情况也行,谢谢!

解决方案 »

  1.   

    SQLServerDriver  这个是驱动,不是数据源
    SQLServerDataSource 才是数据源
      

  2.   

    类型不对,
    设置一下你拖动的数据库表的属性,填写正确的jdbc驱动类
      

  3.   

    还有,我们一般都用外挂的数据源,比如dbcp,c0p3等!
    不知道你用的是哪个!呵呵!
      

  4.   

    正确的 
    Integer theUserId = (Integer) this.nameField.getText();
            String thePassword = (String) this.passField.getText();
            try {
                getPasswordDataProvider().refresh();
                RowKey rowKey = getPasswordDataProvider().findFirst(
                        new String[]{"password.id", "password.password"},
                        new Object[]{theUserId, thePassword});
                if (rowKey == null) {
                    error("Could not login user id '" + theUserId + "'");
                    return null;
                } else {
                    error("success!!");
                }
            } catch (Exception ex) {
                log(ex.getMessage(), ex);
                error(ex.getMessage());
                return null;
            }
    错误的:
    String theUserId = (String) this.nameField.getText();
            String thePassword = (String) this.passField.getText();
            try {
                getAdminDataProvider().refresh();
                RowKey rowKey = getAdminDataProvider().findFirst(
                        new String[]{"admin.userid", "admin.userpass"},
                        new Object[]{theUserId, thePassword});
                if (rowKey == null) {
                    error("Could not login user id '" + theUserId + "'");
                    return null;
                }
            } catch (Exception e) {
                //log("异常消息!", e);
                error("Could not login user id '" + e + "'");
                return null;
            }
    后面的用的是我的数据库,只是字段的类型不同而已,这有什么区别吗?
      

  5.   

    正确的 
    Integer theUserId = (Integer) this.nameField.getText(); 
            String thePassword = (String) this.passField.getText(); 
            try { 
                getPasswordDataProvider().refresh(); 
                RowKey rowKey = getPasswordDataProvider().findFirst( 
                        new String[]{"password.id", "password.password"}, 
                        new Object[]{theUserId, thePassword}); 

                if (rowKey == null) { 
                    error("Could not login user id '" + theUserId + "'"); 
                    return null; 
                } else { 
                    error("success!!"); 
                } 
            } catch (Exception ex) { 
                log(ex.getMessage(), ex); 
                error(ex.getMessage()); 
                return null; 
            } 
    错误的: 
    String theUserId = (String) this.nameField.getText(); 
            String thePassword = (String) this.passField.getText(); 
            try { 
                getAdminDataProvider().refresh(); 
                RowKey rowKey = getAdminDataProvider().findFirst( 
                        new String[]{"admin.userid", "admin.userpass"}, 
                        new Object[]{theUserId, thePassword}); 

                if (rowKey == null) { 
                    error("Could not login user id '" + theUserId + "'"); 
                    return null; 
                } 
            } catch (Exception e) { 
                //log("异常消息!", e); 
                error("Could not login user id '" + e + "'"); 
                return null; 
            } 
    后面的用的是我的数据库,只是字段的类型不同而已,这有什么区别吗?
    忘了变色了,不好意思。请高手再给解答一下。