java rs结果集取值问题

java rs结果集取值问题,第1张

...

stmt = (Statement) conn.createStatement()

rs = (ResultSet) stmt.executeQuery(sql)

rs.next()

int rows=rs.getInt(1)

rows就做基大纯竖是你要的结果锋配

您好,如果有确定的接收字节长度,设置Rthreshold等于接收字节长度有利接收正确率提高.由于你的几个下位机返回数据包字节不等判亏长,你可根据寻址命令发出前预先改变Rthreshold值来保证接收返回符合要求的字节长度.

不然你接收多少字节符合你改发下一寻址命令呢?程序代码处理难度较高.

实际下位机返回数据包可在其代码中补一定其它字纤冲慎节来达到等长,从而使接收代码变毁敬得简洁.

等长接收数据后可对接收处理清0来等待下次接收.

补充:

假如下位机的返回数据按地址号能确定接收字节长度,下列代码可实现接收不等长数据,仅供参考:

Private Sub MSComm1_OnComm()

On Error Resume Next

Dim BytReceived() As Byte

Dim strBuff As String

Dim strData As String

Dim i As Integer

Dim x As Integer

Select Case MSComm1.CommEvent

Case 2

MSComm1.InputLen = 0

strBuff = MSComm1.Input

BytReceived() = strBuff

For i = 0 To UBound(BytReceived)

If Len(Hex(BytReceived(i))) = 1 Then

strData = strData &"0" &Hex(BytReceived(i))

Else

strData = strData &Hex(BytReceived(i))

End If

Next

Text3 = Text3 + strData

If Left(strData, 2) = "00" And Len(strData) = 8 Then

Text1(0).Text = Left(strData, 8)

Call DataClear

ElseIf Left(strData, 2) = "01" And Len(strData) = 10 Then

Text1(1).Text = Left(strData, 10)

Call DataClear

End If

End Select

End Sub


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/12380628.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-25
下一篇 2023-05-25

发表评论

登录后才能评论

评论列表(0条)

保存