Sybase datatype Issue

                                                                                         Sybase 数据类型

1. 首先我们来关注下Sybase官网对应的java数据类型映射关系

 参照:http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.help.ase_15.0.java/html/java/java138.htm

SQL datatype

Corresponding Java datatypes

Simply mappable

Object mappable

char/unichar

java.lang.String

nchar

java.lang.String

varchar/univarchar

java.lang.String

nvarchar

java.lang.String

text

java.lang.String

numeric

java.math.BigDecimal

decimal

java.math.BigDecimal

money

java.math.BigDecimal

smallmoney

java.math.BigDecimal

bit

boolean

Boolean

 

 

tinyint

byte

Integer

smallint

short

Integer

integer

int

Integer

bigint

java.math.BigInteger

unsigned smallint

int

Integer

unsigned int

long

Integer

unsigned bigint

java.math.BigInteger

real

float

Float

float

double

Double

 

 

double precision

double

Double

binary

byte[]

varbinary

byte[]

datetime

java.sql.Timestamp

smalldatetime

java.sql.Timestamp

date

java.sql.Date

time

java.sql.Time

 

2. 第一次在项目中使用sybase, 所以没有什么经验,所以查了上面的数据类型后开始项目

  有这样一个表:

create table ***(

TASKID               numeric(10,0)
TASKNAME        varchar(255)
FILESIZE           numeric(10,2)

)

由上面的类型表可以见到

numeric  对应  java.math.BigDecimal

所以在执行sql为其设置参数代码如下:

setIntArgument(1, taskId);

setStringArgument(2,filepath);

setDecimalArgument(3, new BigDecimal(fileSize/1000d));

本以为可以顺利执行并返回结果,可是往往事与愿违,没有任何 错误以及异常。苦想很久,最后直接debug看到:

ClassNotFoundException:

arg0:  com.sybase.jdbc3.tds.SybBigDecimal  但是去Sybase提供的驱动包中很显然可以找到,神奇之处。最后果断换掉,

利用

setDoubleArgument(3, fileSize/1000d); 通过,真是好玩啊

 

类似的问题还有:

 

DateTime - Timestamp

 

ClassnotFoundException:

com.sybase.jdbc3.jdbc.ErrorMessage

 

com.sybase.jdbc3.tds.TdsDateTime

 

Syabse的开发人员就是牛啊,居然都不用debug就能开发出这样的数据库来,真是厉害,程序员真是伤不起啊。

 

 

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值