【问题标题】:Neo4j 2.3.0-M01 cypher query from VB.NET failing来自 VB.NET 的 Neo4j 2.3.0-M01 密码查询失败
【发布时间】:2015-04-24 14:50:44
【问题描述】:

最近在 Windows 7 Prof PC 上安装了新版本的 Neo4j。能够使用 API 批量插入创建节点。来自 Web 界面的 Cypher 查询可以工作,但现在在 VB.NET 代码中的注释“检索查询结果”之后的行中失败,这将在 JSon 中。这在以前的 Neo4j 版本(2.2.x)上运行良好

 Public Shared Function DBQuery(URI As String, PostString As String) As DataView
    'runs query and returns JSon results as a dataview
    'Uses POST method to access Neo4j Server API
    Dim S As String = ""
    Dim HttpWReq As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create(URI)
    HttpWReq.Method = "POST"
    HttpWReq.ContentType = "application/json"
    HttpWReq.Accept = "application/json"
    Dim B1() As Byte = System.Text.Encoding.Unicode.GetBytes(PostString, 0, Len(PostString))

    'POST query
    'http://blog.micic.ch/net/using-neo4j-graph-db-with-c-net
    HttpWReq.Connection = "Open"
    HttpWReq.ContentLength = B1.Length
    Dim newStream As IO.Stream = HttpWReq.GetRequestStream()
    'this method closes stream before calling getResponse
    Using newStream
        newStream.Write(B1, 0, B1.Length)
    End Using

    'retrieve results of query, which will be in JSon 
    Dim HttpWResp As System.Net.HttpWebResponse = CType(HttpWReq.GetResponse(), System.Net.HttpWebResponse)
    HttpWReq.KeepAlive = False
    HttpWReq.Timeout = 15000000

    Dim E As System.Text.Encoding = System.Text.Encoding.GetEncoding(HttpWResp.CharacterSet)
    Dim SR As IO.StreamReader = New IO.StreamReader(HttpWResp.GetResponseStream, encoding:=E)
    S = SR.ReadToEnd  'JSon result
    Return JSonToDV(S)
End Function

v2.3.0 的文档表明需要不同的 conf 文件设置,但这不起作用。文档位于 http://neo4j.com/docs/2.3.0-M01/server-configuration.html 。 neo4j-server.properties 文件最初没有 org.neo4j.server.database.location=data/graph.db 的条目。添加建议的行(org.neo4j.server.database.location="C:/Data/Neo4j/UMLS/graph.db"),然后数据库无法启动。非常感谢建议的解决方案。

【问题讨论】:

  • 我收到的错误是 InternalServerError {500}。也许是查询?在 Web 界面中,这运行成功:MATCH (n:MRCONSO) where n.SAB='SNOMEDCT_US' RETURN n.CUI,n.STR LIMIT 25,但在我的 VB.NET 代码中,这会导致服务器错误,帖子正在使用 {"query":"MATCH (n:MRCONSO) where n.SAB='SNOMEDCT_US' RETURN n.CUI,n.STR LIMIT 25"}。

标签: vb.net neo4j


【解决方案1】:

问题不在于 Neo4j 2.3.0,而在于 VB.NET 代码。有效的更正代码是:

  Public Shared Function DBQuery(URI As String, PostString As String, method As EnumLib.WebServiceMethod) As DataView
    'Used for individual API calls; see BulkUpload for other method
    'Uses POST method to access Neo4j Server API
    Dim ID As Long = 0
    Dim HttpWReq As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create(URI)

    Select Case method
        Case EnumLib.WebServiceMethod.POST
            HttpWReq.Method = "POST"
        Case EnumLib.WebServiceMethod.GET
            HttpWReq.Method = "GET"
    End Select
    HttpWReq.ContentType = "application/json"
    HttpWReq.Accept = "application/json"

    Dim B1() As Byte = System.Text.Encoding.UTF8.GetBytes(PostString, 0, Len(PostString))

    'http://blog.micic.ch/net/using-neo4j-graph-db-with-c-net
    HttpWReq.Connection = "Open"
    Dim S As String = ""
    Try
        HttpWReq.ContentLength = B1.Length
        Dim newStream As IO.Stream = HttpWReq.GetRequestStream()
        'this method closes stream before calling getResponse
        Using newStream
            newStream.Write(B1, 0, B1.Length)
        End Using

        Dim HttpWResp As System.Net.HttpWebResponse = CType(HttpWReq.GetResponse(), System.Net.HttpWebResponse)

        Dim E As System.Text.Encoding = System.Text.Encoding.GetEncoding(HttpWResp.CharacterSet)
        Dim SR As IO.StreamReader = New IO.StreamReader(HttpWResp.GetResponseStream, encoding:=E)
        S = SR.ReadToEnd

    Catch ex As System.Net.WebException
        MsgBox("Message: " & vbLf & ex.Message)
        Dim RS As IO.StreamReader = New IO.StreamReader(ex.Response.GetResponseStream)
        Dim SS As String = RS.ReadToEnd
        PostReturnString = "WebException Error: " & ex.Message & vbLf & vbLf & ex.Status & vbLf & vbLf & SS
        ' MsgBox("Status: " & vbLf & ex.Status & vbLf & vbLf & SS)
    End Try
    Return JSonToDV(S)
    End Function

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-09-29
    • 1970-01-01
    • 2016-10-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多