SQL 语句 ResultSet 中 getString() getNString() 方法

  • getNString() 方法 api 
    • StringgetNString(String columnLabel)

      获取指定列的值在当前行 ResultSet对象作为 String在Java编程语言 

    • StringgetNString(int columnIndex)

      Retrieves the value of the designated column in the current row of this ResultSet object as a String in the Java programming language.

getNString()方法 api解释

  132618_oN2H_3489292.png

  • getString() api 
    • StringgetString(String columnLabel)

      获取指定列的值在当前行 ResultSet对象作为 String在Java编程语言

    • StringgetString(int columnIndex)

      Retrieves the value of the designated column in the current row of this ResultSet object as a String in the Java programming language

 133111_vw2B_3489292.png

相比之下,getNString()如果查询了属性不为NCHAR、NVARCHAR、LONGNVARCHAR的字段,会报错。

    This getNString method is specified by the getNString method in the java.sql.SQLServerResultSet interface.

    This method can be used to retrieve the value of an nvarcharncharnvarchar(max)ntext, or xml column in the current row of this SQLServerResultSet object. If you try to use this method to retrieve values of other data types, an exception will be thrown.

133220_kR3A_3489292.png

getString()可以查询所有,并不会报错。若非字符或字符串,则会toString一下。

This getString method is specified by the getString method in the java.sql.CallableStatement interface.

All columns in SQL Server can be returned as a string. This means that a string representation of all number-based and character-based types, and a hex-string representation of binary columns such as binary, varbinary, varbinary(max), image, timestamp, and uniqueidentifier, can be returned.

Location-sensitive types such as money, smallmoney, datetime, smalldatetime, float, real, decimal, and numeric will return the canonical toString() format for the underlying value of the type.

User-defined types are returned as hexadecimal string values.

这个getString方法由java . sql中的getString方法指定。
CallableStatement接口。
SQL Server中的所有列都可以作为字符串返回。
这意味着,所有基于数字和字符的类型的字符串表示,以及二进制列(如二进制、varbinary、varbinary(max)、图像、时间戳和唯一的识别符等二进制列的hex字符串表示,都可以返回。
位置敏感类型,如货币、smallmoney、datetime、smalldatetime、float、real、decimal和数值,将返回典型的toString()格式,以确定类型的底层值。
用户定义类型返回为十六进制字符串值。

转载于:https://my.oschina.net/u/3489292/blog/1475313

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值