小编let*_*cia的帖子

SqlServer:用户登录失败

我写了一个非常简单的jdbc登录测试程序.经过各种各样的问题,我几乎得到了它的工作.几乎,似乎无法通过这个"SQLServerException:登录失败的用户xxxxx"问题.

我创建了一个简单的数据库PersonInfo然后我创建了用户user1 password1(sql身份验证).尝试后一切都无法连接到数据库.

我在Win 7上使用SqlServer2008,我从微软获得了最新的jdbc驱动程序.

我的代码是:

import java.sql.*;

public class hell {
public static void main(String[] args) {

    try {
        Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance();
Connection conn=  DriverManager.getConnection("jdbc:sqlserver://localhost:1433;databaseName=PersonInfo;user=Sohaib;password=0000;");


System.out.println("connected");
       }

    } catch (Exception e) {
        e.printStackTrace();
    }
}
}
Run Code Online (Sandbox Code Playgroud)

这是例外

Exception: Unable to get connect
com.microsoft.sqlserver.jdbc.SQLServerException: Login failed for user 'Sohaib'.
and all other supporting errors..
Run Code Online (Sandbox Code Playgroud)

不幸的是,我现在死在水中,直到某种SqlServer Guru或Jdbc Guru对我怜悯并帮助我.

提前致谢.

sql-server jdbc sql-server-2008

32
推荐指数
4
解决办法
9万
查看次数

ASP.NET在GridView中设置DataBound列的宽度

我有一个GridView,它使用BoundField作为列.我正在尝试为我的UserInfo列设置最大宽度.

我尝试了很多方法,但不是很有效.下面是我的GridView的代码:

<asp:GridView ID="GridView1" AutoGenerateEditButton="True" 
ondatabound="gv_DataBound" runat="server" DataSourceID="SqlDataSource1"
AutoGenerateColumns="False">

<Columns>
                <asp:BoundField HeaderText="UserId" 
                DataField="UserId" 
                SortExpression="UserId"></asp:BoundField>

                <asp:BoundField HeaderText="Username" 
                DataField="Username" 
                SortExpression="Username"></asp:BoundField>

                <asp:BoundField HeaderText="UserInfo" 
                DataField="UserInfo" 
                SortExpression="UserInfo"></asp:BoundField>

                </Columns>
</asp:GridView>
Run Code Online (Sandbox Code Playgroud)

寻找有关如何设置特定列宽度的建议,这是我的UserInfo专栏.

c# asp.net gridview

12
推荐指数
2
解决办法
13万
查看次数

Zend Framework 2 Sql选择OR和AND

我想使用Zend\Db\Sql\Select进行此查询:

SELECT table1.* FROM table1 
    INNER JOIN table2 ON table1.columnA = table2.columnB 
    INNER JOIN table3 ON table1.columnC = table3.columnD

WHERE (table2.column2 = 2 or table3.column3 = 3) and table1.column1 = 1

ORDER BY table1.columnE ASC LIMIT 1
Run Code Online (Sandbox Code Playgroud)

到目前为止我有这个代码:

/*@var $db Adapter */
$db = $this->getServiceLocator()->get('db');
$sql = new Sql($db);
$select = $sql->select();

$select->from('table1');
$select->join('table2','table1.columnA = table2.columnB',array());
$select->join('table3','table1.columnC = table3.columnD',array());

$select->where(array('table2.column2' => 2, 'table2.column3' => 3), Predicate\PredicateSet::OP_OR);

$select->where(array('table1.column1' => 1),Predicate\PredicateSet::OP_AND);

$select->order('table1.columnE ASC');
$select->limit(1);

$statement = $sql->prepareStatementForSqlObject($select);
$resultSet = $statement->execute();
Run Code Online (Sandbox Code Playgroud)

但是不起作用,因为产生这个(没有"("和")"为OR):

SELECT …
Run Code Online (Sandbox Code Playgroud)

zend-db zend-framework2

9
推荐指数
2
解决办法
2万
查看次数

如何从具有特殊编码的单词中获取每个字符

我需要从一个单词中获取包含所有字符的数组,但是当我执行以下代码时,单词具有特殊编码的字母,如á.

$word = 'withá';

$word_arr = array();
for ($i=0;$i<strlen($word);$i++) {
    $word_arr[] = $word[$i];
}
Run Code Online (Sandbox Code Playgroud)

要么

$word_arr = str_split($word);
Run Code Online (Sandbox Code Playgroud)

我明白了:

array(6){[0] => string(1)"w"[1] => string(1)"i"[2] => string(1)"t"[3] => string(1) "h"[4] => string(1)"Ã"[5] => string(1)"¡"}

如何获取每个角色如下?

array(5){[0] => string(1)"w"[1] => string(1)"i"[2] => string(1)"t"[3] => string(1) "h"[4] => string(1)"á"}

php encoding character-encoding tokenize

8
推荐指数
1
解决办法
1071
查看次数

Zend Framework 2 SOAP AutoDiscover和复杂类型

我正在准备SOAP服务器并使用以下代码生成我的WSDL:

//(... Controller action code ...)
if (key_exists('wsdl', $params)) {
    $autodiscover = new AutoDiscover();
    $autodiscover->setClass('WebServiceClass')
                 ->setUri('http://server/webserver/uri');
    $autodiscover->handle();
} else {
    $server = new Server(null);
    $server->setUri($ws_url);
    $server->setObject($this->getServiceLocator()->get('MyController\Service\WebServiceClass'));
    $server->handle();
}

//(... Controller action code ...)
Run Code Online (Sandbox Code Playgroud)

但在我的一个WebService方法中,我有一个Array类型的参数,其中每个元素的类型为"MyOtherClass",如下所示:

    /**
     * Add list of MyOtherClass items
     *
     * @param MyOtherClass[]    $items
     *
     * @return bool
     */
    function add($items) {
        // Function code here
    }
Run Code Online (Sandbox Code Playgroud)

当我尝试生成WSDL时,我得到以下错误:

PHP Warning:  DOMDocument::loadXML(): Empty string supplied as input in /<zend framweork path>/Server/vendor/zendframework/zendframework/library/Zend/Soap/Server.php on line 734
Run Code Online (Sandbox Code Playgroud)

或者这个例外:

Cannot add a complex …
Run Code Online (Sandbox Code Playgroud)

php wsdl soapserver zend-soap zend-framework2

8
推荐指数
1
解决办法
7290
查看次数

paypal IPN获得买方交易ID

我需要与交易相对应的买方交易ID,PayPal通过IPN通知我.我正在使用

$_POST['txn_id']
Run Code Online (Sandbox Code Playgroud)

但是这会存储卖方的交易ID,而不是买方的交易ID.同时,买方无法访问卖方的交易ID.

我理解PayPal分配两个不同的交易ID,但卖方需要存储买方交易ID,以便能够与用户就特定交易进行通信.

当PayPal向我的IPN脚本发送通知时,任何人都知道如何接收(或搜索)买方交易ID?

我只收到以下数据:

Array
(
    [mc_gross] => 7.00
    [protection_eligibility] => Ineligible
    [payer_id] => F6912JHUIIHA
    [tax] => 0.00
    [payment_date] => 10:14:55 Sep 11, 2011 PDT
    [payment_status] => Completed
    [charset] => windows-1252
    [first_name] => Name
    [mc_fee] => 2.08
    [notify_version] => 3.2
    [custom] => 
    [payer_status] => verified
    [business] => myemail@gmail.com
    [quantity] => 1
    [verify_sign] => 123232jh4i32u4u3h5n435i43u5455645
    [payer_email] => payermail@gmail.com
    [txn_id] => 123u4324324yuy4574
    [payment_type] => instant
    [btn_id] => 35428120
    [last_name] => lastname
    [receiver_email] => receiver@gmail.com
    [payment_fee] => 2.08
    [shipping_discount] => 0.00 …
Run Code Online (Sandbox Code Playgroud)

paypal paypal-ipn

7
推荐指数
1
解决办法
1万
查看次数

.htaccess到不同端口的特定URL

我想将一些URL重定向到另一个PORT.我的.htaccess是:

RewriteEngine on
RewriteCond %{REQUEST_URI} !^(.*)/$
RewriteCond %{REQUEST_URI} !^(.*)(\.)(.*)$
RewriteRule ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI}/ [R=301,L]
Run Code Online (Sandbox Code Playgroud)

我需要添加一个规则,将开头的^ some-prefix /重定向到端口8080的所有请求,例如:

1- URL

http://www.mysite.com/page1
Run Code Online (Sandbox Code Playgroud)

将重定向到

http://www.mysite.com/page1/
Run Code Online (Sandbox Code Playgroud)

2- URL

http://www.mysite.com/some-prefix/page2
Run Code Online (Sandbox Code Playgroud)

将重定向到

http://www.mysite.com:8080/some-prefix/page2/
Run Code Online (Sandbox Code Playgroud)

我怎样才能做到这一点?谢谢

apache .htaccess mod-rewrite redirect

7
推荐指数
1
解决办法
2万
查看次数

简单的html dom:如何获得没有特定属性的标签

我想得到"class"属性等于"someclass"的标签,但只有那些没有定义属性"id"的标签.

我尝试了以下(根据这个答案),但没有奏效:

$html->find('.someclass[id!=*]');
Run Code Online (Sandbox Code Playgroud)

注意:

我正在使用Simple HTML DOM类,在他们提供的基本文档中,我找不到我需要的东西.

php parsing css-selectors html-parsing simple-html-dom

5
推荐指数
2
解决办法
2821
查看次数

Zend\Session\Container 会话验证失败异常 -- Object(Closure) ZF2

我正在尝试在 ZF2 应用程序中使用身份验证和会话。到目前为止,我有以下代码:

在我的 Module.php 中:

// (...) rest of code

public function getServiceConfig()
    {
        return array(
                'factories' => array(
                        // (...) Other factories

                        // Authentication Service
                        'AuthService' => function($sm) {
                            $dbAdapter           = $sm->get('Zend\Db\Adapter\Adapter');
                            $dbTableAuthAdapter  = new DbTable($dbAdapter,
                                'sec_user','login','password');

                            $authService = new AuthenticationService();
                            $authService->setAdapter($dbTableAuthAdapter);

                            return $authService;
                        },
                ),
        );
    }

// (...) rest of code
Run Code Online (Sandbox Code Playgroud)

然后在我的控制器登录操作中,我有:

use Zend\Session\Container;

// (...) rest of code

    public function loginAction()
    {
       $this->getAuthService()->getAdapter()
                  ->setIdentity('testlogin')
                  ->setCredential('testpass');

        $auth_result = $this->getAuthService()->getAdapter()->authenticate();

        if ($auth_result->isValid()) {
            $session = new Container(); …
Run Code Online (Sandbox Code Playgroud)

php session zend-framework2

4
推荐指数
1
解决办法
3619
查看次数